fieldbus

EtherCAT Primer

From zero to interview-ready: what EtherCAT is, how it works at the physical layer, what sits between the PHY and the controller, and how you would design the master port on a robot's compute carrier board.

00

The one-minute version

EtherCAT is an industrial Ethernet fieldbus that uses ordinary 100 Mb/s Ethernet hardware but runs it as a ring. The master sends one frame per cycle. That frame passes through every slave in turn, and each slave's EtherCAT Slave Controller (ESC) reads its outputs and writes its inputs into the frame while the bits are still passing through, in hardware, with well under a microsecond of delay per node. The last slave sends the frame back to the master on the return pair of the same cable. A separate mechanism, Distributed Clocks, synchronizes every slave's local clock to within well under a microsecond, so all joints act at the same instant even though the frame reached them at different times.

Say it this wayEtherCAT gives me one frame per cycle that every joint reads and writes on the fly, plus distributed clocks that align every joint to well under a microsecond. On the carrier board the master is just a standard Ethernet MAC and PHY; the determinism lives in the slave controllers and the protocol, not in special master hardware.

01

Why standard Ethernet is not enough

A robot needs every joint to receive a new setpoint and return its state every control cycle, with the same timing every time. Ordinary switched Ethernet cannot promise that:

EtherCAT keeps the Ethernet physical layer and frame format, so cables, connectors, magnetics and PHYs are commodity parts. It removes the switch, the per-device frame and the per-device software from the timing path.

02

Application diagram: PHY to controller

EtherCAT application diagram from master controller to slave motor driveCOMPUTE CARRIER BOARD · EtherCAT masterThor CPU / RT MCUmaster stackIgH · SOEM · TwinCATEthernet MACstandard NICPHY100BASE-TXMagnetics1:1 + CMCRJ45 / M12D-codedRGMII/MIIMDI pairsDMACat5e cable · 2 pairs · ≤100 mJOINT MODULE · EtherCAT slave 1Connectorport 0 inMagneticsPHY port 0MII, ≤320 ns RXESCET1100 · LAN9252ports · FMMU · SyncMgrDPRAM · DC unitauto-forward / loopMIIPHY port 1MII, ≤140 ns TXMagneticsConnectorport 1 outMIIto slave 2SII EEPROMESI identityI²C25 MHz osc± 25 ppmshared with ESCand both PHYsSlave MCUCoE · CiA 402 drive profilePDI: SPI / HBISYNC0 / IRQMotor driveFOC current loop · PWM · encoderPHY → ESC: LINK signal (not activity)ESC → PHYs: MDIO managementEEE disabled · RX_ER to ESC

Master side (your compute carrier board). The CPU runs the master stack and builds the cyclic frame in memory. The Ethernet MAC sends it by DMA over RGMII or MII to a 100BASE-TX PHY. The PHY drives the line through magnetics to an RJ45 or M12 D-coded connector. Nothing here is EtherCAT-specific; a standard NIC works.

Slave side (each joint module).

  1. Port 0 in: connector, magnetics, then PHY port 0, which converts line symbols back to MII nibbles.
  2. ESC: receives the frame on port 0, processes it on the fly, and passes it to port 1 almost immediately. If nothing is plugged into port 1, the ESC closes the loop internally and sends the frame back out of port 0.
  3. Port 1 out: PHY port 1, magnetics and connector to the next slave.
  4. SII EEPROM: holds the slave's identity and configuration (from its ESI XML description). The ESC loads it at power-up.
  5. Shared 25 MHz clock: the ESC has no transmit FIFO when using MII, so the ESC and both PHYs must run from the same clock source.
  6. PDI: the process data interface (SPI or a parallel host bus) lets the local MCU read outputs and write inputs in the ESC's RAM.
  7. SYNC0: the distributed-clock unit raises this pulse at the synchronized instant. The MCU latches its setpoint and samples its encoder on SYNC0, not on frame arrival.
  8. Motor drive: the MCU runs the CiA 402 drive state machine and the local current loop (FOC, PWM, encoder) at 10–40 kHz.

Say it this wayEach joint module is two PHYs, an ESC, an EEPROM and an MCU. The frame enters port 0, gets processed in hardware, leaves port 1, and comes back the same way on the return pair. The MCU acts on SYNC0, which is what makes the timing independent of where the joint sits in the chain.

03

Physical layer, from first principles

EtherCAT normally runs on 100BASE-TX, the same physical layer as ordinary Fast Ethernet. Understanding it explains most board-level decisions.

100BASE-TX transmit pathMII nibbles at 25 MHz are 4B/5B encoded to 125 Mbaud, scrambled, converted to NRZI and MLT-3, and driven onto the twisted pair through magnetics; an MLT-3 waveform is shown.MII4 bit × 25 MHz= 100 Mb/s4B/5B5 bit symbols125 MbaudScramblerspread spectrumDC balanceNRZI → MLT-33 levelsfund. ≤ 31.25 MHzMagnetics1:1, isolationto 100 Ω pair1111011001+10−1MLT-3: each 1 steps to the next level(0, +1, 0, −1…); each 0 holds.4 ones make one full cycle, so thefundamental is ¼ of 125 Mbaud.

How the bits get onto the cable

  1. MII: the MAC or ESC hands the PHY 4 bits at a time on a 25 MHz clock. 4 × 25 MHz = 100 Mb/s.
  2. 4B/5B: each 4-bit nibble becomes a 5-bit code chosen to guarantee enough transitions for clock recovery and to provide control symbols. Line rate becomes 5 × 25 MHz = 125 Mbaud.
  3. Scrambling: the bit stream is XORed with a pseudo-random sequence so long repeated patterns do not concentrate energy at one frequency. This lowers EMI and keeps the signal balanced.
  4. MLT-3: each 1 moves the line to the next of three levels (0, +1, 0, −1); each 0 holds. A full cycle needs four 1s, so the highest fundamental is 125/4 = 31.25 MHz. That is why 100 Mb/s fits on Cat5 cable rated to 100 MHz.
  5. Pairs: one twisted pair transmits, the other receives (pins 1-2 and 3-6 on RJ45). Differential, 100 Ω, about 2 V peak to peak.
  6. Magnetics: 1:1 transformers with common-mode chokes give galvanic isolation (1,500 V rms per IEEE 802.3), block common-mode noise, and remove DC. Center taps go to a Bob Smith termination (75 Ω per pair into a high-voltage capacitor to chassis).

Why EtherCAT forms a ring on a line of cable

Full-duplex Ethernet already has two independent directions in every cable. EtherCAT uses them as the two halves of a ring: the outbound frame travels on one pair from node to node, each ESC processing it as it passes; the return path uses the other pair, with each ESC simply forwarding. A line topology is therefore a logical ring with no extra cable.

PHY requirements for an ESC

RequirementValueWhy
InterfaceMII recommendedRMII and RGMII PHYs add transmit FIFOs, which add forwarding delay and jitter. RMII/RGMII only with FPGA IP cores.
RX / TX latency≲ 320 ns / ≲ 140 nsEvery slave adds PHY RX + ESC + PHY TX delay; this sets the per-node forwarding delay.
Link-loss reaction< 15 µsNeeded for ring redundancy: the ESC must close a port fast when a cable breaks. Otherwise use enhanced link detection.
Clock25 MHz, ±25 ppmESC and PHYs share one clock source because MII ESCs have no TX FIFO.
Auto-negotiationOn, 100 Mb/s full duplexIdeally advertise only 100 FD via strapping.
Link signalLink-only LED outputThe ESC uses it to open or close ports. Never an activity signal.
EEE (802.3az)DisabledLow-power idle would add wake latency and break timing.
Preamble, RX_ERUnmodified; RX_ER in and between framesThe ESC uses RX_ER for error counting and enhanced link detection.
PHY address0–3 (or offset 16)Ports map to PHY addresses; avoid broadcast/isolate addresses.
StartupWorks without MDIO configurationRequired features must be active from power-on strapping.

Source: Beckhoff PHY Selection Guide v3.1. Example compliant 100BASE-TX PHYs listed there include Microchip KSZ8081 and KSZ8091, TI DP83826A and TLK110/111, and ADI ADIN1200.

Other physical variants

Board design notes

Say it this wayIt's plain 100BASE-TX: 4B/5B to 125 Mbaud, scrambled, MLT-3 so the fundamental stays at 31 MHz, two pairs through magnetics. EtherCAT uses the two pairs as the two halves of a ring. The board-level rules come from latency: MII not RMII, a shared 25 MHz clock, PHYs under about 320 ns receive and 140 ns transmit, fast link-loss detection, and EEE off.

04

The frame and processing on the fly

EtherCAT frame layoutEthernet preamble, destination and source MAC, EtherType 0x88A4, 2-byte EtherCAT header, then one or more datagrams each with a 10-byte header, data and 2-byte working counter, then the 4-byte FCS.Preamble+SFD8 BDest MAC6 BSrc MAC6 BType 88A42 BECAT hdr2 BDgram hdr10 BDatan BWKC2 BDgram 2…FCS4 BDatagram header: command (APRD, FPWR, LRW…) 1 B · index 1 B · address 4 B · length/flags 2 B · IRQ 2 BMax ~1,486 B of datagrams per Ethernet frame · 12 B inter-frame gap on the wire · minimum frame 64 B
Processing on the flyThe master sends one frame. It passes through slaves 1 to 4 on one pair; each slave reads and writes its own slot as the frame passes. The last slave closes the loop and the frame returns on the other pair to the master.Mastersends 1 frameper cycleSlave 1reads + writesits slotSlave 2reads + writesits slotSlave 3reads + writesits slotSlave 4reads + writesits slotslave 4 port 1 open,loop closes inside ESCoutbound on pair A →← return on pair BEth+ECAT hdrS1S2S3S4WKCFCSone LRW datagram: each slave's FMMU maps it to a slice of the frameWKC counts successful accesses; the master checks it every cycle

An EtherCAT frame is an ordinary Ethernet frame with EtherType 0x88A4. Inside are one or more datagrams, each with a command, an address, data and a working counter (WKC).

Say it this wayThe cyclic data is one logical read-write datagram. Each slave's FMMU maps its slice, reads its setpoint and writes its feedback in transit, and bumps the working counter. If the WKC is wrong, the master knows a joint missed that cycle.

05

Inside the slave controller

Inside an EtherCAT slave controllerUp to four ports with loop control feed the EtherCAT processing unit; FMMUs map logical addresses; SyncManagers guard the process data RAM; a DC unit produces SYNC and LATCH signals; the PDI connects the RAM to the local MCU; an EEPROM controller loads identity.ESCPort 0MII from PHYPort 1MII to PHYPorts 2–3optional (tree)Auto-forward+ loop controlcloses open portsEtherCAT processingunit (EPU)FMMUlog → physSyncMgrmbx · 3-bufProcess data RAMDPRAM, up to 60 KBregisters 0–4 KBPDISPI · µC busMCU / FPGAapplicationDC unitSYNC0/1 · LATCH0/1SII EEPROM ctrlESI identity · PDI config
06

Distributed clocks

Distributed clocks delay measurementA frame is time-stamped by each slave on its way out and again on its way back; the master reads the timestamps, computes each link's propagation delay and each slave's offset to the reference clock in slave 1.Masterreads stampswrites offsetstimestamp latched at each port, outbound and on returnSlave 1ref clock64-bit, 1 nsSlave 2local clocksteered to refSlave 3local clocksteered to refLink delay between slaves n and n+1 ≈ [ (t_back,n − t_out,n) − (t_back,n+1 − t_out,n+1) ] / 2Offset = reference time − local time − accumulated delay. Drift is trimmed continuously by an ARMW of the reference time each cycle.Result: every slave's SYNC0 fires within well under 1 µs of the others, regardless of when the frame arrived.

Without synchronization, joint 1 would act about 40 µs before joint 40, simply because the frame reaches it first, and the master's own send-time jitter would move every joint around cycle to cycle. Distributed clocks remove both effects.

  1. The first DC-capable slave becomes the reference clock.
  2. At start-up the master sends a broadcast that makes every port latch its local time as the frame passes, outbound and on return. From those timestamps it computes the propagation delay of every link.
  3. It writes each slave's offset so every local clock reads the reference time.
  4. Each cycle it reads the reference time and distributes it (an ARMW datagram). Each slave compares and nudges its clock rate, compensating crystal drift.
  5. Each slave raises SYNC0 at a programmed system time. All joints latch setpoints and sample sensors at that instant.

The master's frame can now arrive with tens of microseconds of jitter and nothing changes, as long as it arrives before SYNC0. That is why a general-purpose OS on the master can be good enough, provided it meets the cycle deadline.

Say it this wayDistributed clocks measure every link's delay with timestamps on the way out and back, then steer each slave's clock to a reference. Joints act on SYNC0, not on frame arrival, so master jitter and position in the chain stop mattering.

07

State machine and protocols

StateWhat works
InitNo mailbox or process data. Master sets addresses and SyncManagers.
Pre-OperationalMailbox works. Master configures parameters through CoE (PDO mapping, gains, limits).
Safe-OperationalInputs are valid; outputs held in a safe state. Distributed clocks lock.
OperationalInputs and outputs both live. The robot can move.
BootstrapFirmware update through FoE.

Say it this wayDrives come up through Init, Pre-Op, Safe-Op, Op. Configuration is CoE in Pre-Op; cyclic control is CiA 402 cyclic synchronous torque or position. Safety commands ride as FSoE inside the same frames, using the black-channel principle.

08

Worked timing budget for a robot

Assumptions: 40 joint slaves in one line, each exchanging 12 bytes out (target torque, control word, offsets) and 12 bytes in (position, velocity, torque, status). One LRW datagram for all of them.

ItemDerivationResult
Process data40 × (12 + 12) B960 B
Frame on the wire8 preamble + 14 Ethernet header + 2 ECAT header + 10 datagram header + 960 + 2 WKC + 4 FCS + 12 gap1,012 B
Serialization time1,012 × 8 bit ÷ 100 Mb/s81 µs
Forwarding delay40 slaves × ~1 µs (PHY RX + ESC + PHY TX, both directions combined)~40 µs
Cable40 × 1 m × 2 directions × 5 ns/m0.4 µs
Frame round trip81 + 40 + 0.4~121 µs
Bus load at 1 kHz121 µs ÷ 1,000 µs~12%
Fastest practical cycleround trip plus master compute and margin250 µs (4 kHz)

Data rate is 960 B × 1 kHz ≈ 1 MB/s each way, trivial next to the carrier board's camera traffic. The limit on cycle rate is the frame time and the master's ability to compute and send on time, not bandwidth. If 40 joints at 4 kHz is not enough, split into two EtherCAT segments on two master ports, or move to EtherCAT G.

The ETG's published reference points: about 1,000 distributed digital I/O in roughly 30 µs, and 100 servo axes in about 100 µs.

Say it this wayForty joints at 24 bytes each is under a kilobyte, about 81 µs on the wire plus about a microsecond per node, so roughly 120 µs round trip. A 1 kHz loop uses 12% of the bus; 4 kHz is feasible. The constraint is master timing, not bandwidth.

09

The master on your compute carrier board

Say it this wayI'd give EtherCAT its own MAC and PHY, no switch, and run the master on a real-time core that's isolated from the inference workload, either an isolated core under PREEMPT_RT or a dedicated MCU. A second port on the far end gives ring redundancy, and safety stays on its own path through FSoE or hardwired STO.

10

How it compares

BusRateSyncTopologyMaster hardwareFit for robot joints
EtherCAT100 Mb/s (1 Gb/s G)DC, < 1 µsLine, ring, treeStandard NICVery good; common in robot arms and humanoids
PROFINET IRT100 Mb/s< 1 µsLine, star via switchesSpecial switch ASICsGood; more common in factory cells
TSN Ethernet100 Mb/s–10 Gb/sgPTP 802.1ASSwitchedTSN-capable switchesPromising; ecosystem still maturing
CAN FDup to ~5–8 Mb/s dataNone nativeBusCAN controllerFine for few joints at lower rates
EtherNet/IP100 Mb/s–1 Gb/sCIP Sync (PTP)SwitchedStandardLess deterministic for tight motion loops
11

Interview questions

Why doesn't the EtherCAT master need special hardware?
Because all the timing-critical work happens in the slaves' ESCs. The master only needs to send one standard Ethernet frame per cycle and receive it back. Distributed clocks make the slaves' actions independent of the master's send jitter.
What is processing on the fly?
The ESC reads its output data and inserts its input data while the frame is still streaming through, buffering only a few bits. Per-node delay is the PHY receive and transmit latency plus a small ESC delay, well under a microsecond.
How does a line topology become a ring?
Full-duplex Ethernet has separate transmit and receive pairs. The outbound frame travels on one pair through every node, and the last node turns it around onto the other pair back to the master.
Why MII and not RMII for the slave PHYs?
RMII and RGMII PHYs need transmit FIFOs to cross clock domains. That adds forwarding delay and jitter at every node. MII lets the ESC and PHYs share one 25 MHz clock with no FIFO.
What happens if a cable breaks?
The PHY reports link loss and the ESC closes that port, so the frame turns around there. Slaves upstream keep working. With a second master port at the far end (ring redundancy), the slaves beyond the break are reached from the other side. This needs link-loss detection under 15 µs.
How do distributed clocks work?
Timestamps on outbound and return passes give each link's propagation delay. The master writes each slave's offset to the reference clock, then compensates drift every cycle. Slaves act on SYNC0 at a common system time.
How do you know a slave missed its data?
The working counter. Each successful access increments it, the master knows the expected value, and a mismatch flags that cycle.
What's the working counter increment for LRW?
Read +1, write +2, so a successful read-write adds 3 per slave that has both mapped.
What cycle time can you run 40 joints at?
About 120 µs round trip for 24 bytes per joint, so 1 kHz uses about 12% of the bus and 4 kHz is feasible. The master's compute and send deadline is usually the limit.
Where would you run the master on a Thor-based carrier?
Either an isolated core under PREEMPT_RT running IgH or SOEM, or a dedicated real-time MCU that owns the port and exchanges setpoints with the SoC. I'd lean to the dedicated MCU so a heavy inference load can't starve the control loop.
How is safety handled?
FSoE, a black-channel protocol rated to SIL 3, carries safe-stop and STO commands inside the normal frames with its own CRC and watchdog. Many designs also keep a hardwired STO from a safety MCU.
What is CiA 402 and which mode would you use?
The CANopen drive profile carried over CoE. For a robot joint with a torque-level controller on the master, cyclic synchronous torque (CST); for position-controlled joints, cyclic synchronous position (CSP).
What's EtherCAT P?
EtherCAT plus two 24 V supplies on the same four wires, which cuts cable count to small modules.
Board layout concerns for an EtherCAT port near a motor drive?
Magnetics next to the connector, chassis-bonded shield and Bob Smith termination, 100 Ω matched MDI pairs, TVS at the connector, a short length-matched MII bus, and the PHY clock shared with the ESC. Keep the inverter's switching loop and its return current away from the PHY area.
12

White papers, app notes and references