Design of Two Wheel Inverted Pendulum: JANUARY 19 2020
Design of Two Wheel Inverted Pendulum: JANUARY 19 2020
Design of Two Wheel Inverted Pendulum: JANUARY 19 2020
Pendulum
JANUARY 19 2020
The importance of TWIP Robot
The basic idea of the TWIP
In accordance with these parameters, the equations of motion of the robot could be
established by Lagrangian theory, and state equations are formed after proporate choice of
status variables, figure on the left is angle of robot tilt, figure on the right shows tiling
velocity
Angle conversion
The angular velocity sensor is a gyroscopic MEMS in the 6050 IMU. The angular
velocity digital increment is as follows:
gyro=AdcAin1−(4096∗1.23)/3
The angular velocity value (in radians) is as follows:
gyro∗=0.05859375∗(3.1415926/180).
Kalman filter
We used a sort of trial and error to tune our PID controller applied in the code, we also changed the controller from
UNO to mega for extra clock speed and the advantage of the two extra analog input ports A6&A7:
PID stands for Proportional, Integral, and Derivative. Each of these terms provides a unique response to our self-
balancing robot.
The proportional term, as its name suggests, generates a response that is proportional to the error. For our system,
the error is the angle of inclination of the robot.
The integral term generates a response based on the accumulated error. This is essentially the sum of all the errors
multiplied by the sampling period. This is a response based on the behavior of the system in past.
The derivative term is proportional to the derivative of the error. This is the difference between the current error
and the previous error divided by the sampling period. This acts as a predictive term that responds to how the robot
might behave in the next sampling loop.
Multiplying each of these terms by their corresponding constants (i.e, Kp, Ki and Kd) and summing the result, we
generate the output which is then sent as command to drive the motor.
Tuning the PID
Set Ki and Kd to zero and gradually increase Kp so that the robot starts to oscillate about
the zero position.
Increase Ki so that the response of the robot is faster when it is out of balance. Ki should
be large enough so that the angle of inclination does not increase. The robot should come
back to zero position if it is inclined.
Increase Kd so as to reduce the oscillations. The overshoots should also be reduced by
now.
Repeat the above steps by fine tuning each parameter to achieve the best result.
Thanks for your precious time and attention