Class StepDir<TLine>
A stepper behind a step and direction driver chip such as an A4988 or a DRV8825, as
pamoja_actuators::stepper::StepDir drives one in Rust.
public sealed class StepDir<TLine> where TLine : IOutputLine
Type Parameters
TLineThe step and direction lines.
- Inheritance
-
StepDir<TLine>
- Inherited Members
Examples
var motor = new StepDir<PinScript>(new PinScript(), new PinScript(), delay: new DelayLog());
motor.Steps(-1);
// motor.Position is -1
Remarks
Each step sets the direction line, high for forward, and holds it for the pulse width, since the chip reads the direction on the step line's rising edge and needs it settled first. Then it pulses the step line high for the pulse width, brings it low, and waits the step interval. Microstepping, current limiting, and enable are the chip's own pins and settings, outside this driver.
Constructors
StepDir(TLine, TLine, uint, uint, IDelay?)
Wraps the step and direction lines, without driving them.
public StepDir(TLine step, TLine direction, uint pulseMicros = 10, uint stepMicros = 2000, IDelay? delay = null)
Parameters
stepTLineThe line the chip counts rising edges on.
directionTLineThe line the chip reads the direction from; high is forward.
pulseMicrosuintHow long the direction line is held before the step line rises, and the step line is then held high.
stepMicrosuintThe pause after each step, which sets the speed.
delayIDelayWhat waits: a SleepDelay unless given, or a DelayLog to run with nothing plugged in.
Properties
Position
The step count since the driver was built, forward positive.
public int Position { get; }
Property Value
PulseMicros
How long the direction is held before each step pulse, and the pulse itself, in microseconds.
public uint PulseMicros { get; }
Property Value
StepMicros
The pause after each step, in microseconds.
public uint StepMicros { get; }
Property Value
Methods
Release()
Hands the lines back.
public (TLine Step, TLine Direction) Release()
Returns
Step(StepDirection)
Takes one step and waits the step interval.
public void Step(StepDirection direction)
Parameters
directionStepDirectionWhich way to step.
Exceptions
- Exception
Whatever a line throws when it cannot be driven.
Steps(int)
Takes count steps, backward when negative.
public void Steps(int count)
Parameters
countintThe signed number of steps.
Exceptions
- Exception
Whatever a line throws; the steps already taken stay counted.