Skip to main content

MoveToLoad

Struct MoveToLoad 

Source
pub struct MoveToLoad { /* private fields */ }
Expand description

Move To Load function block.

Drives an axis toward a target load (e.g. from a load cell) and halts as soon as the reading reaches that load.

  • If current_load > target_load, the axis moves in the negative direction.
  • If current_load < target_load, the axis moves in the positive direction.

If the axis reaches position_limit before the load is achieved, the FB halts and enters an error state.

§Lifecycle

is_busy() is true between start and the moment the axis stops (either by reaching the load, hitting the position limit, or being aborted). When the FB returns to idle, check is_error to find out whether the move succeeded.

§Noise rejection

This FB does single-sample threshold detection — it compares current_load against the target once per tick and triggers the moment the threshold is crossed. There is no FB-side debounce, because adding scan-count debounce would compound latency on top of whatever filtering the load card already applies, and overshoot in load control is force on the specimen.

Configure the load card’s filter as the noise-rejection layer. For example, the Beckhoff EL3356’s IIR filter or the NI 9237’s BAA / decimation filter both run in hardware with known phase response. By the time the reading reaches current_load, it should already be smooth enough that a single-sample threshold is reliable.

§Overshoot avoidance: dead_band

Even with a perfectly clean signal, there is unavoidable latency between trigger and stop: the trigger fires, the FB calls axis.halt(), and the axis decelerates over some distance — during which the load continues to change. The result is overshoot past the requested target.

The dead_band configuration trips the threshold early by dead_band units in the direction of motion so the deceleration phase brings the load to the actual target rather than past it:

    load (moving_negative = true, load decreasing)
      │
start ●───────────╮          trigger at target + dead_band
                  │          ↓
                  ●·······╮  halt() called
                           ╲
        target ────────────●◀── final load (close to target)
                             ╲ → undershoot here without dead_band
                 └─ time ─────────────▶

dead_band defaults to 0.0 (strict triggering, fine for slow moves or where the position-limit safety net catches overshoot). To configure it, measure the worst-case overshoot during commissioning and set dead_band to that value via set_dead_band. It persists across start calls.

Implementations§

Source§

impl MoveToLoad

Source

pub fn new() -> Self

Constructor.

Source

pub fn abort(&mut self)

Abort the operation. The axis will be halted by the next tick.

Source

pub fn start(&mut self, target_load: f64, position_limit: f64)

Start the move-to-load operation.

target_load and position_limit are latched on this call and used by every subsequent tick until the FB returns to idle. Any previous trigger position / load values are cleared.

Source

pub fn reset(&mut self)

Reset the state machine to Idle. Does not halt the axis (call abort for that, or halt the axis directly).

Source

pub fn is_error(&self) -> bool

True if the FB encountered an error during the last command.

Source

pub fn error_message(&self) -> String

Returns the error message for the last command.

Source

pub fn is_busy(&self) -> bool

True if the FB is currently executing a command.

Source

pub fn triggered_position(&self) -> f64

Axis position at the moment the load threshold was crossed. Returns f64::NAN until the FB has triggered at least once. Cleared by start.

Source

pub fn triggered_load(&self) -> f64

Load reading at the moment the threshold was crossed. Returns f64::NAN until the FB has triggered at least once. Cleared by start.

Source

pub fn set_dead_band(&mut self, value: f64)

Set the early-trigger margin in load units. See the type-level docs for what this is and when to use it.

Negative values are clamped to 0.0. The new value is read on every tick, so it can be changed mid-move if the caller needs to.

Source

pub fn dead_band(&self) -> f64

Currently-configured early-trigger margin.

Source

pub fn tick(&mut self, axis: &mut impl AxisHandle, current_load: f64)

Execute the function block.

  • axis: the axis being driven.
  • current_load: the latest load reading. Assumed already filtered by the load card — see the type-level docs on noise rejection.

Trait Implementations§

Source§

impl Clone for MoveToLoad

Source§

fn clone(&self) -> MoveToLoad

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MoveToLoad

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MoveToLoad

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V