Class FourWire<TLine>
A four-wire stepper driven coil by coil, through a transistor array such as a ULN2003 or an
H-bridge, as pamoja_actuators::stepper::FourWire drives one in Rust.
public sealed class FourWire<TLine> : IDisposable where TLine : IOutputLine
Type Parameters
TLineThe coil lines.
- Inheritance
-
FourWire<TLine>
- Implements
- Inherited Members
Examples
var coils = (new PinScript(), new PinScript(), new PinScript(), new PinScript());
using var motor = new FourWire<PinScript>(coils, StepDrive.FullStep, delay: new DelayLog());
motor.Steps(2);
// motor.Position is 2
Remarks
Each step energizes the coils the drive pattern names, coil A for the pattern's high bit down to coil D for its low bit, then waits the step interval. The position counts steps from where the motor was when the driver was built, forward positive. A coil line is any IOutputLine: a GpioLine on a board, or a PinScript that records every level.
Constructors
FourWire((TLine A, TLine B, TLine C, TLine D), StepDrive, uint, IDelay?)
Wraps the four coil lines, without driving them.
public FourWire((TLine A, TLine B, TLine C, TLine D) coils, StepDrive drive, uint stepMicros = 2000, IDelay? delay = null)
Parameters
coils(TLine A, TLine B, TLine C, TLine D)The lines for coils A, B, C, and D, in the motor's phase order.
driveStepDriveThe coil pattern to step through.
stepMicrosuintThe pause after each step, which sets the speed.
delayIDelayWhat waits: a SleepDelay unless given, or a DelayLog to run with nothing plugged in.
Exceptions
- PamojaException
The native sequencer could not be created.
Properties
Drive
The coil pattern in use.
public StepDrive Drive { get; }
Property Value
Position
The step count since the driver was built, forward positive.
public int Position { get; }
Property Value
StepMicros
The pause after each step, in microseconds.
public uint StepMicros { get; }
Property Value
Methods
Dispose()
Releases the native sequencer. The coil lines stay the caller's.
public void Dispose()
Idle()
Drops every coil, so the motor holds nothing and draws nothing.
public void Idle()
Exceptions
- Exception
Whatever a coil line throws when it cannot be driven.
Release()
Hands the coil lines back, for a test to read what was driven or a program to reuse them.
public (TLine A, TLine B, TLine C, TLine D) 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 coil 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 coil line throws; the steps already taken stay counted.