Design and Development of Two Wheeled
Design and Development of Two Wheeled
Design and Development of Two Wheeled
Authorized licensed use limited to: ULAKBIM UASL ISTANBUL TEKNIK UNIV Expert now Trial User. Downloaded on December 5, 2009 at 17:16 from IEEE Xplore. Restrictions apply.
4th Student Conference on Research and Development (SCOReD 2006), Shah Alam, Selangor, MALAYSIA, 27-28 June, 2006
PIC 16F 877A will be used on this project due to Error = Setpoint Reading – Current Sensor Reading
its special functions registers like 8 Analog to Digital + Input signal from RC receiver (1)
Converter module and 2 PWM generator module which are
needed on this project. The output of the sensor which is in The input signals from RC receiver are: signal to move
analog voltage will be connected to the PIC microcontroller forward and backward
A/D input pin. Beside that, two PWM generators will be
used to activate the robot’s motors and 20 MHz oscillator The proportional term increases the motor power as the
will be used to generate pulse for the microcontroller. To robot leans further over and decreases the motor power as
interface the DC motor and the microcontroller, a motor the robot approaches the upright position. A gain factor, Kp,
driver is needed. On this project, L293B will be used to do determines how much power to apply to the motors for any
the interfacing. It provides total DC current up to 2 Ampere. given lean, as follows:
In order to generate PWM pulse to two DC motors, the
output pin of the PWM (CCP1/CCP2) will be connected to Output Proportional Term = Kp * Error (2)
the L293B motor driver enable pin.
The 12V 1100mAH Ni-Mh rechargeable battery is While the proportional term is effective at
used as the power source for the robot. responding to the lean, once the robot reaches the upright
position it will proceed to tip in the opposite direction until
Control System the proportional control term increases the motor power
enough to reverse the robot’s motion, rotating it back in the
1-4244-0527-0/06/$20.00 © 2006 IEEE 170
Authorized licensed use limited to: ULAKBIM UASL ISTANBUL TEKNIK UNIV Expert now Trial User. Downloaded on December 5, 2009 at 17:16 from IEEE Xplore. Restrictions apply.
4th Student Conference on Research and Development (SCOReD 2006), Shah Alam, Selangor, MALAYSIA, 27-28 June, 2006
other direction. Therefore, the robot will oscillate back and Error of Right Motor Speed = Setpoint of right motor –
forth, just as a car with worn out shock absorbers bounces Current Speed Reading of Right Motor (10)
for a long time when the car goes over a bump [11].
Output Proportional Term of Right Motor
The differential term of the PID algorithm acts as a = Kp * Error of Right Motor Speed (11)
damper reducing oscillation. Another gain factor, Kd,
determines how much power is applied to the motors Output Differential Term of Right Motor
according to the following equation: = Kd * (Error of Right Motor Speed – Last Error of Right
Motor Speed) (12)
Output Differential Term Output Integral Term of Right Motor
= Ki * Sum of Error for Right Motor Speed (13)
=Kp Kd * (Error – Last Error) / T (3)
=(Kp Kd/T) * (Error – Last Error) (4)
Right Motor Speed = Proportional Term of Right Motor +
Differential Term of Right Motor + Integral Term of Right
Simplify as below:
Motor (14)
=KD * (Error – Last Error) (5)
For tuning the PID control of motor speed, the
Finally, neither the proportional nor differential
value of Kp Ki and Kd is get by trial and error method.
terms of the algorithm will remove all of the lean because
Although this is not efficiency method but it can control the
both terms go to zero as the orientation of the robot settles
speed of motor very well. For the speed control of left
near vertical.
motor, same method is using same as right motor speed
control algorithm.
The integral term sums the accumulated error (error
summed over time) and applies power in the opposite
direction indicated by the sum to drive the lean to zero, as
III. RESULT AND CONCLUSION
follows:
The Balancing Robot has successful balance itself
Output Integral Term
in upright position and the navigation of the robot can
= KpKi * Sum of Error * T (6)
control by a human operator. However, it has some
= KpKiT* (Sum of Error) (7)
drawbacks. The robot only can balance on a flat terrain. In
order to improve this problem, more advance sensors and
Simplify as below:
powerful algorithm must be implemented. Below figure is
= KI * (Sum of Error) (8)
the actual output of the robot which show the tilting angle
and PID controller output of the robot.
The output of the PID controller for balancing the robot will
be: The Actual Output of Two Wheeled Balancing Robot
zero first and the Kp is slowly increase until the robot start 10
to oscillate. Next, the Ki is slowly increased until the robot
start to oscillate again. Then the Kd is slowly increased 0
until the robot is stable and is not oscillating. Then the PID -10
controller is tuned. Although the tuning method used is not
optimized, but it does stabilized the robot to a level that it -20
The PID controller for both of the motor speed will use -40
Time
the same method as above. The output of the Motor PWM
as equation (9) above will be used as the setpoint for left
and right motors. The Back EMF method used to detect the
current speed of both motors. The Back EMF refers to Fig. 4: The PID Output of the Robot.
using the voltage generated by a spinning motor (EMF) to
check the current speed of the motor's rotation [12].
Authorized licensed use limited to: ULAKBIM UASL ISTANBUL TEKNIK UNIV Expert now Trial User. Downloaded on December 5, 2009 at 17:16 from IEEE Xplore. Restrictions apply.
4th Student Conference on Research and Development (SCOReD 2006), Shah Alam, Selangor, MALAYSIA, 27-28 June, 2006
IV. ACKNOWLEDGEMENTS
V. REFERENCES
Authorized licensed use limited to: ULAKBIM UASL ISTANBUL TEKNIK UNIV Expert now Trial User. Downloaded on December 5, 2009 at 17:16 from IEEE Xplore. Restrictions apply.