Introduction: R/C Car Balancing Robot
Hi! This is Kaeru no Ojisan.
We can find many balancing robots (even with open-source code) in website.
Then I have tried to find a balancing robot based on an actual automobile or a commercially-sold R/C car such as Tamiya R/C car. But I cannot find an appropriate one. So I have decided to make R/C Car Balancing Robot by myself based on Tamiya R/C car.
These videos show my achievement of R/C Car Balancing Robot.
This is an inverted balancing and different from a Wheelie.
Also, it is noted that this project is based on a commercially-sold R/C car which has only one driving motor, and that is quite different from other balancing robots which have two driving motors.
The balancing robot with two motors can make on-the-spot-turning by one motor normal rotation and the other reverse rotation.
But I have achieved on-the-spot-turning with one motor by the body turbulence and right/left wheel breaking.
I have referred to these websites for my project. I appreciate the predecessors’ great works.
http://ichiro-maruta.blogspot.jp/2012/04/arduino_30.html
http://cienciaycacharreo.blogspot.jp/2013/10/b-robot-un-robot-equilibrista-impreso_28.html
http://maverickengineer.web.fc2.com/
https://www.instructables.com/id/A-Simple-and-Very-Easy-Inverted-Pendulum-Balancing/
I wish that my project would stimulate someone who will realize an Actual Automobile Balancing Robot.
Step 1: Materials
- TAMIYA BLITZER BEETLE 1/10th Scale Radio Control Off Road Racer
- TAMIYA SP-374 Monster Pin Spike Tires
- TAMIYA NiCd Battery 7.2V 1300Ah Custom Pack
- Arduino UNO R3
- Arduino Proto Shield
- Pololu VNH2SP30 Motor Driver Carrier MD01B
- Pololu ACS714 Current Sensor Carrier -30A to +30A
- MPU6050 Triple Axis Accelerometer & Gyro Breakout
- Multiwii MWC FC Bluetooth Module Programmer
- Futaba S3003 Servo
- TowerPro 9805BB Servo
- TowerPro MG90S MicroServo x 2
- SANYO eneloop KBC-L3A (power supply for Arduino)
- Turnigy 800mAh 3S 40C Lipo Pack
- HRD-12003 DC/DC Converter
- Cable, Screw, Pin Socket, etc.
Step 2: Assemble
Assemble R/C car in accordance with the instructions manual.
Except;
Replace rear tire to bigger one. (SP-374 Monster Pin Spike Tires)
Offset rear wheel axis 10mm backward.
Adjust gear case screw location.
Mount Arduino UNO + Proto Shield.
Mount 800mAh Lipo Pack and DC/DC Converter. (5V power supply for 3 servos)
Attach rise-up servo and break servos for right/left wheels.
Step 3: Schematic for Inverted Balancing on the Spot
Attachments
Step 4: Arduino Code for Inverted Balancing on the Spot
As far as I know, an inverted pendulum can be achieved by controlling the driving motor torque in Lagrange's equation. Motor torque can be controlled by a current to motor or an angular acceleration of motor.
In this project I apply motor current control.
Required motor current for the inverted balancing is calculated as following formula;
iValue = K1 * theta + K2 * phi + K3 * dtheta + K4 * dphi
iValue: requied motor current (A)
theta: wheel angle (rad) ------ computed by integration of dtheta
phi: body angle (rad) –---- obtained from MPU6050 sensor
dtheta: wheel angular velocity (rad/sec) ------ estimated using measured current value and PWM value
dphi: body angular velocity (rad/sec) ----- computed by differentiation of phi
K1, K2, K3, K4: gains (these figures can be found by try and error.)
(Estimated dtheta and theta are inaccurate, but these are working in this project.)
Direct current control is difficult. So, I measure current to motor (iCurrent) and based on error (iValue – iCurrent) feed back to PWM value to motor proportionally with low-pass filter.
These above mentioned are summarized as follows;
float K1, K2, K3, K4;
float theta, dtheta, phi, dphi;
float iValue, iCurrent, iError;
float Ka;
float iMotor;
void loop()
{
iValue = K1 * theta + K2 * phi + K3 * dtheta + K4 * dphi;
iError = iValue - iCurrent;
iMotor = smooth(Ka * iError, 0.05, iMotor);
MotorDrive(iMotor);
}
On-the-spot-balancing is not so fun!
R/C car should be remote controlled.
Then, make it remote control!
Attachments
Step 5: Schematic Adding Remote Control
Attachments
Step 6: Arduino & Processing Code for Remote Control
In this Project R/C Car Balancing Robot is controlled by Processing on PC via Bluetooth.
Ordinary balancing robot (which can be turned) has two driving motors. But my project is based on a commercially-sold R/C car which has only one driving motor. So, turning is controlled by wheel break servos that are attached near at rear right and left wheels.
Furthermore, forward and backward is controlled by Servo System with Integral Mode Controller. In this project, wheel angle is calculated by integration of estimated wheel angular velocity and it is inaccurate. In Servo System with Integral Mode Controller, the error of wheel angle seems to be accumulated, but it is working for forward and backward control.
Normal 4 wheel driving
Forward, backward, stop, right turn and left turn can be selected.
Forward, backward and stop are controlled by motor driver.
Right turn, left turn and straight are controlled by steering servo.
Rise-up
Rise up and change from normal 4 wheel driving mode to inverted balancing mode.
Rise-up is conducted by large servo attached to underneath of car body.
To avoid body disturbance after mode change, K3 (gain for wheel angular velocity) is set smaller.
Inverted balancing
Forward, backward, on-the-spot-balancing, right turn, left turn, on the spot turns (CW and CCW) can be selected.
On the spot balancing ------ State Feedback.
Forward and backward ------ Servo System with Integral Mode Controller.
Right turn and left turn are made by wheel break servos.
On-the-spot-turning is achieved by setting K3 value larger (make body disturbance large) and controlling wheel break servos in response to wheel rotation direction.
Lay-down
Lay down and change from inverted balancing mode to normal 4 wheel driving mode.
Lay-down is made by wheel rotation direction forward and then setting PWM value zero.
Attachments
Step 7: Memorandum
I thought 6V is required for rise-up servo, but 5V enough, so DC/DC Converter can be replaced to much cheaper UBEC.
The output from current sensor is directly connected to Arduino and that makes body disturbance. The body disturbance is required for the turning in this project, but that can be controlled by K3 gain value. In order to reduce the buttery consumption, the output from current sensor to Arduino shall be through low-pass filter (resistance + capacitor).
I applied P-control for current control, but considering the buttery consumption, PI-control is much better.
I think it is because of 10mm backward offset of rear wheel axis (or it might be due to this R/C car model), but the motor force does not transmit equally to the right and left wheels. In normal 4 wheel driving, it does not have effect to straight forwarding, but in inverted balancing, it makes the car body right turning, and I added the code for straight adjustment.
I use eneloop for power supply to Arduino, but that can be provided from NiCd Battery.