Table of Contents

Class FourWire<TLine>

Namespace
Pamoja.Actuators
Assembly
Pamoja.Actuators.dll

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

TLine

The 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.

drive StepDrive

The coil pattern to step through.

stepMicros uint

The pause after each step, which sets the speed.

delay IDelay

What 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

StepDrive

Position

The step count since the driver was built, forward positive.

public int Position { get; }

Property Value

int

StepMicros

The pause after each step, in microseconds.

public uint StepMicros { get; }

Property Value

uint

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

(TLine A, TLine B, TLine C, TLine D)

The lines for coils A, B, C, and D.

Step(StepDirection)

Takes one step and waits the step interval.

public void Step(StepDirection direction)

Parameters

direction StepDirection

Which 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

count int

The signed number of steps.

Exceptions

Exception

Whatever a coil line throws; the steps already taken stay counted.