Table of Contents

Class Pwm

Namespace
Pamoja.Actuators
Assembly
Pamoja.Actuators.dll

The four register bytes for one PCA9685 channel.

public static class Pwm
Inheritance
Pwm
Inherited Members

Remarks

Each call returns them in the channel's own register order, so they can be written in a single bus transaction.

Methods

Counts(ReadOnlySpan<byte>)

Reads a setting back from the four register bytes a channel holds.

public static (ushort On, ushort Off) Counts(ReadOnlySpan<byte> bytes)

Parameters

bytes ReadOnlySpan<byte>

The four channel registers.

Returns

(ushort On, ushort Off)

The counts at which the output goes high and low.

Remarks

The inverse of the builders above, so a caller can read a channel off the bus and see what it is set to rather than decoding the registers by hand.

Exceptions

PamojaException

The registers are not four bytes.

Duty(ushort)

Builds a setting with no phase delay: on at count 0, off at off.

public static byte[] Duty(ushort off)

Parameters

off ushort

The count at which the output goes low, which sets the duty.

Returns

byte[]

The four register bytes.

FromCounts(ushort, ushort)

Builds a setting from explicit on and off counts.

public static byte[] FromCounts(ushort on, ushort off)

Parameters

on ushort

The count at which the output goes high.

off ushort

The count at which it goes low.

Returns

byte[]

The four register bytes; counts are masked to 12 bits.

FullOff()

The setting that holds a channel continuously low, the power-on state.

public static byte[] FullOff()

Returns

byte[]

The four register bytes. This is not the same as a zero duty, which still glitches high for one count.

FullOn()

The setting that holds a channel continuously high.

public static byte[] FullOn()

Returns

byte[]

The four register bytes.

Servo(uint, uint)

Builds the setting that drives a hobby servo to a pulse width.

public static byte[] Servo(uint pulseMicros, uint updateRateHz = 50)

Parameters

pulseMicros uint

The high-pulse width in microseconds. Typical travel is about 1000 to 2000.

updateRateHz uint

The PWM frequency the controller is set to.

Returns

byte[]

The four register bytes.