pyupm_stepmotor module¶
-
class
pyupm_stepmotor.
StepMotor
(dirPin, stePin, steps=200, enPin=-1)[source]¶ Bases:
object
API for the Stepper Motor.
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.
EasyDriver Sensor image provided by SparkFun* underCC BY-NC-SA-3.0.
C++ includes: stepmotor.hpp
-
enable
(flag)[source]¶ void enable(bool 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.
flag: true to enable or false to disable
-
getPosition
()[source]¶ int getPosition()
Gets the current position. This is cumulative and the result of all the step commands sent to the motor.
Stepper’s position.
-
getStep
()[source]¶ int getStep()
Gets the current step. This is relative to one revolution.
Current step, ranges from 0 to number of steps per revolution.
-
setPosition
(pos)[source]¶ void setPosition(int pos)
Sets the current position. Useful if the motor is not at 0 when the driver is initialized.
pos: Current position
-
setSpeed
(speed)[source]¶ void setSpeed(int speed)
Sets the rotation speed in rpm. Default 60 rpm.
speed: Rotation speed in rpm
-
step
(ticks)[source]¶ mraa::Result step(int ticks)
Rotates the motor by the specified number of steps. Positive values rotate clockwise and negative values rotate counter-clockwise.
ticks: Number of steps the motor moves
-