s6.robotic.stepperΒΆ

Stepper axis drivers over RS-485 serial.

Implements a minimal driver for a stepper controller board accessed via a shared serial connection. The Axis class provides convenient motion primitives in distance units; conversion to integer steps is handled via calibration parameters.

Notes

  • Positions are tracked in integer steps. Distances (e.g., millimeters) are converted using distance_per_revolution and step_per_revolution.

  • Commands are serialized to the controller and acknowledgements are awaited. See LinearController.wait_for_ack() for timing behavior.

class s6.robotic.stepper.SerialConnection(port, baudrate, timeout)

Bases: object

Thread-safe singleton for a shared serial port.

Parameters:
  • port (str) – Serial device path (e.g., "COM4" or "/dev/ttyUSB0").

  • baudrate (int) – Port speed in baud.

  • timeout (float) – Read timeout in seconds.

Notes

All instances return the same underlying connection. Use the :pyattr:`connection` property to access the configured serial.Serial object.

property connection

Return the underlying serial.Serial connection.

class s6.robotic.stepper.LinearController(address, distance_per_revolution, step_per_revolution, nominal_speed=32, nominal_acceleration=32, name='')

Bases: object

Base controller implementing low-level step and boundary logic.

Parameters:
  • address (int) – Device address on the bus.

  • distance_per_revolution (float) – Linear travel per motor revolution (e.g., mm/rev).

  • step_per_revolution (int) – Controller steps per revolution.

  • nominal_speed (int, default 32) – Default step speed (device-specific units).

  • nominal_acceleration (int, default 32) – Default acceleration (device-specific units).

  • name (str, default "") – Optional label for logging.

FWD = 128
BWD = 0
distance_to_step(distance)

Convert a linear distance to integer steps.

Parameters:

distance (float) – Travel in the same units as distance_per_revolution.

Returns:

Number of controller steps.

Return type:

int

wait_for_ack(delay_time)

Wait for an acknowledgement frame or timeout.

Parameters:

delay_time (float) – Maximum time (seconds) to wait before returning 0.

Returns:

Non-zero code on success; 0 on timeout.

Return type:

int

set_boundaries(min_boundary, max_boundary)

Set motion boundaries in distance units.

The provided limits are converted to steps and enforced on subsequent motions.

Parameters:
  • min_boundary (float) – Minimum allowable position (distance units).

  • max_boundary (float) – Maximum allowable position (distance units).

step(steps, speed: int = -1, start_acc: int = -1)

Issue a step command with optional speed/acceleration overrides.

Parameters:
  • steps (int) – Signed number of steps. Positive moves forward; negative backward.

  • speed (int, default -1) – Override for speed; when <= 0 uses nominal_speed.

  • start_acc (int, default -1) – Override for acceleration; when <= 0 uses nominal_acceleration.

Notes

Boundaries are enforced; if the motion would exceed limits the step count is clipped so the final position lies on the boundary.

class s6.robotic.stepper.Axis(address, distance_per_revolution, step_per_revolution, nominal_speed=32, nominal_acceleration=32, name='')

Bases: LinearController

High-level axis controller with distance-based helpers.

move(distance, max_speed=-1, acceleration=-1)

Move by a relative linear distance.

Parameters:
  • distance (float) – Travel in distance units (e.g., mm). Converted to steps internally.

  • max_speed (int, default -1) – Optional speed override.

  • acceleration (int, default -1) – Optional acceleration override.

zero(max_speed=-1, acceleration=-1)

Move back to absolute position 0 and reset the tracker.

round_trip(distance, max_speed=-1, acceleration=-1)

Context manager for a symmetric outbound and return motion.

Parameters:
  • distance (float) – Outbound distance before yielding control.

  • max_speed (int, default -1) – Optional speed override.

  • acceleration (int, default -1) – Optional acceleration override.

Yields:

None – Control is returned to the caller between outbound and return legs.

property min_boundary_steps

Minimum allowed position in steps (relative to zero).

property max_boundary_steps

Maximum allowed position in steps (relative to zero).

run_boundary()

Context manager to traverse from min to max boundaries.

goto(position)

Move to an absolute position in steps.

sweep(step_size=1, delay=0.01)

Iterate positions across the boundary range.

Parameters:
  • step_size (float, default 1) – Step size in distance units between samples.

  • delay (float, default 0.01) – Sleep time between moves, in seconds.

Yields:

None – After each move, yields control to the caller.