Skip to main content

Module sim

Module sim 

Source
Expand description

Virtual (simulated) CiA 402 drive backing a fieldbus-less axis. Virtual (simulated) CiA-402 drive backing a fieldbus-less axis.

SimDrive implements AxisView — the same seam an EtherCAT drive handle implements — so the generic Axis controller drives it with zero changes. It emulates a Profile Position drive: the CiA-402 state machine (Switch On Disabled → … → Operation Enabled), the set-point-acknowledge handshake, and motion integration.

Because there is no bus, the runtime must advance the simulation each control cycle by calling SimDrive::step (analogous to the EtherCAT handle’s PDO exchange) before the axis reads feedback.

use autocore_std::motion::sim::SimDrive;
use autocore_std::motion::{AxisView, cia402::{Cia402Control, RawControlWord}};

let mut sim = SimDrive::new();
// Command Operation Enabled (CW 0x000F) and step the sim a few cycles.
let mut cw = RawControlWord(0); cw.cmd_enable_operation();
sim.set_control_word(cw.raw());
sim.set_modes_of_operation(1); // PP
for _ in 0..3 { sim.step(0.01); }
// Status word bit 2 = Operation Enabled.
assert!(sim.status_word() & (1 << 2) != 0);

Structs§

SimDrive
A simulated CiA-402 Profile Position drive.