Package com.diozero.devices.sandpit
Class SilentStepStick
- java.lang.Object
-
- com.diozero.devices.sandpit.SilentStepStick
-
- All Implemented Interfaces:
DeviceInterface
,AutoCloseable
public class SilentStepStick extends Object implements DeviceInterface
Stepper represents a stepper motor driven by a stepper motor controller. Originally developed for a Wetterott SilentStepStick, it should be compatible with the Wetterott StepStick and the Pololu A4988 drivers. It might be compatible with other drivers that use the following control signals: enable (low), direction, and step.The implementation supports up to 16 micro-steps/step. Configuration of micro-stepping must be done external to the implementation.
The implementation assumes a stepper motor with 200 steps/rotation.
The enable pin turns the motor driver on and off. When disabled, the driver does not power the motor and the shaft can be moved manually. When enabled, the powers the motor and and it cannot be moved manually.
- Author:
- Greg Flurry
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SilentStepStick.Direction
static class
SilentStepStick.Resolution
-
Constructor Summary
Constructors Constructor Description SilentStepStick(int enablePin, int directionPin, int stepPin, SilentStepStick.Resolution resolution, float speed)
Constructs a new stepper motor instance.The direction defaults to clockwise.The speed defaults to 1 RPM.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the device.SilentStepStick.Direction
getDirection()
boolean
isEnabled()
void
setDirection(SilentStepStick.Direction direction)
Sets the direction of rotation, either clockwise or counterclockwise.void
setEnabled(boolean enabled)
Enables or disables the stepper driver.void
setOn(boolean on)
Turns on/off the stepper motor.
-
-
-
Constructor Detail
-
SilentStepStick
public SilentStepStick(int enablePin, int directionPin, int stepPin, SilentStepStick.Resolution resolution, float speed) throws RuntimeIOException
Constructs a new stepper motor instance.The direction defaults to clockwise.The speed defaults to 1 RPM.- Parameters:
enablePin
- GPIO pin used to enable the driver.directionPin
- GPIO pin used to set direction of rotation (looking shaft)stepPin
- GPIO pin used to step the motorresolution
- resolution set by external configurationspeed
- speed of rotation in RPM- Throws:
RuntimeIOException
- if initialisation error
-
-
Method Detail
-
close
public void close()
Closes the device.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceDeviceInterface
-
isEnabled
public boolean isEnabled()
-
setEnabled
public void setEnabled(boolean enabled) throws RuntimeIOException
Enables or disables the stepper driver.When disabled, the driver does not power the motor, and thus there is no torque applied. It can be turned manually. When enabled, the driver powers the motor, and thus there is torque. It cannot be turned manually.
- Parameters:
enabled
- true to enable, false to disable- Throws:
RuntimeIOException
- for IO errors
-
getDirection
public SilentStepStick.Direction getDirection()
-
setDirection
public void setDirection(SilentStepStick.Direction direction) throws RuntimeIOException
Sets the direction of rotation, either clockwise or counterclockwise.- Parameters:
direction
- the new direction- Throws:
RuntimeIOException
- for IO errors
-
setOn
public void setOn(boolean on) throws RuntimeIOException
Turns on/off the stepper motor. Technically it turns on/off the step signal to the driver.- Parameters:
on
- true to turn on, false to turn off- Throws:
RuntimeIOException
- if an I/O error occurs when changing the PWM output device value
-
-