Real-Time Control on Linux: Preempt-RT + IgH EtherCAT Master on OK3576-C

In the industrial automation, achieving microsecond-level hard real-time control on general-purpose Linux systems has always been a key challenge for high-precision applications such as robotics and multi-axis motion control. The open-source IgH EtherCAT Master protocol stack, with its exceptional high real-time performance and low jitter characteristics, serves as a critical bridge connecting industrial fieldbus networks to upper-layer applications. However, unlocking its full potential relies on the robust support of the Preempt-RT real-time kernel.

Based on the Forlinx Embedded OK3576-C development board, this article demonstrates microsecond-level communication jitter control under CPU-isolated cores and full-load stress. Through comparative tests of 1ms synchronous speed mode and 125µs synchronous torque mode, it presents a practical, high-performance real-time industrial control solution.

Its Performance is Impressive!

In cycle synchronous velocity mode, cycle jitter was reduced from 6.3080 μs to 3.5790 μs.

In cycle synchronous torque mode, cycle jitter was reduced from 50.0470 μs to 2.1130 μs!

01 What is IgH EtherCAT Master?

Before answering this, let's first understand: What is EtherCAT? EtherCAT is one of the fastest-growing industrial Ethernet protocols. It adopts a hardware-driven architecture and offers multiple advantages including high speed, large data transmission capacity, long transmission distance, short update cycles, and support for a large number of connected devices.

What is IgH EtherCAT Master

IgH EtherCAT is an open-source EtherCAT master running on Linux systems. It creates a Linux character device, allowing applications to communicate with the EtherCAT master module through this interface.

What is IgH EtherCAT Master

It has three parts:

1. Master Module

Acts as the ''brain'' and core of the EtherCAT master.

Manages EtherCAT bus communication and handles data exchange and synchronization between master and slaves. Provides interfaces for both low‑level drivers and upper‑layer applications.

2. Device Modules

Real‑time optimized Ethernet drivers (e.g., stmmac for Rockchip RK platforms).

Bridge between the master and physical network ports. Intelligently separates traffic: selected devices handle EtherCAT frames; others operate as regular Ethernet devices, enabling EtherCAT and standard networking to run in parallel.

Real-Time Control on Linux: Preempt-RT + IgH EtherCAT Master on OK3576-C

3. Application

Executes user‑defined logic.

Requests bus control from the master via API. Once granted, configures the bus and performs cyclic process‑data exchange. Can be implemented as a kernel module or a user‑space program using EtherCAT/RTDM libraries.

Real-Time Control on Linux: Preempt-RT + IgH EtherCAT Master on OK3576-C

Contact us to obtain the official IgH EtherCAT Master source code and technical manual.

02 Real‑Time Kernel: Preempt‑RT

1. Key Advantages:

To ensure high real‑time performance, IgH EtherCAT Master must run on a real‑time operating system. Preempt‑RT is a Linux kernel optimized for real‑time performance, offering clear advantages over standard Linux:

① Hard Real‑Time Guarantee:

Provides deterministic task completion within strict deadlines, unaffected by other tasks.
Essential for time‑critical applications such as industrial automation and aerospace.

② Efficient Scheduling & Low Latency:

Employs priority‑based preemptive scheduling, allowing high‑priority tasks to immediately preempt lower‑priority ones.
Deeply optimizes interrupt handling to drastically reduce response times and eliminate system jitter.

③ High‑Precision Timing:

Delivers microsecond‑level kernel timer accuracy.
Supports real‑time extensions and kernel customization to meet precise cyclic communication requirements of EtherCAT.

2. Real‑Time Performance Testing

This test references the Rockchip RealTime Linux Performance Test Report and is divided into idle-load testing and stress testing. Test Environment:

① Tool: cyclictest

② Hardware Platform: OK3576-C Development Board

③ Kernel Version: 6.1.118-rt36

④ Path:SDK/docs/rk35xx/Patches/Real-Time-Performance/PREEMPT_RT/kernel-6.1/kernel-6.1.118

a. For configuring the Preempt‑RT kernel, refer to the user manual:
/1-manual/OK35xx-Linux6.1.118-configuring real-time kernel method.pdf

b. For real‑time performance test results on different hardware platforms, refer to:
/1-manual/OK35xx-Linux6.1.118-real-time test.pdf

3. Idle‑Load Test:

cyclictest -c 0 -m -t 8 -p99 -D12H

Parameter Details:
-c 0: Selects clock source CLOCK_MONOTONIC
-m: Locks memory to prevent swapping to disk
-t 8: Creates 8 test threads
-p 99: Sets thread priority to 99
-D 12H: Sets test duration to 12 hours

Real-Time Control on Linux: Preempt-RT + IgH EtherCAT Master on OK3576-C

4. Stress Test:

stress-ng -c8 --io 8 --cpu-load 100 -vm 4 --vm-bytes 512M --timeout 10000000s &

Parameter Details:
-c 8: Simulates 8 CPU cores running at full load
--io 8: Simulates disk I/O pressure
--cpu‑load 100: Sets target CPU load to 100%
-vm 4 --vm‑bytes 512M: Simulates memory pressure
--timeout 10000000s: Sets test duration to 10,000,000 seconds

Real-Time Control on Linux: Preempt-RT + IgH EtherCAT Master on OK3576-C

03 Demo Case

This demonstration uses the Cycle Synchronous Velocity (CSV) mode (communication cycle: 1 ms) and the Cycle Synchronous Torque (CST) mode (communication cycle: 125 μs) to drive a servo motor.

1. Environment Setup

Development Environment:

Kernel:6.1.118-rt36
IgH EtherCAT Master:IgH EtherCAT master 1.6.0-rc1
EtherCAT Master:OK3576-C
EtherCAT Slave:
(1)EtherCAT Coupler: EK1100
(2)Digital Output Module: EL2008
(3)Servo Drive: IS620NS1R6I+Servo Motor: MS1H1‑10B30CB‑A330Z

Topology Diagram:

Real-Time Control on Linux: Preempt-RT + IgH EtherCAT Master on OK3576-C

The master connects via Ethernet cable to the EtherCAT coupler EK1100. EK1100 connects via E‑Bus to the digital output module EL2008, and via Ethernet cable to the servo drive IS620N. The AC servo motor MS1H1‑10B30CB is connected to the servo drive IS620N via power and encoder cables.

Use the EtherCat debugging tool to output the identified slaves:

Real-Time Control on Linux: Preempt-RT + IgH EtherCAT Master on OK3576-C

Use the EtherCat debugging tool to output the bus topology:

Real-Time Control on Linux: Preempt-RT + IgH EtherCAT Master on OK3576-C

2. Servo Modes

The IS620N supports 7 servo modes: Profile Position (PP), Profile Velocity (PV), Profile Torque (PT), Homing (HM), Cyclic Synchronous Position (CSP), Cyclic Synchronous Velocity (CSV), Cyclic Synchronous Torque (CST).

Each mode supports different communication cycle times as shown below:

Cycle Time Profile Position Homing Cyclic Sync Position Cyclic Sync Velocity Profile Velocity Profile Torque Cyclic Sync Torque
125μs X X X X X Y Y
250μs X X X X X Y Y
500μs X X X Y Y Y Y
1ms Y Y Y Y Y Y Y

3. Master Performance Test Method

Reference for the following definitions: Definitions of Jitter and Latency

Real-Time Control on Linux: Preempt-RT + IgH EtherCAT Master on OK3576-C

Refer to the official example code: examples/dc_user/main.c · stable-1.5

This code implements the statistical collection of the maximum and minimum time spent per communication cycle. It cyclically prints the maximum and minimum EtherCAT communication cycle times within the interval, with a 1-second printing period.

Real-Time Control on Linux: Preempt-RT + IgH EtherCAT Master on OK3576-C

Demo 1: Cyclic Synchronous Velocity Mode (1 ms)

In Cyclic Synchronous Velocity mode, the upper-level controller periodically sends the pre-calculated target velocity (60FF) to the servo drive. Velocity and torque regulation are executed internally by the servo.

Basic Configuration:

RPDO TPDO Remarks
6040: Control Word 6041: Status Word Mandatory
60FF: Target Velocity Mandatory
6064: Position actual value Optional
606C: Velocity actual value Optional
6060: Modes of operation 6061: Modes of operation display Optional

PDO information output via EtherCAT debugging tool:

Real-Time Control on Linux: Preempt-RT + IgH EtherCAT Master on OK3576-C

Operation Steps:

1. Set the mode: Write 09h to object 6060h to select Cyclic Synchronous Velocity Mode.

2. Set target velocity: Write 0 to object 60FFh (target velocity). Reason: In velocity mode, the servo motor starts rotating immediately upon entering Servo On state (Step 3). Setting the velocity to 0 ensures the motor remains at 0 RPM and does not move when Servo On is activated.

3. Set control command: Write to object 6040h (Control Word) following these sub-steps. Note: Steps 3.1 and 3.2 are performed to transition the drive's state machine into the ready state.

Steps: Bit 4 Bit 3 Bit 3 Bit 2 Bit 0 Description
3.1 0 0 1 1 0 Shutdown
3.2 0 0 1 1 1 Switch on ( Servo On )
3.3 0 1 1 1 1 Enable Operation (Servo On)

4. Write the desired target velocity value to object 60FFh.

Performance Indicators:

① Stress Test (6 hours)

stress -c 4 --io 2 --vm 1 --vm-bytes 256M --timeout 1000000s&
./igh_ethercat_motor_csv

Cycle Time (μs) Minimum Cycle Time (μs) Maximum Cycle Time (μs) Maximum Cycle Jitter (μs)
1000 996.954 1003.262 6.308

Cycle Jitter Sample Count Percentage
[-3.0460,-1.7844) 408 0.94%
[-1.7844,-0.5228) 16691 38.64%
[-0.5228,0.7388) 9040 20.93%
[0.7388,2.0004) 16898 39.12%
[2.0004,3.2620] 163 0.38%
[-1.6970,1.6970] 41054 95.03%

② Isolation Test + CPU (6 hours)

stress -c 4 --io 2 --vm 1 --vm-bytes 256M --timeout 1000000s &
taskset -c 7 ./igh_ethercat_motor_csv

Cycle Time (μs) Minimum Cycle Time (μs) Maximum Cycle Time (μs) Maximum Cycle Jitter (μs)
1000 998.315 1001.894 3.579

Cycle Jitter (µs) Sample Count Percentage
[-1.6850, -0.9692) 3309 0.076597
[-0.9692, -0.2534) 13227 0.306181
[-0.2534, 0.4624) 10747 0.248773
[0.4624, 1.1782) 13353 0.309097
[1.1782, 1.8940] 2564 0.059352
[-1.2100, 1.2100] 41044 0.950093

Demo 2: Cyclic Synchronous Torque Mode (125µs)

In this mode, the upper-level controller periodically sends the pre-calculated target torque (object 6071h) to the servo drive. Torque regulation is executed internally by the servo. When the speed reaches the limit value, the system will enter the speed regulation phase.

Basic Configuration:

RPDO TPDO Remarks
6040: Control Word 6041: Status Word Mandatory
6071: Target torque Mandatory
6064: Position actual value Optional
606C: Velocity actual value Optional
6077: Torque actual value Optional
6060: Modes of operation 6061: Modes of operation display Optional

PDO information output via EtherCAT debugging tool:

Real-Time Control on Linux: Preempt-RT + IgH EtherCAT Master on OK3576-C

Operation Steps:

Step 1: Set Mode - Set object 6060h to 0Ah to select Cyclic Synchronous Torque Mode.

Step 2: Set Target Torque - Set object 6071h to 0 (zero torque). Reason: In torque mode, the target torque takes effect immediately upon entering Servo On state (Step 3). Setting torque to zero ensures safety during initialization.

3. Set control command: Write to object 6040h (Control Word) following these sub-steps. Note: Steps 3.1 and 3.2 are performed to transition the drive's state machine into the ready state.

Steps: Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Description
3.1 0 0 1 1 0 Shutdown
3.2 0 0 1 1 1 Switch on ( Servo On )
3.3 0 1 1 1 1 Enable Operation (Servo On)

Step 4: Set the target torque OD 6071h.

Performance Indicators:

① Stress Test (6 hours)

stress -c 4 --io 2 --vm 1 --vm-bytes 256M --timeout 1000000s&
./igh_ethercat_motor_cst

Cycle Time (μs) Minimum Cycle Time (μs) Maximum Cycle Time (μs) Maximum Cycle Jitter (μs)
125 99.851 149.898 50.047

Cycle Jitter Sample Count Percentage
[-25.1490,-15.1396) 8 0.000185
[-15.1396,-5.1302) 477 0.011042
[-5.1302,4.8792) 42208 0.977037
[4.8792,14.8886) 495 0.011458
[14.8886,24.8980] 12 0.000278
[-3.0940,3.0940] 41040 0.95

② Pressure Test + CPU (6 hours)

stress -c 4 --io 2 --vm 1 --vm-bytes 256M --timeout 1000000s &
taskset -c 7 ./igh_ethercat_motor_cst

Cycle Time (μs) Minimum Cycle Time (μs) Maximum Cycle Time (μs) Maximum Cycle Jitter (μs)
125 123.955 126.068 2.113

Cycle Jitter Sample Count Percentage
[-1.0450,-0.6224) 654 0.015139
[-0.6224,-0.1998) 20946 0.484861
[-0.1998,0.2228) 0 0
[0.2228,0.6454) 20934 0.484583
[0.6454,1.0680] 666 0.015417
[-0.5970,0.5970] 41066 0.950602

In the performance tests described above, data frames that were not received within the expected cycle time were excluded from the period statistics. This situation occurs more frequently when running the 125 µs cycle mode.

For both demonstration modes, the application was configured with FIFO scheduling and memory locking. The system's cycle jitter was significantly reduced when employing the CPU isolation (pinning) strategy.

In cycle synchronous velocity mode, cycle jitter was reduced from 6.3080 μs to 3.5790 μs.

In cycle synchronous torque mode, cycle jitter was reduced from 50.0470 μs to 2.1130 μs.

Real-Time Control on Linux: Preempt-RT + IgH EtherCAT Master on OK3576-C




Contact Sales Team

Our sales team will connect you with FAE engineers for one-on-one technical support.

Talk to Our Engineers

Get a Quote

Get pricing and project evaluation support from our team.

Request a Quote

Apply for Samples

Submit your request to receive product samples for evaluation.

Get Samples

Join Facebook Group

Get Forlinx technical updates and hands-on sharing from our experts.

Join Now