26
ADI | Engineering a More Sustainable Future
Software
The software code is available for download: Remote Motion
Control with 10Base-T1L Ethernet - Code.
To keep the code lightweight and minimize communication
overhead, no standard communications protocols were
implemented above the data link layer. All the messages are
exchanged using the payload field of Ethernet frames with
a predefined fixed format. Data is organized into 46-byte
segments, composed of a 2-byte fixed header and a 44-byte
data field. The header includes an 8-bit device type field,
which determines how received data is processed, along with
an 8-bit device ID field, which enables the selection of an
individual physical device if more devices of the same type
are present.
The host interface is written in Python to ensure compatibility
with both Windows and Linux hosts. Ethernet communication
is managed using the Scapy module, which allows creating,
sending, receiving, and manipulating packets at each layer of
the stack, including the Ethernet data link. Each device type
defined in the protocol has a corresponding class that includes
properties to store data to exchange, and a set of methods
that can be used to modify these properties instead of having
to directly edit the variables. For example, to change motion
direction in speed mode for the motion controller, methods
"setDirectionCW()" and "setDirectionCCW()" are defined, instead
of having to manually assign 0 or 1 values to the direction flag.
Each class also includes a "packSegment()" method that packs
and returns the segment corresponding to the controlled
device in the form of an array of bytes according to the
predefined format for the considered device type.
Firmware is written in C using the ChibiOS environment,
which includes, among other tools, a real-time operating system
(RTOS), a hardware abstraction layer (HAL), and peripheral
drivers, allowing the code to be easily ported between similar
microcontrollers. The project is based on three custom modules:
Figure 2: EVAL-ADIN1110, EVAL-ADIN11X0EBZ, and TMC5160 shield assembled.
2
Figure 3: Communication protocol format.
3
Adobe Stock / Monsitj – stock.adobe.com