This project is maintained by S-Nithish-Kumar
Figure 1 Rear view
Figure 2 State vector derivative
ẋ(t) - Derivative of state vector
θ - Lean angle of the pendulum (rads)
θ . - Angular velocity (rad/s)
θ .. - Angular acceleration (rad/s2)
ω - Rotational speed of the inertia wheel (rad/s)
ω . - Rotational acceleration of the inertia wheel (rad/s2)
mr - Mass of pendulum rod (kg)
mw - Mass of inertia wheel (kg)
lAB - Distance from ground to the center of mass of the pendulum rod (m)
lAC - Distance from ground to the center of mass of the inertia wheel (m)
lAD - Length of the pendulum rod (m)
𝜏m - Motor torque (Nm)
Step 1: Using the state vector derivative, the inverted pendulum model is developed with Simulink, as shown below in Figure . Initially, when no motor torque is applied, the pendulum oscillates freely, as seen in Figure . When motor torque is applied, which is provided as feedback of the pendulum angle, the pendulum oscillates in the upright position, as depicted in Figures x and y, respectively.
Figure 3 Kinematics of Inverted Pendulum in Simulink
Figure 4 Closed loop motor torque control with lean angle feedback
Figure 5 Pendulum output when motor torque is provided a feedback
Step 2: A PID controller is added to further increase the stability of the inverted pendulum and maintain a zero degree lean angle. The simulink model with PID controller and the output of the model is shown in figures and, respectively.
Figure 6 Torque control with PID controller
Figure 7 Pendulum output with PID controller
Step 3: The motorcycle is assembled, and each of the above-mentioned sensors is tested by developing models with Simulink for each sensor, and the models are run in External mode.
Step 4: First, the IMU is tested by running the model in External mode. Simulink has a prebuilt function block for the BNO055 IMU sensor that shows the angular rate, euler angles, and calibration status of the sensor, as seen in Figure . The sensor has to be calibrated every time the controller is powered on.
Figure 8 IMU sensor block
Step 5: The inertia wheel motor rotation is calculated using the Encoder block. A filtered derivative is used to obtain rotations per second and also to filter the signal. The image below shows the Simulink model.
Figure 9 Simulink model to convert encoder values to rad/s
Step 6: The DC motors can be controlled with the DC Motors block, as shown below. A constant value between 0 and 1 is passed as input. A gain block with a value of 255 is added before sending the input to the DC Motors block.
Figure 10 M3 M4 DC Motors block
Step 7: The battery voltage can be measured with the Battery Read block, as shown below.
Figure 11 Simulink model for reading battery voltage
Step 8: To control the servo motor for steering, the Servo Write block is used as shown in Figure
Figure 12 Servo write block
Step 9: Once all the sensors and actuators are tested, all the models are combined into a subsystem.
Figure 13 Sensor signals combined to a bus creator block
Step 10: The sensor data from the subsystem is fed into the PID controller, which gives a signal to rotate the inertia wheel motor for balancing the motorcycle.
Figure 14 Digital controller
Step 11: The PID controller is tuned to balance the motorcycle even when it moves.
Step 12: The Digital Controller block has safety logic that checks the IMU calibration status, battery level, and standing or falling state of the motorcycle. If any of the above conditions fail, then the controller turns off.
Figure 15 Controller safety logic
Step 13: The rear motor speed is increased slowly using a slider to move the motorcycle.
Step 14: Then the steering angle of the motorcycle is slightly changed, and the rear motor speed is slowly increased to make the motorcycle move in a circular path.