Self – Balancing robot is ‘inverted pendulum’ type of robot with two wheels, where control system uses Feedback from Gyroscope and accelerometer to keep the robot in ‘balanced’ position. Control system of the robot has been based on Codesys runtime, (IEC 61131-3 automation software) installed on Raspberry Pi.
- Power supply
- Main power source is 4x Li-ion 18650 batteries. This type of cells has been used as Li-ion batteries are considered safer and ‘impact resistant’ than Li-po batteries.
- 1x Step down Voltage Regulator (LM2596) has been used to provide 5V supply for Raspberry Pi and Control Board.
- 2x Step Up Voltage regulators (XL6009) to provide stable voltage to motors. This will avoid change of motor characteristics during the battery discharge process.
- Charge level monitoring system.
- Voltage divider has been used to measure Voltage of one Cell. Voltage level is measured in control board and passed to Raspberry Pi, where is presented to User in HMI screen.
- RGB LED as additional voltage indicator is placed on the main board.
- When battery charge will drop below certain level Robot will not start.
To ease of use balance-charging circuit has been developed. To charge batteries it is not necessary to take of the batteries from the Robot. Balance charger can be connected straight into the Power-Board.
Robot needs to be switched off before charging process will start!
Power supply circuit has been equipped with 5A fast acting glass fuse. It is recommended to keep the current rating of the fuse of 5A to protect electrical circuit from overload in case of stalled motors
- Motors control
- To provide necessary speed, two Pololu 19:1 Metal Gearmotors 37Dx52L mm has been used.
- Rated speed at 12V: 500rpm
- Torque: 5 kg-cm
- Stall current: 5A
- Motor Drivers: 2x BTS7960 43A H Bridge.
- PWM signal to the drivers is provided by the Teensy 3.2
- Motors are integrated with quadrature encoder with 64 counts per revolution (CPR) of the motor shaft. The total counts are: 64×19 = 1216 counts per wheel revolution.
- Main Control Board
- Separate PCB has been made to integrate all necessary control elements into one place.
- I2C Bus is the only communication protocol used between Raspberry PI and Control Board.
- Teensy 3.2 Microcontroller
- Decodes quadrature encoder signals and converts them to speed in RPM for each wheel.
- Provides PWM signals for motor drivers.
- Converts battery voltage in A/D converter
- Enable/Disable Balancing control of the robot (one digital input has been used)
- Arduino Nano Microcontroller
- ‘Bridge’ between Codesys in Raspberry Pi and Radio nRF24L01
- Provides Joystick values as movement requests.
- Raspberry Pi 3 and Codesys
- Codesys project on the raspberry Pi combines data from all devices and provides PWM reference value for each wheel.
- Main Angle feedback device (MPU6050) communicates with Raspberry Pi through I2C Bus
- Providing HMI screen through Codesys built in Web-server. To use this feature, raspberry Pi needs to be connected to the same LAN than device that is accessing web server.
- Additional info
- Raspberry Pi Camera V2 used to provide on-board View.
- Joystick based on Arduino Nano and nRF24L01 Transceiver
- 2 led diodes that indicate that robot is in ‘Balanced position’
3. Control system overview.
Diagram below shows data flow in cascaded Pi and PID Controllers.
As a reference value for balance PID controller is angle value generated by Speed PI controller. For angle feedback, Gyro and accelerometer values are combined into the Complementary filter and passed to PID balance controller. Balance PID controller provides PWM signals for motor drivers.