Self Balancing Robot Controlled by Micro Python – Jeff Magee 2015apr21, 5,570 views
2 x 12v NEMA17 stepper, motor drivers A4988, gyro & accelerometer mpu6050, controlled by pyboard.
德源科技 兩輪自平衡小車 2WD 金屬電機 雙輪平衡小車 智能小車 1:21電機 (適用JGA25-371) TW$1,230
https://goods.ruten.com.tw/item/show?21402246427970
JGA25-371全金屬電機, 帶有高精度碼盤,一圈有334個脈衝
https://goods.ruten.com.tw/item/show?21402246427970
Building a [Self Balancing Two Wheel Car] with Raspberry Pi – KevinK6 2015, 56,299 views
https://www.instructables.com/id/Building-a-segway-in-Raspberry-Pi/
JGA25-371 DC mmotor with 334 pulse encoder, L293D motor driver, MPU6050 gyro, wiringPi library, complimentary filter
To get acceleration information, execute
$ sudo ./mpu6050_accl
You should see something like:
My acclX_scaled: 0.140625
My acclY_scaled: -0.031006
My acclZ_scaled: 0.994141
My X rotation: -1.768799
My Y rotation: -8.047429
The above acclX, acclY & acclZ are the measured acceleration in g(the g=9.8m/s^2) in X, Y and Z axis.
In fact, the accelerometer only tells us acceleration information. With some basic trigonometric functions calculation, we can obtain the orientation angles. They are “My X & Y rotation” and the unit is in degree.
Let’s also check gyroscope measurement. execute:
$ sudo ./mpu6050_gyro
It will tell you the velocity (in degree/s) of angle in each axis, like this.
My gyroX_scaled: -4.312977 <br>My gyroY_scaled: 0.458015 <br>My gyroZ_scaled: 0.366412 <br>My gyroX_scaled: -4.053435 <br>My gyroY_scaled: 0.427481 <br>My gyroZ_scaled: -0.160305
Please try rotate the car frame and watch the changes by time. Then you will understand the gyroscope measurement more.
If we only use acceleration information to calculate the orientation angle, the angle will be not stable and not reliable. So, somebody invent the method to use the velocity of angle information to calculate the angle, and complement with the angle from acceleration. Then it will give us more stable and reliable angle.
It’s so-called “Complementary filter“. You will see the complementary filter in our code later. Check for more detail explanation in reference documents.
.END
Categories: MPU6050, Raspberry Pi, Self Balancing Robot