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
  • Constructor Details

    • 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 motor
      resolution - resolution set by external configuration
      speed - speed of rotation in RPM
      Throws:
      RuntimeIOException - if initialisation error
  • Method Details

    • close

      public void close()
      Closes the device.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface DeviceInterface
    • 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 -
      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