Kart/stepper motor controller
|Line 37:||Line 37:|
| brown, black
| brown, black
Revision as of 13:21, 28 June 2022
The kart's stepper motor controller module generates 4 coil driving signals and receives a stepper end input.
The stepper motor is a Nanotec SP3575M0906-A.
It has a step angle of 7.5°, and as such 48 steps per turn. It is attached to a 100:1 reductor, which leads to an output axis with 4800 steps per turn.
The DC/stepper control board hosts a current source which is directed to one (or more) of the stepper motor's coils.
The end switch is connected between one of the FPGAs I/O with an internal pull-up enabled and the GND. The logic is internally reverted (i.e. a '1' is read when the switch is closed).
The cables are connected as follows:
Signal Color phase 1 white phase 2 blue phase 3 red phase 4 yellow +5V / 2A brown, black
To begin with, the design environment has to be downloaded.
It comprises the
stepperMotorController block which contains the registers and events manager and an empty
angleControl block which is to be completed.
The block receives a
targetAngle unsigned number and has to step the coils at each occurrence of the
stepEn signal until the desired angle is reached.
The coils are controlled through the 4 outputs
coil4. When a '1' is applied, the corresponding coil is magnetized.
To control the stepper, one coil at a time should be magnetized, known as wave drive.
The switching frequency should also be chosen carefully. A frequency of 285 Hz is near the slip limit of the motor. The frequency is given by the formula : f = 100k / prescaler. A prescaler (clockDivider) of 400 (i.e. a frequency of 250 Hz) is a great first approach.
The steering angle,
actual, is estimated with the help of a counter which increments or decrements each time the coils change.
It is joined with a logic signal,
reached, telling if the desired angle has been reached.
This information is sent back to the controlling smartphone.
A switch contact, providing the signal
stepperEnd, has to be mechanically fitted on the kart in order set one end of the wheels' direction movement.
As soon as
stepperEnd is '1', the stepper motor is stopped and the
actual angle is reset.
With this, the steering motor will not try to turn further than what the kart's mechanical structure allows it to do in one of the directions.
In the other direction, it is the programmer's task not to request a too large
This also means that the angles are always considered as positive numbers, the zero position being given by the
- In order to limit the current consumption, turn off the current in all the coils when the stepper motor is not turning any more.
- Make sure that both the first and the last pulse of the coil control signals have the same duration as all the others.
The mechanical design allows for the following variations:
stepperEndswitch can be placed such as to detect the maximal steering angle either on the left or on the right side
- switching the coil controls in the sequence
1 - 2 - 3 - 4 - 1 - 2 - …can result in the kart to turn either to the left or to the right
In order to cope with all possibilities, 2 setup signals are provided to the block:
sensorLeftbeing '1' means that the
stepperEndswitch has been placed such as to react when the wheels are oriented to the maximal steering angle on the left side
clockwisebeing '1' means that the sequence
1 - 2 - 3 - 4 - 1 - 2 - …lets the steering turn to the right
The corresponding setup bits are configured in the hardware control register.
The hardware control register also contains the bit
restart allowing to let the stepper motor turn all the way to the angle where the
stepperEnd switch is pressed.
This has to be sent by the remote control smartphone after a successful Bluetooth pairing, together with the appropriate
clockwise setup bits, in order for the FPGA hardware to discover the zero angle position.
Obviously, this should only be done after the Stepper motor period register has been set to a proper value.
Restarting to the zero position can also be a help if too much current has been drawn from the batteries and the FPGAs' power has sunk in a way that they have performed a reset.