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
impl MoveToLoad
Sourcepub fn start(
&mut self,
target_load: f64,
target_speed: f64,
target_accel: f64,
position_limit: f64,
)
pub fn start( &mut self, target_load: f64, target_speed: f64, target_accel: 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.
Sourcepub fn reset(&mut self)
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).
Sourcepub fn error_message(&self) -> String
pub fn error_message(&self) -> String
Returns the error message for the last command.
Sourcepub fn triggered_position(&self) -> f64
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.
Sourcepub fn triggered_load(&self) -> f64
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.
Sourcepub fn set_dead_band(&mut self, value: f64)
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.
Sourcepub fn set_stop_decel(&mut self, value: Option<f64>)
pub fn set_stop_decel(&mut self, value: Option<f64>)
Set the deceleration (user units / s²) used for the drive-side motion profile. Typically populated once at process startup by SDO-reading the drive’s quick-stop deceleration (0x6085) and converting counts/s² to user units.
Pass None to revert to the default behavior (use target_accel as
the deceleration). Values ≤ 0 are treated as None. Persists across
start calls.
Sourcepub fn stop_decel(&self) -> Option<f64>
pub fn stop_decel(&self) -> Option<f64>
Currently-configured deceleration, or None if the FB is falling
back to target_accel.
Sourcepub fn set_settle(&mut self, speed: f64, tolerance: f64)
pub fn set_settle(&mut self, speed: f64, tolerance: f64)
Enable the post-halt settle correction by setting both
settle_speed and settle_tolerance to non-zero values. Either
value at 0 disables the feature. See the Settling state docs.
Values clamped to >= 0. Persists across start.
Sourcepub fn settle_speed(&self) -> f64
pub fn settle_speed(&self) -> f64
Currently-configured settle speed (user units / s). Zero = disabled.
Sourcepub fn settle_tolerance(&self) -> f64
pub fn settle_tolerance(&self) -> f64
Currently-configured settle load tolerance. Zero = disabled.
Sourcepub fn tick(&mut self, axis: &mut impl AxisHandle, current_load: f64)
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
impl Clone for MoveToLoad
Source§fn clone(&self) -> MoveToLoad
fn clone(&self) -> MoveToLoad
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more