[][src]Struct accel_stepper::Driver

pub struct Driver { /* fields omitted */ }

A stepper motor driver.

Note

You may want to use the CummulativeSteps helper to convert a movement in "real" units (e.g. mm or inches) to the correct number of steps.

Methods

impl Driver[src]

pub fn new() -> Driver[src]

pub fn move_to(&mut self, location: i64)[src]

Move to the specified location relative to the zero point (typically set when calibrating using Driver::set_current_position()).

pub fn move_by(&mut self, delta: i64)[src]

Move forward by the specified number of steps.

pub fn set_max_speed(&mut self, steps_per_second: f32)[src]

Set the maximum permitted speed in steps/second.

Caution

the maximum speed achievable depends on your processor and clock speed. The default max speed is 1.0 step per second.

pub fn max_speed(&self) -> f32[src]

Get the maximum speed.

pub fn set_acceleration(&mut self, acceleration: f32)[src]

Set the acceleration/deceleration rate (in steps/sec/sec).

pub fn acceleration(&self) -> f32[src]

Get the acceleration/deceleration rate.

pub fn set_speed(&mut self, speed: f32)[src]

Set the desired constant speed in steps/sec.

Speeds of more than 1000 steps per second are unreliable. Very slow speeds may be set (eg 0.00027777 for once per hour, approximately). Speed accuracy depends on the system's clock. Jitter depends on how frequently you call the Driver::poll_at_constant_speed() method. The speed will be limited by the current value of Driver::max_speed().

pub fn speed(&self) -> f32[src]

Get the most recently set speed.

pub fn distance_to_go(&self) -> i64[src]

Get the number of steps to go until reaching the target position.

pub fn target_position(&self) -> i64[src]

Get the most recently set target position.

pub fn set_current_position(&mut self, position: i64)[src]

Reset the current motor position so the current location is considered the new 0 position.

Useful for setting a zero position on a stepper after an initial hardware positioning move.

pub fn current_position(&self) -> i64[src]

Get the current motor position, as measured by counting the number of pulses emitted.

Note

Stepper motors are an open-loop system, so there's no guarantee the motor will actually be at that position.

pub fn stop(&mut self)[src]

Sets a new target position that causes the stepper to stop as quickly as possible, using the current speed and acceleration parameters.

pub fn is_running(&self) -> bool[src]

Checks to see if the motor is currently running to a target.

pub fn poll<C, D>(&mut self, device: D, clock: C) -> Result<(), D::Error> where
    C: SystemClock,
    D: Device
[src]

Poll the driver and step it if a step is due.

This function must called as frequently as possoble, but at least once per minimum step time interval, preferably as part of the main loop.

Note that each call to Driver::poll() will make at most one step, and then only when a step is due, based on the current speed and the time since the last step.

Warning

For correctness, the same SystemClock should be used every time Driver::poll() is called. Failing to do so may mess up internal timing calculations.

pub fn poll_at_constant_speed<C, D>(
    &mut self,
    device: D,
    clock: C
) -> Result<bool, D::Error> where
    C: SystemClock,
    D: Device
[src]

Poll the motor and step it if a step is due, implementing a constant speed as set by the most recent call to Driver::set_speed().

You must call this as frequently as possible, but at least once per step interval, returns true if the motor was stepped.

Trait Implementations

impl PartialEq<Driver> for Driver[src]

impl Default for Driver[src]

impl Debug for Driver[src]

Auto Trait Implementations

impl Unpin for Driver

impl Sync for Driver

impl Send for Driver

impl RefUnwindSafe for Driver

impl UnwindSafe for Driver

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]