ActuonixLinear

Struct ActuonixLinear 

Source
pub struct ActuonixLinear<const CS_P: char, const CS_N: u8, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos> { /* private fields */ }
Expand description

Generic driver for Actuonix linear actuators (P16, T16).

ReadPos is a closure that returns the raw 12-bit ADC reading (0..4095).

Implementations§

Source§

impl<const CS_P: char, const CS_N: u8, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos> ActuonixLinear<CS_P, CS_N, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos>
where Pwm1: _embedded_hal_PwmPin<Duty = u16>, Pwm2: _embedded_hal_PwmPin<Duty = u16>, ReadPos: FnMut() -> u16,

Source

pub fn new<SlpMode, DisMode>( drv: Drv8873<CS_P, CS_N>, pwm1: Pwm1, pwm2: Pwm2, nsleep: Pin<SLP_P, SLP_N, SlpMode>, disable: Pin<DIS_P, DIS_N, DisMode>, read_position: ReadPos, stroke_len_mm: f32, buffer_bottom_mm: f32, buffer_top_mm: f32, ) -> Self

Construct a new Actuonix driver with Hardware PWM.

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

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.

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

Read raw 12-bit ADC value (0-4095) with hardware oversampling and a median filter.

Source

pub fn position_percent(&mut self) -> f32

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

Source

pub fn position_mm(&mut self) -> 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_P, CS_N>

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<const CS_P: char, const CS_N: u8, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos> Freeze for ActuonixLinear<CS_P, CS_N, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos>
where Pwm1: Freeze, Pwm2: Freeze, ReadPos: Freeze,

§

impl<const CS_P: char, const CS_N: u8, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos> RefUnwindSafe for ActuonixLinear<CS_P, CS_N, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos>
where Pwm1: RefUnwindSafe, Pwm2: RefUnwindSafe, ReadPos: RefUnwindSafe,

§

impl<const CS_P: char, const CS_N: u8, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos> Send for ActuonixLinear<CS_P, CS_N, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos>
where Pwm1: Send, Pwm2: Send, ReadPos: Send,

§

impl<const CS_P: char, const CS_N: u8, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos> Sync for ActuonixLinear<CS_P, CS_N, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos>
where Pwm1: Sync, Pwm2: Sync, ReadPos: Sync,

§

impl<const CS_P: char, const CS_N: u8, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos> Unpin for ActuonixLinear<CS_P, CS_N, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos>
where Pwm1: Unpin, Pwm2: Unpin, ReadPos: Unpin,

§

impl<const CS_P: char, const CS_N: u8, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos> UnwindSafe for ActuonixLinear<CS_P, CS_N, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos>
where Pwm1: UnwindSafe, Pwm2: UnwindSafe, ReadPos: 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.