EtherCrab
An EtherCAT master written in pure Rust.
Crate features
std(enabled by default) - exposes the [std] module, containing helpers to run the TX/RX loop on desktop operating systems.defmt- enable logging with thedefmtcrate.log- enable logging with thelogcrate. This is enabled by default when thestdfeature is enabled.
For no_std targets, it is recommended to add this crate with
Examples
This example increments the output bytes of all detected slaves every tick. It is tested on an EK1100 with output modules but may work on other basic slave devices.
Run with e.g.
Linux
RUST_LOG=debug
Windows
$env:RUST_LOG="debug" ; cargo run --example ek1100 --release -- '\Device\NPF_{FF0ACEE6-E8CD-48D5-A399-619CD2340465}'
use Env;
use ;
use ;
use MissedTickBehavior;
/// Maximum number of slaves that can be stored. This must be a power of 2 greater than 1.
const MAX_SLAVES: usize = 16;
/// Maximum PDU data payload size - set this to the max PDI size or higher.
const MAX_PDU_DATA: usize = 1100;
/// Maximum number of EtherCAT frames that can be in flight at any one time.
const MAX_FRAMES: usize = 16;
/// Maximum total PDI length.
const PDI_LEN: usize = 64;
static PDU_STORAGE: = new;
async
Community
Current and future features
-
asyncAPI - Usable in
no_stdcontexts with no allocator required, as long as anasyncexecutor is available. - Autoconfigure slaves from their EEPROM (SII) data during startup
- Supports configuration using CoE data
- Safely usable in multi-threaded Linux systems with e.g.
tokioorstd::threadandblock_on. - Support for SDO read/writes to configure slave devices
- Distributed clocks
- Detection of delays between slave devices in topology
- Static drift compensation on startup
- Cyclic synchronisation during OP
- Basic support for CiA402/DS402 drives
- A higher level DS402 API for torque, position and velocity control of common servo drives in a more abstract way.
- Integration with LinuxCNC as a HAL component using
the Rust
linuxcnc-hal. - Load slave configurations from ESI XML files
Profiling
To profile an example:
# Might need sudo sysctl kernel.perf_event_paranoid=-1
# Might need sudo sysctl kernel.perf_event_mlock_kb=2048
# Ctrl + C when you're done
Sponsors
Thank you to everyone who has donated test equipment, time or money to the EtherCrab project! Would you like to be in this list? Then please consider becoming a Github sponsor!
- @nealsjoe generously donated an EK1100 with several IO modules for testing with.
- Trisk Bio generously donated some additional Beckhoff modules and some optical ethernet gear.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.