API Reference

adafruit_stspin

CircuitPython driver for the Adafruit STSPIN220 Stepper Motor Driver Breakout Board

  • Author(s): Liz Clark

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_stspin.Modes

Valid microstepping modes for STSPIN220.

Each mode value encodes the state of MODE1-MODE4 pins: - Bits 0-1: MODE1, MODE2 (physical pins if connected) - Bits 2-3: MODE3, MODE4 (multiplexed with STEP/DIR during reset)

classmethod is_valid(mode: int) bool

Check if a mode value is valid.

Parameters:

mode (int) – Mode value to check

Returns:

True if valid mode

Return type:

bool

classmethod microsteps(mode: int) int

Get number of microsteps for a given mode.

Parameters:

mode (int) – Step mode constant

Returns:

Number of microsteps per full step

Return type:

int

class adafruit_stspin.STSPIN(step_pin, dir_pin, steps_per_revolution: int = 200, mode1_pin=None, mode2_pin=None, en_fault_pin=None, stby_reset_pin=None)

Driver for the STSPIN220 Low Voltage Stepper Motor Driver.

Parameters:
  • step_pin (Pin) – The pin connected to STEP (step clock) input

  • dir_pin (Pin) – The pin connected to DIR (direction) input

  • steps_per_revolution (int) – Number of steps per full motor revolution

  • mode1_pin (Pin) – The pin connected to MODE1 input (optional)

  • mode2_pin (Pin) – The pin connected to MODE2 input (optional)

  • en_fault_pin (Pin) – The pin connected to EN/FAULT pin (optional)

  • stby_reset_pin (Pin) – The pin connected to STBY/RESET pin (optional)

clear_fault() None

Clear fault condition by toggling enable pin.

property enabled: bool

Motor power stage enable state.

Returns:

True if enabled, False if disabled

Return type:

bool

property fault: bool

Check if a fault condition exists.

Returns:

True if fault detected, False if normal operation

Return type:

bool

property microsteps_per_step: int

Number of microsteps per full step for current mode.

Returns:

Microsteps per full step (1, 2, 4, 8, 16, 32, 64, 128, or 256)

Return type:

int

property position: int

Current motor position in steps (0 to steps_per_revolution-1).

Returns:

Current position in steps

Return type:

int

reset() None

Reset the device by toggling the STBY/RESET pin.

property speed: float

Motor speed in revolutions per minute (RPM).

Returns:

Current speed in RPM

Return type:

float

property standby: bool

Device standby state.

Returns:

True if in standby mode, False if active

Return type:

bool

step(steps: int) None

Move the motor a specified number of steps.

Parameters:

steps (int) – Number of steps to move (positive = forward, negative = reverse)

step_blocking(steps: int, delay_seconds: float = 0.001) None

Move the motor with blocking delay between steps.

Parameters:
  • steps (int) – Number of steps to move (positive = forward, negative = reverse)

  • delay_seconds (float) – Delay between steps in seconds

property step_mode: int

Current microstepping mode.

Returns:

Current step mode constant from Modes class

Return type:

int