# Remote control balancing car based on Liangshan School
## Material selection
### Main control: Liangshan School development board
### Motor driver: TB6612 module or L298N module. ![Screenshot 2023-02-27 012504.png]

![TB6612 module.png]

### Power supply: 11.1V model aircraft lithium battery, regulated to 5V through LDO (ME6118A50) to power each module and development board. (It will be better to use DC-DC chips)! [Model aircraft lithium battery.jpg]

### Bluetooth: HC-06 Bluetooth module (anything that can be used normally is fine). ![HC-06.png]

### Motor: I chose the larger power GB37-520 with encoder, which can easily introduce a speed closed loop to the car. ![37GB-520 encoding motor.jpg]

### Gyroscope: Select the MPU6050 module to output the attitude angle and introduce an angle closed loop. ![image.png]

### RGB light: WS2812E RGB 4P is used to display the status of the car. ![image.png]

## Code part
### Motor driver: Determine the details of code writing based on the module truth table used. ![TB6612 truth table.png]

### MPU6050: Port the DMP library and read data through hardware IIC.
### Bluetooth: Through the mobile phone APP - Bluetooth debugger, use the "professional debugging" function to develop your own graphical control interface. Currently, only a simple Bluetooth debugging PID parameter function has been developed. ![Bluetooth debugger.png]

### Balance control: Using cascade PID control, currently only the upright loop has been developed, and the speed loop is under development.
### Code reference: http://t.csdn.cn/K3bDg
## Notes
### 1. When the motor drive module smokes (breaks down), turn off the power quickly to prevent the motor from killing the main control. Then replace it with a new one and stop using it (personal experience).
### 2. Pay attention to the layout of the PCB and the mechanical structure you want. My own version was not done well.
## Photos of the car
![IMG_20230226_144457.jpg]

![IMG_20230227_011228.jpg]

![IMG_20230227_011318.jpg]

## Summary
### The driving of each part has been completed, and the distance should be needed to really allow the car to achieve a better balance effect. Join the speed closed loop and will continue to update it in the future.
### Undergoing major changes...