Skip to main content

El3356

Struct El3356 

Source
pub struct El3356 {
    pub peak_load: f32,
    pub busy: bool,
    pub error: bool,
    pub error_message: String,
    pub configured_mv_v: Option<f32>,
    pub configured_full_scale_load: Option<f32>,
    pub configured_scale_factor: Option<f32>,
    /* private fields */
}
Expand description

Function block for the Beckhoff EL3356 strain-gauge terminal.

Fields§

§peak_load: f32

Largest absolute load seen since construction, last reset, or last tare.

§busy: bool

True while a configuration read or write sequence is in progress.

§error: bool

True after an SDO operation failed. Clear with clear_error.

§error_message: String

Last error message, if any.

§configured_mv_v: Option<f32>

Current sensitivity (mV/V) value on the device. Populated by the last successful configure or read_configuration. None until one of those completes. Reset to None at the start of each call.

§configured_full_scale_load: Option<f32>

Current full-scale load value on the device. Populated by the last successful configure or read_configuration. None until one completes. Reset to None at the start of each call.

§configured_scale_factor: Option<f32>

Current scale factor on the device. Populated by the last successful configure or read_configuration. None until one completes. Reset to None at the start of each call.

Implementations§

Source§

impl El3356

Source

pub fn new(device: &str) -> Self

Create a new EL3356 function block for the given EtherCAT device name.

device must match the name used in project.json’s ethercat device list (it’s the device field sent with every SDO request).

Source

pub fn tick(&mut self, view: &mut El3356View<'_>, client: &mut CommandClient)

Call every control cycle.

Performs three things, in order:

  1. Updates peak_load from *view.load.
  2. Releases the tare pulse after 100 ms.
  3. Progresses any in-flight SDO operation from configure.
Source

pub fn configure( &mut self, client: &mut CommandClient, full_scale_load: f32, sensitivity_mv_v: f32, scale_factor: f32, )

Begin an SDO configuration sequence: sensitivity (mV/V), full-scale load, and scale factor written to object 0x8000 subs 0x23, 0x24, and 0x27 respectively. Non-blocking — sets busy = true and returns immediately. Poll busy / error on subsequent ticks.

No-op (logs a warning) if the FB is already busy. Any existing error flag is cleared at the start of a new sequence.

Source

pub fn read_configuration(&mut self, client: &mut CommandClient)

Begin an SDO read sequence that fetches the three calibration parameters from the terminal’s non-volatile memory.

The EL3356 stores sensitivity, full-scale load, and scale factor persistently, so the card may power up with values from a previous configuration — not necessarily what the current control program expects. Call read_configuration at startup (or whenever you need to verify the sensor parameters) to populate the configured_* fields with the device’s current values.

Non-blocking: sets busy = true and returns immediately. Poll busy / error on subsequent ticks. No-op (logs a warning) if already busy. Clears error and resets all three configured_* fields to None at the start so intermediate values aren’t mistaken for final ones.

Source

pub fn reset_peak(&mut self)

Reset peak_load to 0.0. Immediate; no IPC.

Source

pub fn tare(&mut self)

Pulse the tare bit high for 100 ms, and reset the peak.

The device-side bit (view.tare) is actually written by tick, so tick must be called every cycle. If tare is called while a previous pulse is still in progress, the 100 ms window restarts.

Source

pub fn clear_error(&mut self)

Clear the error flag and message.

Source

pub fn sdo_write( &mut self, client: &mut CommandClient, index: u16, sub_index: u8, value: Value, )

Write an arbitrary SDO. Non-blocking; sets busy = true and tracks the response through the FB’s state machine like the other operations.

Does not touch the configured_* calibration fields — generic writes are orthogonal to the calibration cycle managed by configure and read_configuration.

Source

pub fn sdo_read( &mut self, client: &mut CommandClient, index: u16, sub_index: u8, )

Read an arbitrary SDO. Non-blocking; the response lands in the internal result buffer, retrievable via result, result_as_f64, result_as_i64, or result_as_f32 once busy clears.

Does not touch the configured_* calibration fields — generic reads are orthogonal to the calibration cycle managed by configure and read_configuration.

Source

pub fn set_mode0_filter_enabled( &mut self, client: &mut CommandClient, enable: bool, )

Enable or disable the filter on Mode 0, which is the default, slower mode of the bridge input ADC. Factory default is TRUE. Mode 0 is active when the Sample Mode bit of the Control Word is FALSE.

Source

pub fn set_mode0_averager_enabled( &mut self, client: &mut CommandClient, enable: bool, )

Enable or disable the averager on Mode 0, which is the default, slower mode of the bridge input ADC. The averager is low-latency and should usually be left on. Mode 0 (10.5 kSps internal rate): The 4-sample averager adds roughly 0.14 ms of latency. Factory default is TRUE. Mode 0 is active when the Sample Mode bit of the Control Word is FALSE.

Source

pub fn set_mode0_filter( &mut self, client: &mut CommandClient, filter: El3356Filters, )

Set the Mode 1 filter (CoE 0x8000:11). Mode 0, the default mode, is High Precision. Mode 0 is active when the Sample Mode bit of the Control Word is FALSE. The ADC runs slower (yielding a hardware latency of around 7.2 ms) but delivers very high accuracy and low noise.
Mode 0 is typically used paired with a stronger IIR filter—for highly accurate, static weighing where a completely calm value is required.

Source

pub fn set_mode1_filter_enabled( &mut self, client: &mut CommandClient, enable: bool, )

Enable or disable the filter on Mode 1, the faster mode of the bridge input ADC. Factory default is TRUE. Mode 1 is active when the Sample Mode bit of the Control Word is TRUE.

Source

pub fn set_mode1_averager_enabled( &mut self, client: &mut CommandClient, enable: bool, )

Enable or disable the averager on Mode 1, the faster mode of the bridge input ADC. The averager is low-latency and should usually be left on. Mode 1 (105.5 kSps internal rate): The 4-sample averager adds roughly 0.014 ms of latency. Factory default is TRUE. Mode 1 is active when the Sample Mode bit of the Control Word is TRUE.

Source

pub fn set_mode1_filter( &mut self, client: &mut CommandClient, filter: El3356Filters, )

Set the Mode 1 filter (CoE 0x8000:12). Mode 1 sacrifices a bit of accuracy for speed: the ADC runs much faster (yielding a hardware latency around 0.72 ms). Mode 1 is typically paired with a very weak filter (like IIR1 or disabled entirely) to track fast transients — for example, capturing a rapid impact or tracking a high-speed dosing cycle. Mode 1 is active when the Sample Mode bit of the Control Word is TRUE.

Source

pub fn is_error(&self) -> bool

The FB encountered an error processing the last command.

Source

pub fn is_busy(&self) -> bool

The FB is busy processing a command.

Source

pub fn reset(&mut self)

Full reset: drop all transient state so the FB behaves as if freshly constructed (except for the cached SDO device name).

Clears the error flag, cancels any in-flight SDO operation, releases the tare bit on the next tick, and discards the last sdo_read result. Does not zero peak_load — call reset_peak or tare if you need that — and does not clear configured_*; those stay populated from the last configure or read_configuration so the program’s view of the device’s calibration survives a mid-op abort.

Source

pub fn result(&self) -> Value

Get the full response from the most recent sdo_read.

The returned value is the complete ethercat.read_sdo payload — an object with value, value_hex, size, raw_bytes, etc. Prefer the typed accessors (result_as_f64, result_as_i64, result_as_f32) for scalar register reads.

Source

pub fn result_as_f64(&self) -> Option<f64>

Get the value field of the most recent sdo_read as an f64, if the SDO returned a number. Returns None if no read has completed, the response had no value field, or the field is not coercible to f64.

Source

pub fn result_as_i64(&self) -> Option<i64>

Get the value field of the most recent sdo_read as an i64. See result_as_f64 for None semantics.

Source

pub fn result_as_f32(&self) -> Option<f32>

Get the value field of the most recent sdo_read as an f32, interpreting the returned u32 bit pattern as an IEEE-754 single-precision float. This is the correct accessor for REAL32 SDOs (e.g. the EL3356’s calibration parameters).

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> 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, 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