Welcome to 520 Motor repository
10.Car steering control (PD)
Car steering control (PD)
The tutorial mainly introduces the steering control of the balancing car.
Steering principle
The steering control can be achieved by the different speeds (speed difference) of the left and right motors of the balancing car.
PD controller
The main function of differential (D) control in PID control is to reduce the dynamic error and oscillation of the system, and the main function of integral (I) control is to eliminate static errors.
Since the car itself is equipped with heavy objects such as batteries and has a large moment of inertia, the car will overshoot during the adjustment process. If it is not suppressed, the car will over-steer and fall down; in order to eliminate the overshoot in the direction control of the car, it is necessary to add differential control.
Implementation code
xint Turn_PD(float gyro){static float Turn_Target,turn_PWM;float Kp=Turn_Kp,Kd; //To change the steering speed, please change Turn_AmplitudeTurn_Target=0;Kd=Turn_Kd;//==============================================//turn_PWM=Turn_Target*Kp/100+gyro*Kd/100+Move_Z; //PD control combined with Z-axis gyroscopereturn turn_PWM; //Steering ring PWM is positive for right turn and negative for left turn}
Software code
Basic PID control of balancing car: 08-13 tutorial only provides one project file.
Product supporting materials source code path: Attachment → Source code summary → 3.PID_Course → 08-13.Balanced_Car_PID