![Terasic Self-Balancing Robot Скачать руководство пользователя страница 30](http://html.mh-extra.com/html/terasic/self-balancing-robot/self-balancing-robot_user-manual_1088554030.webp)
Self-Balancing Robot
User Guide
28
www.terasic.com
July 12, 2018
loop corresponds to the
int turn(float Gyro)
function in the software of our demo.
The block diagram of the three loops integrated function is shown in
Figure 1- 21
.
Figure 1- 21 PID closed-loop Control with Angle, Speed and Turn of the Robot
Note:
The PID parameters of the balance loop, speed loop and turn loop have polarity, so the
feedback must be formed positive feedback to become the closed loop control which is
advantageous to the robot balance.
The corresponding codes are
Encoder_Integral=Encoder_Integral-Movement;
in the
int speed(void)
function and
Bias+=110;
and
Bias-=110;
in the int turn(float Gyro) function. When the Bluetooth
and IR send control commands, the speed loop and turn loop start working. The robot does a linear
motion at a set speed, and rotates at a set angular speed.
The status of the robot needs to be sampling controlled at regular intervals. In our demo, the interval
time is 10ms. The sampling control of the angle, speed and rotation angle can be implemented by
executing the interrupt function void
MPU_INT_ISR(void * contex, alt_u32 id)
. Meanwhile, the
while function in the main code is used for polling the Bluetooth/IR control signal, ultrasonic
detection obstacle distance (for obstacle avoidance) signal and power monitoring signal.
The main routine flow chart is shown in
Figure 1- 22
.