pub struct ActuonixLinear<CS: CsControl, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos, const N: usize> { /* private fields */ }Expand description
Generic driver for Actuonix linear actuators (P16, T16).
Supports ganging N physical actuators driven in parallel by the same
H-bridge but each with their own potentiometer channel. Channels marked
inverted have their raw reading mirrored (4095 - raw) before fusion,
which undoes swapped wiper wiring on mechanically opposed units. The
per-channel enabled flags select which pots contribute to the fused
position estimate; disabled channels are still sampled so telemetry can
see them, they just don’t influence control.
ReadPos is a closure that returns raw 12-bit ADC readings (0..4095) for
all N channels in one call.
Implementations§
Source§impl<CS: CsControl, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos, const N: usize> ActuonixLinear<CS, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos, N>
impl<CS: CsControl, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos, const N: usize> ActuonixLinear<CS, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos, N>
Sourcepub fn new<SlpMode, DisMode>(
drv: Drv8873<CS>,
pwm1: Pwm1,
pwm2: Pwm2,
nsleep: Pin<SLP_P, SLP_N, SlpMode>,
disable: Pin<DIS_P, DIS_N, DisMode>,
read_positions: ReadPos,
inverted: [bool; N],
stroke_len_mm: f32,
inverted_pair_sum_mm: f32,
buffer_bottom_mm: f32,
buffer_top_mm: f32,
) -> Self
pub fn new<SlpMode, DisMode>( drv: Drv8873<CS>, pwm1: Pwm1, pwm2: Pwm2, nsleep: Pin<SLP_P, SLP_N, SlpMode>, disable: Pin<DIS_P, DIS_N, DisMode>, read_positions: ReadPos, inverted: [bool; N], stroke_len_mm: f32, inverted_pair_sum_mm: f32, buffer_bottom_mm: f32, buffer_top_mm: f32, ) -> Self
Construct a new Actuonix driver with Hardware PWM.
inverted[i] should be true for channels whose pot wiper is wired
inversely to the extension direction (e.g., mechanically opposed units
that share the same drive signal). All channels start enabled.
Sourcepub fn set_channel_enabled(&mut self, channel: usize, enabled: bool)
pub fn set_channel_enabled(&mut self, channel: usize, enabled: bool)
Enable or disable a specific potentiometer channel. Disabled channels are still sampled for telemetry but do not contribute to the fused position estimate used by control.
Sourcepub fn any_channel_enabled(&self) -> bool
pub fn any_channel_enabled(&self) -> bool
True if at least one potentiometer channel is enabled for fusion.
Sourcepub fn channel_medians(&self) -> &[u16; N]
pub fn channel_medians(&self) -> &[u16; N]
Access the last computed per-channel medians (raw, uninverted). Useful for telemetry. Returns the values from the most recent refresh.
Sourcepub fn set_speed(&mut self, speed: f32)
pub fn set_speed(&mut self, speed: f32)
Set the motor speed and direction.
speed - A float from -1.0 (Full Retract) to 1.0 (Full Extend).
If no pot channels are enabled, soft-limit checks are skipped so manual drive still works without position feedback.
Sourcepub fn enforce_limits(&mut self)
pub fn enforce_limits(&mut self)
Continuously check the ADC position and brake if the actuator exceeds the software limits. This should be called regularly in the main application loop. No-op when no channels are enabled (manual drive without feedback).
Sourcepub fn is_limit_braking(&self) -> bool
pub fn is_limit_braking(&self) -> bool
True when we are currently braking due to software limit enforcement.
Sourcepub fn position_raw(&mut self) -> Option<u16>
pub fn position_raw(&mut self) -> Option<u16>
Refresh all channels and return the fused raw 12-bit position
(0..4095). Returns None if no channels are enabled.
Sourcepub fn position_percent(&mut self) -> Option<f32>
pub fn position_percent(&mut self) -> Option<f32>
Read position as a fraction (0.0 = Retracted, 1.0 = Extended).
Sourcepub fn position_mm(&mut self) -> Option<f32>
pub fn position_mm(&mut self) -> Option<f32>
Read position in millimeters.
Sourcepub fn stroke_len_mm(&self) -> f32
pub fn stroke_len_mm(&self) -> f32
Get the max stroke length.
Sourcepub fn sleep(&mut self)
pub fn sleep(&mut self)
Put the driver into sleep mode.
This shuts down most of the internal circuitry to reduce power consumption.
Sourcepub fn enable_outputs(&mut self)
pub fn enable_outputs(&mut self)
Enable the motor and wake the driver if in sleep.
Sourcepub fn disable_outputs(&mut self)
pub fn disable_outputs(&mut self)
Disable the motor and brake.
Sourcepub fn read_fault<I, PINS>(
&mut self,
spi_bus: &mut SpiBus<I, PINS>,
) -> Result<Fault, Error>where
I: Instance,
PINS: Pins<I>,
pub fn read_fault<I, PINS>(
&mut self,
spi_bus: &mut SpiBus<I, PINS>,
) -> Result<Fault, Error>where
I: Instance,
PINS: Pins<I>,
Read the FAULT status register from the DRV8873.