Self-Balancing Motorcycle

The first developed project consisted on a two-wheeled mockup, similar to a motorcycle, which is able to stabilize itself thanks to flywheel. The main purpose of the project is helping develop some understanding in the fields of kinematics and control algorithms, among others.

The entirety of this project has been done using Simulink.

COMPETENCES

FUNCTIONING

This mock-up is capable of maintaining itself balanced in different situations, being those steady in the place, moving back and forth in a line, and moving back and forth while rotating. The balance is obtained thanks to the black balance wheel, which when spinning, maintains the motorcycle up. Of the three possible projects to do with the motor, only two of them where accomplished, having the rotating one as a future exercise (although the one that allows moving in a straight line could be modified to move in a predefined static angle).

DATA OBTENTION AND CONVERSION

In the static version of the motorcycle, data is retreived from three sources: the encoder of the balancing wheel (number of detected turns), the battery read (raw voltage of the battery) and the IMU sensor (Angular rate, Euler angles and the status of the IMU sensor). In the version which adds the movement, the count of the encoder of the rear wheel is also registered.

After obtaining the data, it needs to be converted so the mock-up can operate with it. Each of the data receives a different treatment, so it is converted in usable data. The battery's raw value is converted into volts, the counts of each of the encoders is converted to speed, and each of the data from the IMU suffers some kind of conversion too.

The converted data will be used afterwards in to different points: the safety chart and the PD controller.

SAFETY CHART

This chart is defined in order to meet just one purpose: certifying the security of both the mock-up and the user. In order to do so, some data must be treated, making sure that the values of that data are between the acceptable limits. The conditions are the following ones:

  • Check if the motorcyle is not sloping to much

  • Check if the IMU has when calibrated in X, Y and Z axes

  • Check if the battery of the motorcycle is above 3 Volts

If any of those conditions is not met, the motorcycle will stop its execution. This supposes that the motors will stop working and the cycle will evnetually fall. In order for the cycle to move, though, it is necessary that a button established in Simulink is enabled, so even if the previous three requierements are met, the motorcycle will not move until the user enables so.

PD CONTROLLER

In order for the cycle to operate exactly as expected, it is utterly necessary to define a PD controller that will ensure that the values previously obtained maintain the cycle up, stable. For doing so, only the Proportional and Derivative controls will be used, as it is not necessary to define an Integrative one, as quiclky reaching the balance point could cause problems with the overshot.

A third control is needed, though, as the balance motor will start to spin faster and faster the more time the cycle stays balanced. This will cause the cycle to fall, and the speed of the balance wheel may cause casualties. In order to avoid this situation, another control is added, which diminishes the value of the PD if too many spins are registered in the same direction.

In the cycle with motion Simulink project, a second PD is added. This PD as different values for the Proportional and Derivative values. The spins done with both the balance wheel and the rear wheel are taken into account in this situation. The value obtained are merged so that the speed is variable, but consistently quick.

FINAL DATA CONVERSION

Once the data passes through the PD controllers, the only need is to ensure that the values obtained do not overflow the maximum or minimum of the motors, in order not to burn them.

For the motion exercise, not only that conversion is done, but a chart is also established so that the cycle moves following a predefined pattern: 3 seconds stopped, 5 seconds backward, another 3 seconds stopped, and 5 seconds forward. This is in order to test the proper working in both directions.

The data converted is then sent to the servo and the motors, so they move according to the data obtained.

Last updated