Back

EtherCAT

Loading views...

EtherCAT

Category: Industrial

Overview

EtherCAT (Ethernet for Control Automation Technology) is a real-time industrial Ethernet protocol by Beckhoff that processes frames on-the-fly at each slave, achieving sub-100µs cycle times and <1µs synchronization across all nodes. Ideal for motion control, robotics, and high-speed automation.


1. Theory & Fundamentals

  • Process-on-the-fly: Each slave reads/writes data as frame passes
  • Speed: 100 Mbps Ethernet; up to 1500 bytes per cycle
  • Cycle time: 62.5 µs with 100 axes
  • Distributed Clocks (DC): All slaves < 1 µs synchronized
  • Physical: Standard Cat5e Ethernet cable/connector
  • EtherType: 0x88A4
  • Slave ASIC: ET1100 (Beckhoff), LAN9252 (Microchip)

2. Frame / Packet Structure

EtherCAT frame (inside Ethernet frame):
  EtherType: 0x88A4
  EtherCAT Header: Length(11b) | Type(4b)
  Datagram(s):
    CMD | IDX | Address(4B) | Length | IRQ | Data | WC

CMD types:
  LRW = Logical Read/Write (most common)
  APRD/APWR = Auto-increment read/write
  FPRD/FPWR = Configured-address read/write

Working Counter: Each slave increments if it processed datagram
Address: Logical process image address

3. Protocol Mechanics

  • Master sends one frame containing all PDOs; slaves modify in-transit
  • Slave state machine: INIT → PRE-OP → SAFE-OP → OP
  • FMMU: Maps slave local memory to master process image
  • Sync Manager: Handles PDO (process) and mailbox (SDO) buffers
  • DC synchronization: Propagation delay measured, all clocks locked
  • CoE (CANopen over EtherCAT): SDO for acyclic parameter access

4. Hardware Implementation

  • Slave ASIC: LAN9252 (SPI interface to MCU), ET1100 (parallel)
  • Master: PC with any Ethernet NIC + TwinCAT or SOEM
  • Cable: Cat5e, 100m per segment
  • ECAT slave stack code (SSC): Beckhoff free download
  • Topology: Line, tree, ring (redundancy)

5. Register-Level / Configuration

// LAN9252 EtherCAT slave with SSC (Beckhoff Slave Stack Code)
#include "ecat_def.h"
#include "ecatslv.h"
void ECAT_Application(void) {
    // Map PDO outputs to actuator
    Motor_SetVelocity(Obj.TargetVelocity);
    // Map sensor to PDO inputs
    Obj.ActualVelocity = Encoder_GetVelocity();
    Obj.ActualPosition = Encoder_GetPosition();
    Obj.StatusWord     = Motor_GetStatus();
}
// Called every cycle by SSC interrupt

6. Driver / Software Development

// SOEM (Simple Open EtherCAT Master) on Linux
#include "ethercat.h"
ec_init("eth0");        // Init master on eth0
ec_config_init(FALSE);  // Find slaves
ec_config_map(&IOmap);  // Map process data
ec_statecheck(0, EC_STATE_SAFE_OP, EC_TIMEOUTSTATE);
ec_writestate(0);       // Set all to OP
while(running) {
    ec_send_processdata();   // Send PDOs
    ec_receive_processdata(EC_TIMEOUTRET);
    // IOmap now contains slave data
    memcpy(outputs, &IOmap[0], out_size);
}

7. Debugging & Testing

  • EtherCAT Wireshark plugin: Decode 0x88A4 frames
  • TwinCAT: Scan network, configure, monitor
  • EC-Engineer: Third-party config tool
  • Working Counter errors: Slave not processing datagram
  • Common issues: Wrong cable; slave stuck PRE-OP; DC not locking

8. Real-World Applications

  1. CNC machine axis control
  2. Robot joint torque/position control
  3. Semiconductor equipment (wafer handling)
  4. Printing/packaging machines
  5. Wind turbine pitch control

9. Advanced Topics & Edge Cases

  • EtherCAT P: 24V power + data on same cable
  • FSoE (Safety over EtherCAT): SIL 3 functional safety
  • EtherCAT G: 1 Gbps variant
  • Hot-connect: Add slaves at runtime
  • Redundancy: Ring topology for fault tolerance

10. Standards & Variants

Standard Notes
IEC 61158 EtherCAT standard
ETG.1000 EtherCAT spec
ETG.6100 FSoE safety layer
EtherCAT G 1 Gbps variant

💡 Practical Examples

Ex 1: Motion PDO — Master sends TargetVelocity=1500; slave returns ActualVelocity=1498 every 250 µs.

Ex 2: TwinCAT scan — discovers all slaves automatically.

Ex 3: DC sync — 20 servo drives synchronized to <500 ns jitter.


🧪 Practice Questions

Beginner: 1) Process-on-the-fly concept? 2) Working Counter? 3) Physical layer? 4) Slave states? 5) What is a PDO?

Intermediate: 1) Distributed Clocks sync. 2) FMMU mapping. 3) LAN9252 + STM32 slave. 4) PDO vs SDO. 5) How <100µs cycle achieved?

Advanced: 1) 32-axis motion system. 2) FSoE implementation. 3) SOEM master application. 4) Debug SAFE-OP stuck. 5) EtherCAT hot-connect.


Checklist

  • [ ] Explain process-on-the-fly
  • [ ] Understand slave state machine
  • [ ] Configure LAN9252 via SPI
  • [ ] Implement PDO data exchange
  • [ ] Use SDO for parameters
  • [ ] Set up Distributed Clocks
  • [ ] Debug with Wireshark plugin
  • [ ] Use TwinCAT for configuration
  • [ ] Build SOEM master application
  • [ ] Implement FSoE safety layer