Developing Compact and Powerful EtherCAT Controllers with acontis EC-Master on the NVIDIA Jetson Orin Nano
Content
- Introduction
- Setting up Linux on the NVIDIA Jetson Orin Nano Development Kit
- Installing the Linux Real-time Kernel
- Configuring the Linux Kernel
- Setting Up EC-Master with Linux Network Driver
- Setting Up EC-Master with acontis Real-time Ethernet Network Driver
- Enabling Motion Control with EC-Motion
- Conclusion
Introduction
The NVIDIA Jetson Orin Nano is among the latest in NVIDIA 's lineup of powerful, compact AI and edge computing devices. This article provides a comprehensive guide to setting up and optimizing high-performance EtherCAT controllers using the NVIDIA Jetson Orin Nano, leveraging the capabilities of acontis' EC-Master software – enabling the next step in mobile robotics and many other applications! You will learn how to set up the board for real-time Linux, configure the Linux kernel for optimal performance, and integrate the atemsys kernel module for best network performance.
We are also going to show you how to start the example application for Distributed Clocks, EcMasterDemoDc, and have a detailed look at the results from our performance tests showing the vast differences between a simple, and an EtherCAT-optimized system setup. Finally, we will take a look at how to set up and run the example application for motion control, EcMasterDemoMotion, on the Jetson Device using EC-Engineer to demonstrate the benefits of EtherCAT for motion control.
This blog is split into the following segments:
- Setting up Linux on the NVIDIA Jetson Orin Nano and installing the real-time kernel
- Optimizing the real-time kernel settings
- Setting up EC-Master with SockRAW
- Setting up EC-Master with acontis real-time drivers
- Understanding the performance measurements and the significant benefits of acontis’ real-time drivers
- Enabling motion control with acontis’ EC-Motion
Setting Up Linux on the NVIDIA Jetson Orin Nano Development Kit
Depending on which JetPack version you have installed, the installation process for the real-time kernel may vary. Here we will use the JetPack 6.0, which includes NVIDIA's Jetson Linux 36. For other implementations using other JetPack versions the installation and optimization settings of the real-time kernel may differ. For more information, refer to the Jetson Linux Documentation Archive for your specific JetPack SDK and Jetson Linux version. Search for real-time, and you'll find detailed instructions for installing the appropriate real-time kernel for your Jetson Linux version.
Installing the Linux Real-time Kernel
For applications requiring precise timing and deterministic responses, integrating a real-time kernel is essential. To install the real-time kernel, we have to edit the nvidia -l4t-apt-source.list file.
Open it for editing using the following command:
$ sudo nano /etc/apt/sources.list.d/nvidia -l4t-apt-source.list
Then add the following line, save, and close the file:
deb https://repo.download.nvidia .com/jetson/rt-kernel r36.3 main
Finally, run these commands to update and install the required packages for the real-time kernel:
$ sudo apt update
$ sudo apt install nvidia -l4t-rt-kernel nvidia -l4t-rt-kernel-headers nvidia -l4t-rt-kernel-oot-modules nvidia -l4t-display-rt-kernel
After a successful installation, you'll need to reboot the system. On the boot screen you will be able to see updated boot options and confirm that real-time kernel was successfully installed.
Figure 1: Boot process NVIDIA Board
Configuring the Linux Kernel
To achieve the best performance for real-time communication with EtherCAT, some kernel settings require adjustment. This is accomplished by editing the file containing the kernel configuration settings:
$ sudo nano /boot/extlinux/etxlinux.conf
Add the following kernel boot parameters to the real-time kernel configuration, which includes settings to deactivate power saving and CPU throttling, as well as blacklisting the Ethernet port used for EtherCAT to avoid access by other tools and drivers:
modprobe.blacklist=r8168 cpuidle.off=1 cpufreq.off=1 processor_idle.max_cstate=0 processor.max_cstate=0 nohz_full=3 isolcpus=3 rcu_nocbs=3 rcupdate.rcu_cpu_stall_suppress=1 nohz=off rcu_nocb_poll idle=poll irqaffinity=0
After adding this, save the file, exit nano, and restart the system. After the system has rebooted, check to confirm the parameters were added to the kernel configuration:
$ cat /proc/cmdline
For more information about the kernel parameters, please check out our article about setting up Ubuntu Linux 22.04 for Real-time Performance with EtherCAT.
Setting Up EC-Master with Linux Network Driver
The acontis EC-Master software stack communicates with SubDevices by exchanging EtherCAT frames via a standard Ethernet network adapter (MAC). Linux network drivers support various adapters and provide a raw socket interface (SOCK_RAW) for applications that send/receive Ethernet frames, like EC-Master. However, performance may be poor, and real-time constraints are hard to maintain due to the unoptimized Linux network stack and driver code. To show the significant difference in performance between the raw socket interface and the acontis real-time driver, we will first use SOCK_RAW and do some performance measurements.
Figure 2: System Block Diagram using sockraw
The acontis EtherCAT Class A example application “EcMasterDemoDc” relies on an EtherCAT Network Information (ENI) file that provides the EtherCAT network configuration to EC-Master, so we'll need to create one first. ENI files can be generated with an application such as acontis' EC-Engineer. After creating the ENI file eni.xml, copy this file to the Jetson device where we will run the “EcMasterDemoDc” with the SOCK_RAW Ethernet interface using the “libemllSockRaw.so” library which is included with EC-Master.
Now we are able to start the EcMasterDemoDc application with the following command line parameters:
$ sudo ./EcMasterDemoDc -f eni.xml -sockraw eth0 1 -v 4 -a 3
It is important to note that you must specify your network interface after the -sockraw parameter. In our case it is eth0. For more information about the example application and the command line parameters, please see the EC-Master User Manual in our Developer Center.
At this point, you have successfully started an EtherCAT MainDevice on the Jetson Orin Nano!
Measurement 1: Real-time kernel using sockraw
In order to perform a performance test, we use the built-in performance measurement capability included with the EcMasterDemoDc example application by executing this command (note the -perf command line parameter):
$sudo ./EcMasterDemoDc -f eni.xml-sockraw eth0 1 -v 4 -a 3 -t 3600000 -perf -dcmlog
This provides the following performance measurement results for our system:
Description |
Min [us] |
Avg [us] |
Max [us] |
Cycle Time |
991.7 |
1000.0 |
1012.7 |
Task Duration (EC-Master CPU load + App load) |
12.4 |
18.5 |
207.7 |
EC-Master CPU load |
10.8 |
16.7 |
205.0 |
App duration=load |
0.1 |
0.2 |
1.7 |
The chart shows the min and max values around the average, which indicate the jitter for those measurements. The jitter values for the cycle time and EC-Master execution time are just a rough indicator for the much more important value: the jitter of the cyclic frame that is transporting the process data.
Especially for motion control and robotics applications, it is mandatory that the cyclic frame always arrives at all SubDevices before the DC Sync signal occurs.
The EcMasterDemoDc application is able to create a log file containing the network time (register 0x910 of the DC reference clock), which is the time returned in every cyclic frame and has a nanosecond resolution. In an ideal world, the EtherCAT MainDevice software will transmit the cycle frame every cycle time, and the network time will be incremented by the same value (for example, every 1 ms cycle the network time increases by 1,000,000 nanoseconds). In a real-world application, however, the jitter caused by the operating system, the EC-Master software, the Linux stack, and the hardware will result in an increase of the network time that does not exactly match the cycle time. Looking at the differences in these values the real jitter of the cyclic frame can be easily determined.
Figure 3: Cyclic frame jitter using sockraw
In this chart we can see that the average latency looks good and indicates good performance, the more important measurements are the peaks that occur on a regular basis. These peaks generate large delays that can lead to lost EtherCAT frames which can lead to stability issues in the EtherCAT communications and significantly impact the overall system performance.
This chart is based on the column “CtlErr [ns]” in the dcmlog file. The file is created when the command line parameter -dcmlog is used.
Measurement 2: Real-time kernel using sockraw with CPU and network loads
For further real-world scenarios, we also did performance tests when adding in additional CPU load from applications outside of EC-Master, along with additional network (TCP/IP) load on a second network interface.
For the CPU load we used stress-ng, which is a tool that can simulate high workloads. This tool can push various hardware components—like the CPU, memory, disk, and I/O—to their limits. Before starting EcMasterDemoDc, we started stress-ng to generate high loads on the CPU, using this command:
$ stress-ng --cpu 3 --taskset 0-2 --copy-file 1 --timeout 4000s -l 30
The --taskset parameter specifies which CPU core is being stressed. In our test case we ran this on all cores except the core running the EtherCAT application EcMasterDemoDc.
For the TCP/IP network load we first had to add a second network interface since the Jetson Orin Nano only has one accessible Ethernet port. So we used a USB-Ethernet adapter, and for the load we used the tool nping with the following parameters:
$ nping --rate 500 --data-length 2000 172.17.10.120 -c 10000000
Note: 172.17.10.120 is the IP address of the second Ethernet port on our Jetson Orin Nano
This measurement, with stress-ng and nping running, yielded the following results:
Description |
Min [us] |
Avg [us] |
Max [us] |
Cycle Time |
988.6 |
1000.0 |
1012.9 |
Task duration (EC-Master CPU load + App load) |
13.0 |
16.7 |
253.6 |
EC-Master CPU load |
11.3 |
15.2 |
251.2 |
App duration=load |
0.1 |
0.2 |
2.0 |
Figure 4: Cyclic frame jitter using sockraw with load
As with the first measurement without CPU and network load, the most critical measurements are the very large peaks, which can have severe effects on the machine or robot.
Setting Up EC-Master with acontis Real-time Ethernet Network Driver
The acontis Real-time Driver is a replacement for the standard Linux Ethernet network adapter (MAC) driver that is optimized for implementing real-time EtherCAT applications. The driver runs in User Space and controls the MAC directly for a high-performance cyclic operation. The driver requires direct access to the MAC hardware and this is achieved by using the acontis atemsys Linux kernel module that is licensed under GPL. The atemsys kernel module is included with EC-Master and also available on acontis' GitHub page.
Figure 5: System Block Diagram using atemsys and real-time driver
Setting up atemsys kernel module
To setup the atemsys kernel module, the first step is to clone the git repository from http://github.com/acontis/atemsys.git. Once the repository is cloned, navigate to the directory and build the modules by running the command:
$ make modules
This will generate the atemsys.ko file, which we will need to load atemsys into the kernel. We can load it using the following command:
$ insmod atemsys.ko
After inserting the kernel module, we now have direct hardware access, enabling enhanced performance when using the acontis Real-time Ethernet Drivers.
Measurement 3: Real-time kernel using acontis real-time Ethernet driver
With the direct hardware access provided by using atemsys, we will now run additional performance tests using the acontis real-time driver for the Jetson Orin’s embedded Ethernet controller – a Realtek 8169. Since the acontis real-time drivers offer much lower latency and jitter (as we will see), we will also increase the EtherCAT cycle time by a factor of 4, resulting in a EtherCAT cycle time of only 250 microseconds (4 kHz).
To start EcMasterDemoDc with the acontis real-time driver for the Realtek 8169 with a 250 µs cycle time, we use this command:
$ sudo ./EcMasterDemoDc -f eni.xml -rtl8169 1 1 -v 4 -a 3 -b 250 -t 3600000 -perf -dcmlog
Let’s have a look at the results of this test:
Description |
Min [us] |
Avg [us] |
Max [us] |
Cycle Time |
238.6 |
250.0 |
264.1 |
Task duration (EC-Master CPU load + App load) |
10.1 |
11.3 |
30.5 |
EC-Master CPU load |
8.7 |
9.9 |
26.5 |
App duration |
0.1 |
0.2 |
0.7 |
Figure 6: Cyclic frame jitter using acontis real-time driver
In addition to the reduction of the average latency, the most impressive result is the nearly complete elimination of the latency peaks. Eliminating these latency peaks by using the acontis real-time driver enables a much faster and, more importantly, more reliable EtherCAT system operation.
Measurement 4: Real-time kernel using acontis real-time Ethernet driver with CPU and network loads
In a fourth test, we add the same CPU and network loads from measurement 2, yielding the following results:
Description |
Min [us] |
Avg [us] |
Max [us] |
Cycle Time |
237.8 |
250.0 |
266.1 |
Task duration (EC-Master CPU load + App load) |
10.1 |
11.6 |
31.6 |
EC-Master CPU load |
8.9 |
10.0 |
27.1 |
App duration |
0.1 |
0.2 |
2.0 |
Figure 7: Cyclic frame jitter using acontis real-time driver with load
Even with the CPU and network loads added to the NVIDIA Jetson Orin, the performance using acontis real-time drivers eliminates the extreme latency peaks. This enables a safe, high-speed, high-performance EtherCAT implementation required in many applications such as multi-axis motion control used in robotics.
Enabling Motion Control with EC-Motion
So far, we have used a simple demo application that exchanges data with simple EtherCAT SubDevices like I/O and similar devices. Still, EtherCAT offers many benefits for motion control – and the NVIDIA Jetson Orin Nano provides significant resources for calculating all motion-relevant control data. With acontis' EC-Motion EtherCAT Motion Control library, the complexity involved in programming motion control applications is reduced to a minimum – as EC-Motion provides a range of functions to calculate trajectories for motion control applications.
The block diagram below shows the overall software architecture and data exchange between EC-Master running on the Jetson Orin Nano using the Real-Time Ethernet Driver. EC-Motion is part of the EtherCAT application. We will leverage the convenience of the acontis RAS Server (remote access via TCP) to connect EC-Engineer directly to EC-Master to monitor the EtherCAT network and SubDevices and even to control the devices.
Figure 8: System Architecture of EC-Engineer and EC-Master using RAS
Running EC-Motion involves a few steps as shown below:
To start with, we connect our NVIDIA Jetson device with some EtherCAT drives on the EtherCAT network. We first run the EcMasterDemoDc application with the acontis real-time Ethernet driver using the following command:
$ sudo ./EcMasterDemoDc -v 3 -rtl8169 1 1 -sp -t 0
We use the -sp parameter to start the RAS Server, enabling us to connect with EC-Engineer using a remote TCP connection. In EC-Engineer, we export the ENI file by clicking on “Export ENI”. After that, we activate the Motion Tab in the main menu: Click on View and check Motion mode. The Motion Tab will now appear on the right side of the interface.
Figure 9: Motion Mode activated
Now we are able to export the EC-Motion configuration (DemoConfig.xml) required for the EcMasterDemoMotion example application we will run later. For the motion configuration we have to specify our real-time Ethernet Driver – in this case, the rtl8169 for the Realtek 8169. We will also change the verbosity level and provide the path to the ENI file on the NVIDIA Jetson Orin device where we will later run the EcMasterDemoMotion example application.
Figure 10: EC-Engineer DemoConfig.xml in Motion Tab
Before running the EcMasterDemoMotion we have to place the DemoConfig.xml in the appropriate directory alongside the EcMasterDemoMotion, together with the generated ENI file and the specific link layer we are using. After that, we execute the following command:
$ sudo ./EcMasterDemoMotion DemoConfig.xml
Once EC-Master with the EC-Motion demo is started, we can reconnect EC-Engineer remotely. By switching to Diagnosis Mode in EC-Engineer, we gain control of the drive from the Motion Tab. To start the motor, we need to choose an axis index and click the button to “Power-On”. Now the drive is enabled and we can rotate the motor by pressing the Move Relative button – this is how easy it is to control on your drives with acontis' EC-Motion and EC-Engineer!
Figure 11: Control drives and move motors from EC-Engineer's Motion Tab
Conclusion
Combining the computational prowess of the NVIDIA Jetson Orin nano with acontis' EC-Master software and real-time Ethernet drivers results in a compact, efficient, and high-performance EtherCAT controller for challenging high-speed applications with fast cycle times. In order to leverage this computing power and achieve the best results for these demanding EtherCAT applications, it is crucial to install and choose the right settings for the real-time Linux kernel and to use real-time capable Ethernet drivers.
The real-time Linux kernel with appropriate kernel configuration results in a stable and precise cyclic task with very low jitter to that is unaffected by other applications that add CPU load. While the standard Linux network interface driver offers simplicity and broad support, the performance suffers and results in large amounts of latency and jitter that leads to unpredictable delays in the EtherCAT application. This issue is exacerbated when additional network interfaces (Ethernet and Wi-Fi) are active besides the one used for EtherCAT.
Using acontis' EtherCAT MainDevice software EC-Master with the acontis real-time Ethernet drivers running in NVIDIA's Jetson Linux with real-time kernel on the NVIDIA Jetson Orin Nano provides outstanding performance, allowing stable cycle times of 250 microseconds or less with very low timing jitter. By leveraging EtherCAT's Distributed Clocks feature, the synchronization of the complete EtherCAT network can be achieved down to the nanosecond range. All of this combined to meet the highest demands of motion control and robotic applications.