top of page
Connecting Dots

Self-Balancing Robot

To develop the self-balancing wheel, the user started by designing the chassis using SolidWorks. Then, they imported the model to Simulink environment and began to define the parts of the multibody system. They created custom parts for the wheels, shaft, and chassis using standard solids and unique shapes. After defining the parts, they connected them using rigid transforms and joints to create the complete multibody system.

 

Once the multibody system was defined, the user applied gravity and used PID controllers to balance the system. They followed a tutorial from MathWorks to implement the PID controllers and adjust the gains to achieve stable balancing. The PID controllers were used to regulate the angle of the system and adjust the torque applied to the wheels to maintain balanceThe user also implemented a user interface using MATLAB App Designer to control the robot's movements and adjust the controller gains in real-time. The interface allowed them to visualize the system's behaviors' and fine-tune the controller gains for better performance.

 

Through this process, the user developed a fully functional self-balancing wheel using Simulink and MATLAB. They learned how to define multibody systems, apply physical properties like gravity, and use PID controllers to control the system's behaviour. The user also gained experience using MATLAB App Designer to create a user interface for real-time control and adjustment of the system. https://uk.mathworks.com/matlabcentral/fileexchange/88768-two-wheeled-self-balancing-robot

The system

The self-balancing robot looks like under this figure 06 in Matlab.

The two wheel self-balancing robot is a popular project in robotics that involves designing and building a robot that can balance itself on two wheels. In MATLAB Simulink and Simscape, a two wheel self-balancing robot can be modelled as a mechanical system that includes several components such as a chassis, two wheels, motors, sensors, and controllers.

The basic idea behind the self-balancing robot is to use a feedback control system to adjust the speed and direction of the wheels in response to the angle of the robot. When the robot tilts forward or backward, the control system detects the angle and adjusts the speed of the wheels to bring the robot back to an upright position.

 

The Simscape model of the self-balancing robot typically includes the following components:

  1. Chassis: The body of the robot that houses the components and provides structural support.

  2. Wheels: The two wheels that allow the robot to move and balance.

  3. Motors: The motors that drive the wheels and provide the necessary torque to keep the robot balanced.

  4. Sensors: Sensors such as accelerometers and gyroscopes are used to measure the orientation and motion of the robot.

  5. Control system: The control system uses the sensor feedback to adjust the speed and direction of the wheels and keep the robot balanced.

 

By modelling the self-balancing robot in Simscape, we can simulate its motion and analyse its behaviour under different conditions. We can also use the model to design and test different control systems to improve the performance of the robot.

The Simscape model of the self-balancing robot typically includes a number of subsystems that represent the different components of the system. For example, the motor subsystem may include a DC motor, a motor driver, and a current sensor, while the sensor subsystem may include an accelerometer, a gyroscope, and a Kalman filter for sensor fusion.

To simulate the motion of the self-balancing robot, we would typically set up a simulation in Simulink that includes the Simscape model and the necessary inputs and outputs. We can then run the simulation and observe the behaviour of the robot, including its motion and its angle as a function of time. We can also analyse the performance of the control system and make adjustments to improve its stability and accuracy.

 

Overall, the Simscape model of the two wheel self-balancing robot provides a useful tool for understanding and analysing the behaviour of this complex mechanical system, and for designing and testing different control systems to improve its performance.

Picture9.png

Figure 06: Two-wheel self-balancing robot

The main simscape code is given in the below figure.

Picture1.png

Figure 07: The main system for self-balancing robot

The system consist of the simple rigid blocks as the mechanism is so simple as shown in figure 06, and all the blocks are assembled and stick in together via revolute joints, prismatic joints and mainly the rigid transform, which limit how each object is positioned in relation to or in reference to other objects or points.

 

The two sub-systems consist of the chassis part and the cart part (Inside cart Left wheel and Right wheel)

Cart Subsystem

The left and right wheel is in a separate subsystem as shown in figure 08 to make the assembly so simple. A collection of blocks you combine into a single Subsystem block is referred to as a subsystem. Using subsystems: Creates a hierarchical block layout with a subsystem block on the bottom layer and the subsystem's constituent blocks on the top layer. The two wheels are connected to a Rigid transform separately and both are connected shaft shown in figure 08.

Picture2.png

Figure 08: Main cart subsystem

Picture3.png

Figure 09: Left wheel subsystem

The chassis subsystem consist of plates and rods of the robot. Each solid plate is connected with a rigid transform and all the plates are connected with the pillars to make the connection between the plates of the robot and the rods as all the plates are symmetrically connected with the rods.

 

There is a main component called ‘External Force and Torque’ which is given below;

Picture5.png

The frame connected to the block's F port receives the exterior force and/or torque applied by the exterior Force and Torque block. The forces and torques in a frame operate at its origin and around its corresponding axes, respectively. Physical signals that define the forces and torques are accepted by the block. Throughout a simulation, the signal can have a fixed number or change over time.

 

The resolution frame can be specified in order to fix the force and torque inputs. A force input with a positive value works in the frame axis's positive direction. According to the right-hand rule, a torque input with a positive number moves the associated frame axis.

Figure 10: Main chassis subsystem

Picture4.png

The pillar subsystem is given inthe below figure 11. All the cylindrical rods have been connected with the rigid transform to model compound rigid bodies.

Picture2.png

Figure 11: Main pillar subsystem: Rods

The PID controller plays a crucial role in the functionality of the self-balancing wheel robot. It is responsible for constantly measuring the tilt angle of the robot and generating control signals to the actuators (motors) to maintain balance. The gains of the PID controller need to be tuned carefully to ensure stable and accurate control of the system.

 

After many struggles the correct PID values were found to control the balance of a self-balancing robot.

Picture2.png
Picture3.png

Figure 13: The fully stabilize scope of the robot

Figure 12: PID Values

Overall Robot

Picture4.png

Figure 14: Toggle visibility of frames of the robot.

The three shelves self-balancing robot is a robot that uses two wheels and a chassis consisting of three shelves and rods to balance itself. The robot is designed and simulated in MATLAB Simulink using the Simscape Multibody toolbox. The simulation involves the use of rigid bodies and joints to assemble the robot and apply various physical properties such as damping and stiffness to achieve the desired motion.

 

The PID controller is used to control the motion of the robot and maintain its balance. The controller receives input from sensors that measure the tilt angle of the robot and adjust the speed of the motors to keep the robot balanced. The use of PID controllers in the simulation allows for efficient and accurate control of the robot.

 

The simulation of the self-balancing robot provides a practical example of how Simscape Multibody can be used to design and simulate complex mechanical systems. It also highlights the importance of control systems in the design of robots and other mechanical systems.

Conclusion

The tutorial provided a valuable opportunity for the user to gain a better understanding of how to assemble a robot using rigid bodies and joints within the simscape environment. The user gained knowledge on various aspects including damping stiffness, robot orientation, and PID control. The end result was a fully functional self-balancing robot.

bottom of page