Skip to main content

Module actuators

Module actuators 

Source
Expand description

The C ABI for the actuator drivers.

These functions wrap [pamoja_actuators] for callers that reach the SDK through the flat C boundary: the command-encode half of a PCA9685 PWM controller and of a stepper motor, turning a desired output into the bytes and coil patterns a driver applies.

A PWM setting is four register bytes, so it crosses by value as a #[repr(C)] struct the caller writes straight to the channel’s registers. A stepper sequencer and position both carry state across calls, so they cross as handles.

Structs§

PamojaPwm
A PCA9685 channel’s four register bytes.
PamojaStepper
An opaque handle to a position in a stepper drive sequence.

Enums§

PamojaStepDirection
Which way to step a motor.
PamojaStepDrive
A stepper drive pattern, trading torque, smoothness, and resolution.

Constants§

PAMOJA_PCA9685_CHANNELS
How many PWM channels a PCA9685 drives.
PAMOJA_PCA9685_COUNTS
How many counts a PCA9685 period is divided into.
PAMOJA_PCA9685_DEFAULT_ADDRESS
The address a PCA9685 answers at with its six address pins low.
PAMOJA_PCA9685_INTERNAL_OSC_HZ
The PCA9685’s internal oscillator frequency, in hertz.
PAMOJA_PCA9685_MODE1_AUTO_INCREMENT
MODE1’s auto-increment bit: the register pointer moves on after each byte.
PAMOJA_PCA9685_MODE1_EXTCLK
MODE1’s EXTCLK bit: the prescaler divides the EXTCLK pin rather than the oscillator.
PAMOJA_PCA9685_MODE1_RESET
The power-on value of MODE1: asleep, answering the All Call address.
PAMOJA_PCA9685_MODE1_RESTART
MODE1’s RESTART bit: set when the part slept with a channel running, cleared by a written 1.
PAMOJA_PCA9685_MODE1_SLEEP
MODE1’s SLEEP bit: the oscillator is off and PRE_SCALE takes a write.
PAMOJA_PCA9685_MODE2_RESET
The power-on value of MODE2: totem-pole outputs.
PAMOJA_PCA9685_OSCILLATOR_STARTUP_MICROS
How long the oscillator takes to run once woken, in microseconds.
PAMOJA_PCA9685_PRE_SCALE_MIN
The smallest value the part loads into PRE_SCALE, about 1526 Hz.
PAMOJA_PCA9685_PRE_SCALE_RESET
The power-on value of PRE_SCALE: 200 Hz on the internal oscillator.
PAMOJA_PCA9685_REGISTER_ALL_LED_ON_L
The first of the four ALL_LED registers, which load every channel at once.
PAMOJA_PCA9685_REGISTER_LED0_ON_L
The first of channel 0’s four registers; channel n starts four registers on per channel.
PAMOJA_PCA9685_REGISTER_MODE1
Mode register 1: restart, clock, auto-increment, sleep, and the addresses answered.
PAMOJA_PCA9685_REGISTER_MODE2
Mode register 2: how the outputs are wired and when they change.
PAMOJA_PCA9685_REGISTER_PRE_SCALE
The prescaler that sets the PWM frequency, writable only while the part sleeps.
PAMOJA_STEPPER_DEFAULT_PULSE_MICROS
How long a step and direction driver holds the direction before a step pulse, and the pulse itself, unless given another, in microseconds.
PAMOJA_STEPPER_DEFAULT_STEP_MICROS
The pause a stepper driver takes after each step unless given another, in microseconds: two milliseconds, a rate common geared hobby motors follow without stalling.

Functions§

pamoja_pca9685_channel_register⚠
Returns the first of a PCA9685 channel’s four consecutive registers.
pamoja_pca9685_frequency_for_prescale
Returns the update rate a PCA9685 prescale value produces.
pamoja_pca9685_prescale_for_frequency
Returns the prescale value that sets a PCA9685 update rate.
pamoja_pwm_counts⚠
Reads a PCA9685 setting back from the four register bytes a channel holds.
pamoja_pwm_duty
Builds a PWM setting with no phase delay: on at count 0, off at off.
pamoja_pwm_from_counts
Builds a PWM setting from explicit on and off counts.
pamoja_pwm_full_off
The setting that holds a channel continuously low, the power-on state.
pamoja_pwm_full_on
The setting that holds a channel continuously high.
pamoja_pwm_servo
Builds the setting that drives a hobby servo to a given pulse width.
pamoja_stepper_coils⚠
Returns the coil pattern a stepper currently holds, without advancing it.
pamoja_stepper_free⚠
Releases a stepper handle.
pamoja_stepper_new
Creates a stepper at the start of a drive pattern, with its position at zero.
pamoja_stepper_step⚠
Advances a stepper one step and returns the coil pattern to apply.
pamoja_stepper_step_count
Returns how many steps make up one electrical cycle of a drive pattern.
pamoja_stepper_steps⚠
Returns how many steps a stepper has taken, signed by direction.
pamoja_stepper_steps_for_degrees
Returns how many steps a rotation of degrees takes on a given motor.