StepMotor Class
- ID: stepmotor
- Name: Stepper Motor
- Other Names: EasyDriver Stepper Motor Driver
- Category: motor
- Manufacturer: sparkfun generic
- Link: http://www.schmalzhaus.com/EasyDriver/index.html
- Connection: gpio
This module defines the Stepper Motor interface. It is compatible with stepper motor drivers that use 2 pins to control the motor, like an Easy Driver from Brian Schmalz or the STR driver series from Applied Motion. It can also control an enable pin if one is available and connected.
The implementation is synchronous and thus blocking while the stepper motor is in motion. However it is possible to send the commands via threading and the performance of the library will be very good given a low CPU load. On a busy system though you will notice some jitter especially at higher speeds. It is possible to reduce this effect to some extent by using smoothing and/or microstepping on stepper drivers that support such features.
Item Index
Methods
StepMotor
-
dirPin
-
stePin
-
steps
-
enPin
Instantiates a StepMotor object.
Parameters:
-
dirPin
NumberDirection GPIO pin
-
stePin
NumberStepper pulse GPIO pin
-
steps
NumberNumber of steps per revolution (Default 200)
-
enPin
NumberEnable pin if connected (Optional)
Returns:
enable
-
flag
Can be used to enable/disable the stepper driver if an enable pin is available and connected. Check your data sheet as some drivers might have the enable logic inverted.
Parameters:
-
flag
Booleantrue to enable or false to disable
setSpeed
-
speed
Sets the rotation speed in rpm. Default 60 rpm.
Parameters:
-
speed
NumberRotation speed in rpm
step
-
ticks
Rotates the motor by the specified number of steps. Positive values rotate clockwise and negative values rotate counter-clockwise.
Parameters:
-
ticks
NumberNumber of steps the motor moves
Returns:
stepForward
-
ticks
Rotates the motor forward (clockwise).
Parameters:
-
ticks
NumberNumber of steps the motor moves
Returns:
stepBackward
-
ticks
Rotates the motor backward (counter-clockwise).
Parameters:
-
ticks
NumberNumber of steps the motor moves
Returns:
setPosition
-
pos
Sets the current position. Useful if the motor is not at 0 when the driver is initialized.
Parameters:
-
pos
NumberCurrent position
getPosition
()
Number
Gets the current position. This is cumulative and the result of all the step commands sent to the motor.
Returns:
Stepper's position.
getStep
()
Number
Gets the current step. This is relative to one revolution.
Returns:
Current step, ranges from 0 to number of steps per revolution.