SlushEngine: Moving a stepper motor at diffrent speeds
The SlushEngine has a very handy integrated motion engine. This allows all the motion control to be managed in a real-time manner without requiring the resources of the Raspberry Pi. The motion engine can be used to spin the motor at a certain speed in a certain direction. This can be handy if you are driving wheels, a pump, a fan, etc...
In the above code there are three different different operations happening
- The motor is initialized, in this case we are using motor 0. Any and all motors can be used in this example
- The motor spins in one direction for a few seconds and then spins in another direction. This happens while the motion engine tracks the speed.
- The motor returns to the zero position (the position the rotor was at when the program started)
During these operations the motion engine is working in the background to keep track of the motors position. This feature can be very handy because it helps to handle stopping conditions. If the motor is stopped at any point (i.e. the user hits a pause/stop button). The SlushEngine can be stopped and the position remembered.
In a way the motion engine position tracking features acts like an encoder. The only time it can loose its position is if power is removed from the stepper or excessive force is applied to the motor.