The power to keep the car upright and running is derived from the two wheels of the car.Wheel rotation is driven by two DC motors.Therefore, the car as a control object, the control input is the rotation speed of the two motors from the control point of view, trolley motion control task can be decomposed into the following three basic control tasks:
1: Control car balance:Keeping the state of upright and balance of the car by controlling the forward and reverse movement of the two motors;
2. Control car speed:Car speed control is achieved by adjusting the positional deviation of the car,in the end it actually evolved to control the speed of the motor to achieve wheel speed control;
3. Control the direction of the car:The steering control of the car is achieved by controlling the rotational differential between the two motors.
Download the arduino link:https://www.arduino.cc/en/Main/Software, open the arduino IED,and download the balance car code, then open the code folder osoyoo_abc.
Download library files - balance libraries,add library files.the first method:Directly click on the item —>Loading library file->Add a .ZIP, select the path of your library file to add it. Check if your library file was added successfully. Click File -> Samples.You can view your library file.
The second method: unzipping files of balance libraries directly,Copying and pasting the file that under the directory directly on the libary directory that under the arduino installation path.
The control of the balance, speed, and direction of the car uses angle, speed, and direction rings,respectively.Debugging parameters of PID is a long process.Each link has a certain degree of influence with each other. Therefore, it needs to be debugged patiently to find a set of optimal parameters.
The balance car angle uses a PD (proportional derivative) controller.In debugging, we need to adjust the values of Kp and Kd,make the car have a good speed and stability.The parameter used for the calculation of the angle is the tilt angle of the car.Kp is the coefficient of inclination of the car,Kd is the coefficient of angular velocity,it is used to reduce the over adjustment by the proportional adjustment. It is according to the sequence :first P (proportional), after D (differential).
(1) Determine the size of Kp
The principle of determining parameters: Kp keeps increasing until there is a large amount of low frequency jitter.
(2) Determine the size of Kd
The principle of determining parameters:Kp keeps increasing until high frequency jitter occurs.
We can sure that Kp=40 and Kd=0.6are the maximum parameters of P and D ,we try not to exceed these two values in the later debugging process ,decrease the value properly,you can see that the car after adjustment is smoother.However, it is still unable to maintain a long period of erection,after standing for a short period of time, it will accelerate in one direction,so we can add speed loop to get better performance,but the angle loop is very difficult for the car to keep a good upright effect.At this point, the upright debugging part has come to an end.
The speed loop controls the speed of the car.On the one hand, the car is more stable when it is stationary, the car will not fall sideways,on the other hand, the car can be driven upright.The speed loop uses a PI (Proportional Integral) controller.The parameter used to calculate the speed loop is the speed of the car.It is necessary to set the parameters of upright before adjusting the speed .Here we set Kp=40 and Ki=0.6,first adjust I (integral) and then adjust P (proportion).
1.Determine the size of the Ki_speed value
2. Determine the size of the Kp_speed value The principle of determining the parameters: Kp_speed keeps increasing until the cart can stay upright and not easily fall down.
Therefore, we set Ki_speed=0.25,Kp_speed=5.20,this is just a rough demonstration of the parameter debugging process,not the optimal parameter,the size of the parameters can be further fine-tuned according to the actual situation.
After the adjustment of the upright ring and the speed ring,the car has been able to remain stable and upright,due to the actual deviation of the left and right motors,it is necessary to introduce a directional ring to control the direction of going straight of the car to prevent the car from yawing.
The above method is the static parameter adjustment method of the car.You can get the parameters of making car stand upright.If the car is in poor state of upright,the parameters need to be fine-tuned again to make the car have better state when working.In general, the proportional parameters affect the adjustment speed of the car ,Differential parameters affect the stability of the car;The integration parameters are related to the accuracy of the adjustment.The following figure shows the optimal parameters for all parameter adjustments.Differential parameters affect the stability of the car,the integration parameters are related to the accuracy of the adjustment.The following figure shows the optimal parameters for all parameter adjustments.The following describes the weight adjustment of the balance car's load.
The upper limit of the weight of the balance car is 2KG. After the upper limit is exceeded,the motor will run on the load and cause damage to the motor.The acceleration cannot be too fast,otherwise the center of gravity will be unstable and the car will easily fall.The following shows the smooth and optimal parameters of a balanced car.
DownLoad Url osoyoo.com