EPuck2 Motor - EPFL-MICRO-315/TPs-Wiki GitHub Wiki
⚠ wiki page used in TP2
Introduction to EPuck2 Motors
- The e-puck2 robot is equipped with two stepper motors
- These motors have two windings
- The power in these windings is controlled by 4 signals (a, b, c and d) for each motors
- Look at the figure 1 showing how these four signals have to be activated to make the motor turn
- Every signal transition is considered as a step
- A rotation of 360° of the wheel corresponds to 1000 steps
- 20 steps per revolution of the motor combined with a gear reduction of 50:1
- To calculate the distance run by the robot, one must consider the robot wheel's perimeter of 13cm.
- More information on stepper motors:
- http://en.wikipedia.org/wiki/Stepper_motor
- http://fr.wikipedia.org/wiki/Moteur_pas_a_pas
- in any motor design course, e.g Prof. Perriard's electromechanical conversion course
Figure 1
Activation sequence for the motor 1 control signals
Implementation in Code
- The control of the motors can be managed for instance by this state machine where the direction (backward and forward) and speed can be handled
Figure 2
State machine with the states of motor control
[!WARNING] Avoid staying too long in a state that powers the coils of the motors or else they will heat very strongly and this can even destroy material.
- So be careful when handling GPIOs managing the drivers of the motors.
- On the state machine figure it misses the state
0000where the 2 coils are not supplied at all. This is the state in which the motor must be when it is stopped so as not to consume and especially not to heat.
[!IMPORTANT]
- It is really IMPORTANT to test your motor management code by simulating the states of the state machine with the 4 Red LEDs (
1-Front,3-Right,5-Backand7-Left).- Start by changing the states at very low frequency (≤1Hz) so you can visually see and validate the main part of your code without powering the motor then without risk.
- When your code seems ok, before to replace the LED's GPIOs with those interacting with motor driver:
[!WARNING] Don't forget that driver motor GPIOs have a different configuration (external pull-down and positiv logic) and work exactly like
FRONT_LEDorBODY_LED
[!IMPORTANT]
- Then test your state machine by replacing 2 of the 4 previous Red LEDs with these 2 new LEDs. You will know better how to configure the GPIOs of the motors
- Again if your code seems ok, replace all the LED's GPIOs with those interacting with motor driver
- Finally do the same with the second motor.
💡 Tips and Tricks
- The 4-bit value in the state machine figure indicates the values you have to put in the 4 binary signals that control the windings of the stepper motor
- To make the motors turn, these signals have to change in a cyclical way according to the FSM (Finite state machine)
- Two timers, one for each motor (timers 6 and timer 7 are recommended) must be used:
- each timer interrupt makes the motor performing one step
- the interval of timer interrupt must be set accordingly to the desired speed of each wheel
- There must be a step counter allowing the robot to move for a given number of steps
- Do not consider trapezoidal speed profiles but just rectangular (on-off) speed profiless