Skip to main content

ActuonixLinear

Struct ActuonixLinear 

Source
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>
where Pwm1: _embedded_hal_PwmPin<Duty = u16>, Pwm2: _embedded_hal_PwmPin<Duty = u16>, ReadPos: FnMut() -> [u16; N],

Source

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.

Source

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.

Source

pub fn any_channel_enabled(&self) -> bool

True if at least one potentiometer channel is enabled for fusion.

Source

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.

Source

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.

Source

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

Source

pub fn extend(&mut self)

Extend the actuator at full speed.

Source

pub fn retract(&mut self)

Retract the actuator at full speed.

Source

pub fn brake(&mut self)

Brake (stops quickly by shorting motor terminals).

Source

pub fn is_limit_braking(&self) -> bool

True when we are currently braking due to software limit enforcement.

Source

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.

Source

pub fn position_percent(&mut self) -> Option<f32>

Read position as a fraction (0.0 = Retracted, 1.0 = Extended).

Source

pub fn position_mm(&mut self) -> Option<f32>

Read position in millimeters.

Source

pub fn stroke_len_mm(&self) -> f32

Get the max stroke length.

Source

pub fn drv(&mut self) -> &mut Drv8873<CS>

Access the inner DRV8873 for fault reading.

Source

pub fn sleep(&mut self)

Put the driver into sleep mode.

This shuts down most of the internal circuitry to reduce power consumption.

Source

pub fn wake(&mut self)

Wake the driver from sleep mode.

Source

pub fn enable_outputs(&mut self)

Enable the motor and wake the driver if in sleep.

Source

pub fn disable_outputs(&mut self)

Disable the motor and brake.

Source

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.

Auto Trait Implementations§

§

impl<CS, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos, const N: usize> Freeze for ActuonixLinear<CS, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos, N>
where Pwm1: Freeze, Pwm2: Freeze, ReadPos: Freeze, CS: Freeze,

§

impl<CS, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos, const N: usize> RefUnwindSafe for ActuonixLinear<CS, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos, N>
where Pwm1: RefUnwindSafe, Pwm2: RefUnwindSafe, ReadPos: RefUnwindSafe, CS: RefUnwindSafe,

§

impl<CS, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos, const N: usize> Send for ActuonixLinear<CS, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos, N>
where Pwm1: Send, Pwm2: Send, ReadPos: Send, CS: Send,

§

impl<CS, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos, const N: usize> Sync for ActuonixLinear<CS, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos, N>
where Pwm1: Sync, Pwm2: Sync, ReadPos: Sync, CS: Sync,

§

impl<CS, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos, const N: usize> Unpin for ActuonixLinear<CS, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos, N>
where Pwm1: Unpin, Pwm2: Unpin, ReadPos: Unpin, CS: Unpin,

§

impl<CS, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos, const N: usize> UnsafeUnpin for ActuonixLinear<CS, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos, N>
where Pwm1: UnsafeUnpin, Pwm2: UnsafeUnpin, ReadPos: UnsafeUnpin, CS: UnsafeUnpin,

§

impl<CS, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos, const N: usize> UnwindSafe for ActuonixLinear<CS, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos, N>
where Pwm1: UnwindSafe, Pwm2: UnwindSafe, ReadPos: UnwindSafe, CS: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.