Self-Balancing Robot
User Guide
15
www.terasic.com
July 12, 2018
From
Figure 1- 11
, It can be seen if the balance of the car is tilted forward or backward,
corresponding changes resulting the acceleration of the X-axis and Y-axis. Meanwhile, the angular
speed of the Y-axis will also change.
Figure 1- 11 Status of the XYZ coordinates on the mpu-6500
Continue to introduce how to calculate the tilt angle of the balance car from the accelerometer.
Figure 1- 12
, ignore the horizontal acceleration of the car, there is a vertical angle θ when body tilts
forward or backward. G is for the acceleration of gravity. Resolve g vector into X and Z directions,
gx and gz are coordinate components for X-axis and Z-axis respectively, θ is the tangent angle of gx
or gz. Read out the values of gx & gz from the accelerometer in the MPU-6500. Get the degree of
angle θ by using the function θ = arctan(gx/gz).