Raghu - Rajappa MasterThesis Report
Raghu - Rajappa MasterThesis Report
MASTER
Rajappa, Raghu
Award date:
2017
Link to publication
Disclaimer
This document contains a student thesis (bachelor's or master's), as authored by a student at Eindhoven University of Technology. Student
theses are made available in the TU/e repository upon obtaining the required degree. The grade received is not published on the document
as presented in the repository. The required complexity or quality of research of student theses may vary by program, and the required
minimum study period may vary in duration.
General rights
Copyright and moral rights for the publications made accessible in the public portal are retained by the authors and/or other copyright owners
and it is a condition of accessing publications that users recognise and abide by the legal requirements associated with these rights.
• Users may download and print one copy of any publication from the public portal for the purpose of private study or research.
• You may not further distribute the material or use it for any profit-making activity or commercial gain
Department of Mathematics and Computer Science
Electronics Systems Group
Investigation of
EtherCAT for the
Motion Building
Blocks
Master Thesis
Raghu Rajappa
Supervisors:
Nabi Najafabadi, M.
[Link] [Link]
Laurens van de Laar
Nico Meijerman
1.0 version
I, Raghu Rajappa, declare that this thesis titled, “Investigation of EtherCAT for theMo-
tion BuildingBlocks” and the work presented in it are my own. I confirm that:
• This work was done wholly while in candidature for the [Link]. degree at Eindhoven
5 University of Technology.
• I have clearly attributed every instance at which I have consulted the published work
of others.
• Where I have quoted from the work of others, the source is always given. With the
exception of such quotations, this thesis is entirely my own work.
The citation conventions usual to the discipline in question here have been respected.
Throughout this report, as a personal choice, I have used a third-person writing approach,
hence using we instead of I from here on. This written work may be tested electronically
for plagiarism.
15
Signed:
Date:
20 This thesis project is done at NTS-Group, a high tech company which specializes in
low to medium-volume, high-complexity industrial systems. One area of focus at NTS is
industrial automation with precision motion control. The setup of these complex systems
usually include master-slaves. This thesis project is specifically about the communication
interface between the master and slaves.
25 Since over a decade, NTS-Group has been using proprietary communication protocols
for their complex systems. For the communication from master to slave, they use Unit
Communication Protocol (UCP) and for communication amongst the slaves, they use a
hard real-time protocol called Real Time Data Networks (RTDN). Both these protocols
are asynchronous serial communication protocols using the CAN bus hardware layer. Until
30 now, this communication has been sufficient. As the company foresees the systems getting
more complex, some of RTDN’s shortcomings are becoming apparent. These shortcomings
include limited baud rate, limited physical bus length of CAN, portability constraints
and limited payload size. The thesis project was done primarily to investigate an alternate
communication protocol called EtherCAT and to explore control system architectures with
35 the ethercat performance results.
This project includes several phases. The first is phase has been identification, design,
implementation and testing a master-slave system communicating over EtherCAT. With
a successful implementation of and testing, which also included three slaves (scalability
test), we can now extract performance metrics.
40 The second phase includes synchronization of the distributed clocks across the slaves
and the master for synchronized actions and also for synchronized timestamps. The per-
formance analysis helps us understand the advantages and limitation of EtherCAT. The
biggest advantage includes ten fold improvement in performance of EtherCAT over the
CAN based protocols. And contrary to initial assumptions, the bottleneck has been the
45 system latency at the master side and not the slave ethercat implementation done in the
project.
The third phase of the project was to investigate whether a centralized control architec-
ture over EtherCAT is feasible for high precision motion control. This includes developing
and integrating MATLAB/Simulink into the TwinCAT (master) and running control al-
50 gorithm at the master (centralized) instead of at the slaves (de-centralized or distributed).
It has been observed that with a large delay in the control loop (for the setup), a centralized
architecture is not yet feasible for high precision control.
I would like to thank NTS Systems development, part of the NTS-Group, because
60 without them I would not have had this opportunity to do this project.
I would like to also express my sincere gratitude to those who helped and supported
me during this master thesis work. In particular, I would like to thank Nabi Najafabadi,
M., Laurens van de Laar, Reinder J. Bril, Nico Meijerman, Sohan Walimbe, Marco van
Nieuwenhoven for their extensive support with helping make this project a success.
65 There are many others who I would like to thank, including Bart Verkoeijen, Patrick
van der Mijden, Mike Curvers, Bert de Swart, Alessandro Figini, Santosh Athur, Garbi
Singla Lezcano, Ferry Schoenmakers, for helping me, at the drop of a hat, with several
questions about TwinCAT, Texas Instrument’s controller, ethercat protocol and general
implementation.
Contents vi
List of Tables xi
1 Introduction 1
75 2 Background 4
2.1 Unit Communication Protocol (UCP) . . . . . . . . . . . . . . . . . . . . . 5
2.1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.1.2 UCP Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.1.3 Significance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
80 2.2 Real-Time Data Networks (RTDN)? . . . . . . . . . . . . . . . . . . . . . 7
2.2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2.2 Operating Principle . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.2.3 Significance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.3 EtherCAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
85 2.3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.3.2 Operating Principle . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.3.3 Significance of EtherCAT for industrial control application . . . . . 13
2.3.4 CANopen over EtherCAT . . . . . . . . . . . . . . . . . . . . . . . 14
2.4 Synchronization - Distributed Clocks (DC) . . . . . . . . . . . . . . . . . . 18
90 2.4.1 Operating Principle . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.5 Serial Peripheral Interface (SPI) . . . . . . . . . . . . . . . . . . . . . . . . 21
2.5.1 Operating Principle . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3 Design 23
3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
95 3.2 Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.3 EtherCAT system design overview . . . . . . . . . . . . . . . . . . . . . . . 24
3.4 The Master . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.4.1 TwinCAT 3.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.4.2 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
100 3.4.3 Simulink Integration . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.4.4 PLC program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.5 The Slave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.5.1 EtherCAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.5.2 SPI Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
105 4 Implementation 44
4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
4.2 Slave Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
4.2.1 EtherCAT slave software . . . . . . . . . . . . . . . . . . . . . . . . 45
4.2.2 Serial Peripheral Interface . . . . . . . . . . . . . . . . . . . . . . . 52
110 4.3 ESC description file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Bibliography 80
3.1 High level EtherCAT master-slave design. The PC is the master and the
165 ESC along with the proprietary Motion Building Block (MBB), together
make up the slave. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.2 A master-slave ethercat system with the implemented components indicated
in green. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.3 EtherCAT master-slave system setup at the company. It consists of a Beck-
170 hoff drive that works as another slave and is used as a drive control. . . . . 26
3.4 EtherCAT Slave Information contains mandatory and optionally specified
information about the slave. This information is given as input to TwinCAT
to be parsed and stored. [10] . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.5 Simulink model integrated into TwinCAT. [11].This is not an image of our
175 own PI controller. The reason being because of the use of trial licence of
TwinCAT, the visualization is not available. . . . . . . . . . . . . . . . . . 28
3.6 Integrating Simulink within TwinCAT . . . . . . . . . . . . . . . . . . . . 29
3.7 PLC program, integrated in TwinCAT, to log data . . . . . . . . . . . . . 30
3.8 Beckhoff’s piggyback controller FB1111-014x[12] . . . . . . . . . . . . . . . 31
180 3.9 EtherCAT Slave including the Motion Building Block board (consists of
Texas Instrument’s DSP) and the Beckhoff’s piggyback ASIC which handles
the ethercat communication- also called Ethercat slave controller. . . . . . 32
3.10 Process of configuring Ethercat Slave Controller (ESC), as per the require-
ments. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
185 3.11 EtherCAT state machine [13] . . . . . . . . . . . . . . . . . . . . . . . . . 34
3.12 Actions/Tasks to be performed, at the slave, during the state transition. All
other (not indicated in the figure) state transitions are invalid and lead to
updating the error register with the appropriate invalid state transition error. 35
3.13 EtherCAT slave Init state necessary implementation. . . . . . . . . . . . . 36
190 3.14 Actions performed during EtherCAT slave Pre-Op state. . . . . . . . . . . 37
3.15 Actions/Tasks performed during EtherCAT slave Safe-Op state. . . . . . . 38
3.16 Actions/Tasks performed during EtherCAT slave Op state. This is when
the slave is fully operational . . . . . . . . . . . . . . . . . . . . . . . . . . 38
3.17 SPI interface hardware connections between the ESC and the TI DSP . . . 39
195 3.18 SPI interface hardware connections between the ESC and the MBB . . . . 40
3.19 SPI write/read state machine. . . . . . . . . . . . . . . . . . . . . . . . . . 41
3.20 SPI Read sequence diagram. . . . . . . . . . . . . . . . . . . . . . . . . . . 42
3.21 SPI Write sequence diagram. . . . . . . . . . . . . . . . . . . . . . . . . . . 43
4.1 The master and the MBB accessing the ESC through EtherCAT and SPI. 45
200 4.2 The flow diagram shows the ethercat slave software sequence. . . . . . . . . 46
4.3 Cyclic SYNC signal from the ESC to MBB. The SYNC signal is generated
using the precise DC clock of the ESC. . . . . . . . . . . . . . . . . . . . . 51
4.4 Packing of three variables of different lengths (for TI, default length is 16 bit). 52
4.5 SPI frame with a maximum of 12 characters of SPI data (and 4 characters
205 of SPI header), at a time. . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
4.6 ESC description files (.xml and .c) are programmed to the master, ESC and
slave for uniform ethercat communication. . . . . . . . . . . . . . . . . . . 56
4.7 SOES configuration tool used to generate the ESC description file. . . . . . 57
4.8 SOES configuration tool showing the configurable settings and the CAN-
210 open’s Object dictionary way of description. . . . . . . . . . . . . . . . . . 57
5.1 The count of clock deviations (positive and negative deviations) and the
value in µs with respect to the reference clock. . . . . . . . . . . . . . . . . 63
5.2 The three control architectures and their performance across the various
metrics. Green indicates the best of the three, while Yellow indicates a
245 moderate performance and Orange stands for a poor performance of the
metric. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Introduction
300 consists of information of the various technologies learnt to implement the system. These
technologies include the existing RTDN and UCP communication, EtherCAT, CANopen
over EtherCAT, Disctributed Clock Synchronization and Serial Peripheral Interface.
”Design” chapter lists the generic requirements for the project and the design of in-
dividual software components that make up the EtherCAT based master-slave system.
305 The ”Implementation” chapter describes the implementation of the new EtherCAT based
system and some of the difficulties faced during the implementation.
”Performance Evaluation and Analysis” chapter describes the research goals, the pro-
cess involved in extracting the required data and the analysis of the data to map the
performance of the new system. It also includes the study of the centralized control sys-
310 tem and extending that to the comparison of the control architectures while proposing a
new control architecture. The ”Conclusions” chapter speaks about the conclusions drawn
from the project and how the project can be taken forward for future implementation.
Background
315 Several concepts learnt, to implement this project are introduced in this chapter. The
master-slave setup, currently in use at the company, is shown in Figure 2.1. The figure
shows the communication between the master and slaves - Unit Communication Protocol
(UCP) as well as the communication amongst the slaves - Real Time Data Networks
(RTDN) which adheres to hard-real time constraints. Sections 2.1 and 2.2 describe the
320 existing proprietary communication protocols used by NTS-Group and the source of in-
formation is the NTS internal documentation.
Figure 2.1: Existing master-slave network using UCP and RTDN communication
Figure 2.2: The UCP tasks and interface layers in the software as related to the OSI
model [1].
Figure 2.3: The UCP structure shown for an example segment of 29 bytes length.
2.1.3 Significance
The advantages and the limitation of the UCP protocol, hence leading to the imple-
350 mentation of EtherCAT, are as follows.
Advantages
• Reusability - suitable logical units, interfaces and tasks can be reused for slaves(units).
This helps in quickly scaling the software.
• Hardware independence - UCP can be used over CAN, TCP/IP, or even EtherCAT.
355 • Platform neutral way of describing - The physical unit, logical units, interfaces and
tasks are described using XML.
Disadvantages
• Interoperability - Every new sub-system needs to be modified to be operable with the
existing NTS systems because the new sub-systems may not be able to understand
360 UCP. This increases development costs for NTS.
• Proprietary - UCP is NTS-Group proprietary protocol which does not yet have a
widespread acceptance and standardization. This increases the developmental and
maintenance costs when working with newer more complex systems.
• Larger payload - As the systems at NTS-Group get more complex, the data logging,
365 analysis and diagnostic need more data increasing the payload sizes of messages. At
the moment even though in theory the payload is not limited, in practise to restrict
one ID taking up more time within the CAN network, the payload size of a messsage
is restricted to maximum of 128 bytes.
1
The CAN data link or application layer is not used, instead a custom protocol is used.
Since RTDN uses the CAN transceiver, the basic working of the protocol has similarities
with CAN protocol. These include:
Apart from these similarities, it is useful to know that the RTDN protocol follows the non
destructive bit-wise arbitration principle to keep the real-time constraints or in a scenario
where the RTDN is out of sync. The RTDN message format is shown in Figure2.5, and
390 the fields within this message are explained in Table2.1.
An interesting observation here is that this format is very similar to EtherCAT’s mes-
sage format which consists of a header and logical windows pre-configured for each slave
device based on the number of inputs/outputs each slave devices requests2 . Each byte3 in
an RTDN message is formatted as shown in Figure 2.6.
0 9 19 29 39 49 59 69 75
Figure 2.5: RTDN message format. Each message includes a frame (message ID). Each
Window represents pre-configured length of data for each device.
0 1 2 3 4 5 6 7 8 9
Figure 2.6: Each RTDN byte consists of a start and stop bit along with the data.
2
Request is made through the configuration file for the slave device, hence at compile time the window
size is allocated, to all slave devices in the network, by the master
3
Each RTDN byte consists of 10 bits instead of the standard definition of byte which is 8 bits
This byte indicates the start of a new RTDN frame along with an iden-
tifier for the frame. The maximum number of frames is 8. The frame
#Frame number will have a duplicate contents in the upper and lower nibble of
the byte:
Frame 1: 0x11 . . . Frame 8: 0x88
Communication window. A node has its own communication window
inside a RTDN frame transfer. This window contains one ore more data
bytes that will be published on the bus, and will be monitored by all
other nodes. The communication window content is application specific
WindowX and may also vary between different frames numbers.
Each node will know when it may publish its communication window
on the bus. It will also know exactly what information other nodes will
publish. A node will monitor its data on the bus and detect if the data
is published correctly.
A 16-bit CRC checksum calculated over all previous data, #frame and
window data, by the master. The #frame byte is used as ‘seed’ for the
CRC
CRC calculation. To uniquely identify the CRC checksum, the multi-
processor bit in the second CRC byte (LSB byte) will be set
395 The RTDN message will be built up in byte-frames. The master will start this frame
by transmitting the frame number. Thereafter the master will publish its data window on
the bus (Window 1). After that the next slave will publish its data window on the bus
(Window 2) and so on, until all slaves have published their data (up to Window N). From
there the master will take over again and write a two-byte CRC checksum to the bus.
400 When an RTDN transfer fails for whatever reason, the frame is ignored. It is important
that all nodes ignore the received data, although they may have received all data correctly.
This way all nodes will work with exactly the same information. A failed RTDN transfer
will be retried. The frame number is not incremented and the frame will be re-transmitted
with the most recent application data.
410 Advantages
• Real time - RTDN is real time in nature. This is essential for precison motion control.
• Uses CAN hardware - CAN as a transceiver is secure and reliable (high Electro-
Magnetic interference resistance) which is essential.
• Every slave in the network is aware of the contents of every frame. Each slave keeps
415 a local database copy and hence the slave knows the data relevancy. This custom
solution keeps the communication minimal and straightforward.
Disadvantages
Even though interestingly RTDN is conceptually similar to EtherCAT, there are dis-
advantages to RTDN mainly due to the use of CAN as the message carrier. UCP’s disad-
420 vantages are applicable to RTDN as well. But the most important disadvantage of RTDN
is limitation in payload size. Another limitation is RTDN cannot yet be used for master-
slave communication, hence limiting it’s use within the complex system to only slave-slave
communication.
2.3 EtherCAT
425 2.3.1 Introduction
EtherCAT means ”Ethernet for Control Automation technologies”. It is an Ethernet
based fieldbus protocol which has been invented by Beckhoff GmBH. The protocol is stand-
ardized and is being widely adopted [14], [15]. The main principle behind EtherCAT is to
transmit large amounts of data that require short update cycles and with very low jitter.
430 EtherCAT with respect to the OSI model is as shown in the Figure 2.7.
receiving happens on separate lines), each node reads its inputs and adds its outputs to
the message frame. Input data to a node is read as the message passes through that node’s
input port and output data is inserted while the frame passes through the output port to
450 the next node. A single message consisting of a summation of all the data is issued by the
EtherCAT master. Thus when the message arrives back at the EtherCAT Master every
node in the network has received new input data from the Master and returned new output
data to the master. Overall, the delay as the message frame passes through each node
(input and output ports) is a few nanoseconds. An EtherCAT network can be compared
455 to a train (message frame) originating at a station (master), moving through every station
(slave nodes) in the network and then back to the originating station through the same
route. At each station (slave nodes) the train can off-load and re-load train compartments
with people/goods (input-output data) while the train moves through the station [17].
Now that we know how the EtherCAT operates, let us understand a few concepts about
460 EtherCAT essential to the project.
incremented by all devices that process the associated datagram, hence used as an effective
diagnostic tool. As indicated earlier, the main advantage of EtherCAT is based on the
470 possibility to pack data of several devices into one single summation frame. [17].
EtherCAT cycletime
The cycle time is an important performance metric for industrial communication sys-
tems. It is defined as the time necessary to exchange the input/output data between the
controller and all networked devices once. The minimal cycle time of an industrial com-
475 munication system based on EtherCAT depends on several terms. Some of those factors
are payload per device, used topology and Ethernet type e.g. 100MB or 1GB. Typical
minimum cycle time for EtheCAT based on the 100Mbps BASE-TX connection, is approx-
imately around 100µs.
Topology
480 EtherCAT uses full-duplex Ethernet physical layers for communication. When an Eth-
erCAT device detects a port to forward the frame and this port is closed, the frame is
automatically returned back to the master device, through the same route. Due to these
two features (full-duplex mode and returning data back through the same route when
closed port is detected), EtherCAT can support almost any physical topology such as line,
485 tree or star. It is also possible to combine topologies with any EtherCAT device with three
or more ports which can act as junction. One example EtherCAT network topology is
shown in Figure 2.9. If an EtherCAT network is wired in ring configuration (requires two
ports on the master device), it can provide cable redundancy.
In theory, as claimed by the EtherCAT Technology Group, we can have upto 65535 slave
490 devices connected to a network. Assuming we can use 100BASE-TX Ethernet physical
connection, two slave devices can be separated by upto 300 ft distance.
495 • It satisfies both hard and soft real-time requirements along with deterministic re-
sponse times.
• Flexible topology - EtherCAT can use any network topology (line, star, tree) and
any combination of them. Due to the operating principle of EtherCAT, the topology
of EtherCAT has little to no effect
505 • EtherCAT masters can be implemented on many devices with a standard network
card. The slaves, though, do need special hardware to be fully compatible with
EtherCAT.
• EtherCAT supports packing data in the form of CANopen application over Eth-
erCAT (CoE), Servodrive-Profile over EtherCAT (SoE), Ethernet over EtherCAT
510 (EoE), Functional Safety over EtherCAT (FSoE). The protocol can be adapted to
support custom application protocol over EtherCAT. The best example for this is
UCP protocol of NTS-Group can be adapted to be transmitted over EtherCAT.
• This extensive support can be used to NTS’s advantage by using multiple vendors as
sources to off-the-shelf components without having to worry about cross-compatibility
between vendors. In practice, this is not always the case because EtherCAT is open
520 source leading to more vendors improvizing on EtherCAT in their own unique way.
But atleast in theory this is an advantage.
• In theory, using EtherCAT 1000 devices can updated in 30µs. In practise, this
translates to supporting µm precision motion control.
Figure 2.10: Several device profiles and protocols can co-exist side by side [4]
Examples of slave settings done with SDO are enabling an encoder counter, or the offset
of an analog output, or the period of a PWM signal. SDO settings are stored in a non-
volatile memory of the terminal, so the settings are remembered also when the terminals
545 loses power [19].
Examples of PDO data can be: a value sent to a digital output, a value received by a
digital input, a value send to an analog output, an encoder value received from an encoder
interface. PDOs are normally sent and received at a high frequency. Control signals of the
controller are sent with PDOs [19].
550 In the current implementation we are using Beckhoff’s TwinCAT at the master’s node.
Beckhoff’s CANOpen implementation uses EtherCAT’s states, shown in Figure 2.12 and
to effectively use SDOs and PDOs. Depending upon the state (shown in red, yellow and
green), different functions are accessible or executable in the EtherCAT slave. In the
Pre-Operational state SDO settings are possible, but PDO can’t be used. The the Safe-
555 Operation state the PDO can be used, although the slave keeps its outputs in a safe state,
while the input data are updated cyclically. In the Operational state the slave copies the
output data of the masters to its outputs [19].
In the case of CANopen over EtherCAT (CoE), the SDO protocol is used directly, so
that existing CANopen stacks can be used practically unchanged. Optional extensions are
560 defined that lift the 8-byte limit and enable complete readability of the object list [20]. An
example of an SDO request message is as shown in Figure 2.13.
Figure 2.13: An example of CANopen over EtherCAT SDO request message from the
master to slave [2].
The length of the distributed clock is 64 bit with a resolution of 1ns and a base starting
time is at January 1,2000,0:00 [7]. The first 32 bit measure 4.2ms and all the 64 bits
measure over 580 years. Figure 2.14 shows one slave clock to be reference (indicated by
R) and other slave clocks shall be adjusted to this reference clock. Figure 5.3 shows the
580 deviation of clocks from the reference clock during initialization and then during operational
phase.
Figure 2.14: Distributed Clock synchronization in an ethercat network. One slave’s clock is
configured as reference (R) and the other slave’s local clocks are adjusted to this reference
clock. [7]
Figure 2.15: The deviation of the local clocks compared to the reference clock during
initialization of DC and during operational state. [7]
The synchronization procedure including the offset and delay calculations are shown in
two Figures, 2.16 and 2.17
Figure 2.17: Example delay calculations shown again as a sequence between master and
slave within an ethercat network. [8]
Figure 2.18: Bit by bit, simultaneous transfer, between master and slave. [9]
There are several modes of operation along with other modifiable parameters such as
600 baud rate, number of bits per character and read/write buffer sizes. The mode of operation
is determined by polarity of clock and the instant at which the data is latched (clock phase).
This is shown in the table 2.3.
Figure 2.19: Storing data to write and read in buffer in the SPI master (MBB).The figure
also shows configurable baud rate. [9]
Design
3.2 Requirements
NTS-Group specializes in low/medium volume, high complexity systems. The primary
610 reason for NTS-Group to investigate EtherCAT technologies is to be a solution provider
and a part of the EtherCAT ecosystem which is growing rapidly. They also intend to move
away from custom solutions like RTDN, UCP and use readily available components to
prototype tailor made modules (customized to requirements) and then use the company’s
”value engineering” capability to produce cost-effectively. With these intentions, NTS have
615 certain questions about EtherCAT that are interesting to explore. These questions in the
form of requirements are as follows.
• What is the best achievable (lowest possible) response time with the components
available? What is EtherCAT’s update rate frequency?
• How does the frame delay scale corresponding to the variation in frame size (bytes
of payload)?
625 • What is the achievable frequency of operation for the EtherCAT with the setup and
implementation?
• How does the jitter of the network scale with distributed clock synchronization?
• What are the costs (delay, licences, etc) of integrating Simulink in TwinCAT?
Control Architecture Choice The final objective is understand if this information has
any consequences on control architecture choices?
The following sections explain the design process of the master-slave system that is
635 used to implement and investigate ethercat’s performance. The implementation, testing
and results are a part of the chapters to follow.
Figure 3.1: High level EtherCAT master-slave design. The PC is the master and the ESC
along with the proprietary Motion Building Block (MBB), together make up the slave.
• Slave runs a modified Open source ethercat framework called Simple Open EtherCAT
650 Slave (SOES) stack.
Figure 3.2: A master-slave ethercat system with the implemented components indicated
in green.
Figure 3.3: EtherCAT master-slave system setup at the company. It consists of a Beckhoff
drive that works as another slave and is used as a drive control.
Alternatives to TwinCAT - TwinCAT is only one of the options there is, to convert-
ing a PC into an real time control system. An alternative to TwinCAT is Simple Open
EtherCAT Master (SOEM) which also provides a similar suite, as TwinCAT, for Windows
(and Linux). Another alternative to TwinCAT software is IntervalZero. This is a software
665 suite that converts any Windows based PC into an RTOS (just like TwinCAT). But Inter-
valZero does not directly provide support for EtherCAT. It works closely with companies
that make EtherCAT master stacks for IntervalZero RTOS. These master stacks are not
as commonly used as TwinCAT.
The reason to choose TwinCAT is simply because it has a better Graphical User In-
670 terface and a considerably larger user-base which implicitly means better support (either
directly or through forums).
Figure 3.4: EtherCAT Slave Information contains mandatory and optionally specified in-
formation about the slave. This information is given as input to TwinCAT to be parsed
and stored. [10]
Figure 3.5: Simulink model integrated into TwinCAT. [11].This is not an image of our
own PI controller. The reason being because of the use of trial licence of TwinCAT, the
visualization is not available.
TwinCAT has some limitations. One such limitation is that there exists no easy options
to log the data that is interesting to the user. Hence alternative option is to write our
own program to log data. Initially the plan was to implement C++ program that will
705 store chosen data into a buffer and then once this buffer is full, data will be written
asynchronously to a file on the local hard-disk. But due to the steep learning curve to use
TwinCAT specific C++ functions, we changed our decision and went with implementing
PLC code. The idea is the same - copy necessary data into a buffer and when the buffer
is full, write the contents of the buffer asynchronously into a file on the hard-disk. This is
710 shown in figure 3.7
• LAN/Ethernet port
The proprietary Motion Building Block (MBB) does not include LAN ports as well as
ethernet physical layer. It also does not support processing ethercat frames on the fly.
These two important and essential shortcomings have been managed by including a special
720 ASIC from Beckhoff. This ASIC is a piggyback EtherCAT Slave Controller (ESC) that
handles the ethercat communication. Figure 3.8 shows the specific piggyback controller
used in the project - Beckhoff’s FB1111-014x. Figure 3.9 shows the piggyback controller
interface with the MBB board. Serial Peripheral Interface (SPI) is used as an asynchronous
communication between the MBB board and the ESC. The SPI protocol is explained in
725 the background chapter 2.5. The implementation of this SPI interface for the project has
been explained the the following section.
Figure 3.9: EtherCAT Slave including the Motion Building Block board (consists of
Texas Instrument’s DSP) and the Beckhoff’s piggyback ASIC which handles the ether-
cat communication- also called Ethercat slave controller.
3.5.1 EtherCAT
To develop the Slave EtherCAT software, we had two options of ethercat framework -
1. Beckhoff’s EtherCAT Slave stack
730 2. Simple Open EtherCAT Slave stack(SOES), is Open source.
Because of complications and delay in obtaining the Beckhoff’s slave stack license and
also because SOES is open source, we chose SOES to develop the ethercat slave code.
The SOES provides a skeletal framework for implementing EtherCAT slave and it can be
downloaded and distributed for free from the SOES website.
the frame. This frame is then transmitted to the next port to the next slave in the network.
If the next port is not connected, then it transmits the frame back to the master through
745 the other duplex channel of the same ethernet cable.
From the software developer’s perspective, the important task here is to configuration
of the ESC. This configuration is then transmitted by the master, through ethercat, during
initialization of the network which is shown in figure 3.10.
Figure 3.10: Process of configuring Ethercat Slave Controller (ESC), as per the require-
ments.
3.12.
Figure 3.12: Actions/Tasks to be performed, at the slave, during the state transition. All
other (not indicated in the figure) state transitions are invalid and lead to updating the
error register with the appropriate invalid state transition error.
Init state This is the default power-on state of the ESC which is contained in a register
- ”Data Link-layer Status” (DLStatus) register. The Sync Managers (SM) responsible for
mailbox communication are initialized in this state. The Init state is an indicator that the
765 ESC is ready for mailbox communication (but does not communicate).Figure 3.13 shows
the actions to be performed during the Init state of the ESC.
Pre-Op state The Sync Managers (SM) responsible for mailbox communication are val-
idated in this state. In our project we use CANopen as the application layer to exchange
all information, over the EtherCAT data link layer (hence called CoE). In CANopen ter-
770 minology, mailbox communication is also called as SDOs (Service Data Objects).
Hence, SDO communication takes place during Pre-Op state. Process Data Objects
(PDO) are not, yet, communicated in this state. The Sync Managers responsible for PDO
communication is initialized and other settings for this PDO transfer are also communicated
through the SDOs, as shown in figure 3.14.
775 Safe-Op state The SMs for process data exchange (PDOs), the Functional Memory
Management Units (FMMUs), Distributed Clock configuration and initialization are all
done during the transition from Pre-Op to Safe-Op state. The slave devices validates all
these configurations against it’s own object-list (present in the MBB board in our project)
and prepares the ESC for PDO communication.
780 In the Safe-Op state, the slave transmits/receives mailbox (SDO) and only the input
(output from master) process data (PDOs). The output (input to the master) PDOs are
still in ”safe” state hence the slave does not transmit the output PDOs. Actions/Tasks
performed during Safe-Op state is shown in as shown in figure 3.15.
Op state [H] The slave is in fully operational state. Mailbox (SDOs) and process data
785 (PDOs) are communicated in this state.
In this state, both inputs and outputs are transmitted/received by the slave. This is
shown in figure 3.16.
Figure 3.16: Actions/Tasks performed during EtherCAT slave Op state. This is when the
slave is fully operational
Bootstrap state From Init, the master can change the state of a slave to Bootstrap if
there is a need to update/write firmware into the EEPROM. This state is not shown in
790 figure 3.12 because it is a special state that is not used normally.
Hardware Connections
800 The figure 3.17 shows the physical connections between the Ethercat Slave Controller
(ESC) and the Texas Instruments DSP (TMS320F2812) which is the processor used in the
MBB board. The figure also shows the Vcc supply and the ground connections essential for
the ESC to operate. Figure 3.18 shows the soldered connections between the MBB and
the ESC.
Figure 3.17: SPI interface hardware connections between the ESC and the TI DSP
Figure 3.18: SPI interface hardware connections between the ESC and the MBB
The software design of the SPI interface in the form of state machine is shown in the
figure 3.19. The SPI is initialized to an IDLE state. Every interaction between the MBB
and the ESC either puts the SPI into write mode or read mode and it’s respective buffers
are handled to make a successful communication.
The flow diagram of Read and Write function of the SPI are shown in figures 3.20 and
3.21.
Implementation
• The EtherCAT Slave Controller (ESC) that handles the EtherCAT communication.
825 • The Motion Building Block (MBB) that handles the ESC and the information that
needs to be exchanged.
• Serial Peripheral Interface (SPI) which is used as communication between the MBB
830 and the ESC.
The software components are explained in brief in the following paragraphs and will be
details in the later sections of this chapter.
Serial Peripheral Interface (SPI) A preposterous amount of time was spent in es-
tablishing the SPI communication between the Texas Instruments(TI) DSP on the MBB
835 board and the ESC. For the SPI communication, the TI DSP is the SPI master and the
ESC is the SPI slave. As indicated in the design, the SPI peripheral is initialized (along
with the GPIO pins used for the SPI communication) and held in the Init state. From
here, the SPI peripheral is invoked, either to write or to read data to/from the ESC.
ESC Software The ESC we use in our setup is an ASIC from the German company,
850 Beckhoff GmbH. It is pre-programmed with Beckhoff’s software and we have no access to
the code, which makes it essentially a ”black box”. Beckhoff provides elaborate manuals
which describe how we can configure the ESC to respond in a certain manner and also
describes how we can interact with the ESC. From the MBB, we use SPI to interact with
the ESC and from the master (PC) we use EtherCAT to interact with the ESC as shown
855 in Figure 4.1.
Figure 4.1: The master and the MBB accessing the ESC through EtherCAT and SPI.
The EtherCAT slave software is written in C and programmed into the MBB. There are
multiple vendors providing the skeletal framework for the slave software. We have chosen
Simple Open EtherCAT Slave software as the framework because it is open source and can
be re-used without licensing hassle. I personally felt we could have worked with Beckhoff
860 provided slave software framework but this was at a much later stage with a steep learning
curve for the time remaining, hence reluctantly did not make the switch.
The core idea is, at startup, this software first initializes the peripherals needed to
interact with the ESC and then initializes the ESC to ”INIT” state. Then, cyclically, the
state of the ESC (EtherCAT state machine) is monitored and if any events are pending,
865 corresponding actions are executed. The flow diagram is shown in Figure 4.2. The code
shown in Listing 4.1 consists of the hardware and software initialization.
Figure 4.2: The flow diagram shows the ethercat slave software sequence.
v o i d main ( v o i d )
{
870 ...
...
CPU init ( ) ; // I n i t i a l i z e t h e CPU o f t h e TI c o n t r o l l e r
CPU DELAY US( 5 0 0 0 0 ) ; // Wait t i l l t h e power s o u r c e s a r e s t a b l e
I n i t G p i o ( ) ; // I n i t i a l i z e SPI s p e c i f i c GPIO p i n s
Software initialization The EtherCAT Slave Controller is rest to ”Init” state by clear-
ing the errors and resetting the Sync-Managers(SM). The code Listing 4.3 refers to this
925 software initialization step.
Sync Manager The sync managers are responsible for synchronizing the access to the
ESC. What this means is the SM prevents simultaneous access to the ESC hence keeping
the data consistent. Also either the master or the MBB can disable this SM causing the
ESC to become inaccessible, hence no input/output update will occur. Again enabling the
930 SM will enable transactions to happen.
// I n i t i a l i z e t h e ESC t o ”INIT”
v o i d EtherCAT init ( v o i d )
{
935 // Wait u n t i l t h e ESC i s powered on by r e a d i n g t h e DataLink S t a t u s (
DLSTATUS) r e g i s t e r
...
...
// Reset i n p u t v a r i a b l e s t o d e f a u l t
940 ...
...
/∗ r e s e t ESC t o i n i t s t a t e ∗/
ESC ALstatus ( ESCinit ) ; // A p p l i c a t i o n Layer S t a t u s r e g i s t e r i s r e s e t
ESC ALerror (ALERR NONE) ; // C l e a r e r r o r s
945 ESC stopmbx ( ) ; // Stop Mailbox communication
ESC stopinput ( ) ; // Stop Input comm .
ESC stopoutput ( ) ; // Stop output comm .
}
950 Task Loop The task in hand is to read the state of the ESC, check for pending events
like change of state or request to write/read and then finally execute the application task.
The code Listing 4.4 refers to this task loop. The Application task is shown in the following
code Listing 4.5. It is important to note that output and input throughout the code is with
reference to the EtherCAT master (PC). Hence input means input to the PC and output
955 from the ESC. Similarly for output, it is the input to the ESC(slave) from the PC(master).
//ESC Task l o o p t o be i n v o k e d c y c l i c a l l y
v o i d EtherCAT task ( v o i d )
{
960
i f ( ( ESCvar . ALstatus & 0 x 0 f ) == ESCinit )
{
/∗ I f INIT s t a t e , then r e s t o r e RX and TX PDO s e t t i n g s t o d e f a u l t
s i z e ∗/
965 ...
...
...
}
//Read t h e system time from t h e ESC .
970 ...
// Check f o r pending a p p l i c a t i o n e v e n t
ESC ALevent ( ) ;
//Read t h e ESC s t a t e
ESC state ( ) ;
975
A p p l i c a t i o n P r o c e s s ( ) ; // E i t h e r c a l l e d h e r e on i n DC i f DC i s e n a b l e d
}
Listing 4.4: Task Loop invoked to check ESC state and execute the application
985
// A p p l i c a t i o n Loop
void ApplicationProcess ( void )
{
// Keep t r a c k o f WATCHDOG t i m e r
990 ...
// Check i f t h e A p p l i c a t i o n S t a t u s i n t h e ESC i s ” Output ” ( with r e s p e c t
t o e t h e r c a t master )
i f (App . s t a t e & APPSTATE OUTPUT)
{
995 /∗ SM2 ( Output ) t r i g g e r e d and pending ? ∗/
i f ( ESCvar . ALevent & ESCREG ALEVENT SM2)
{
ESCvar . ALevent &= ˜ESCREG ALEVENT SM2 ; // Event acknowledged
RXPDO update ( ) ; //Read t h e Output b u f f e r
1000
// Perform t a s k s based on t h e output v a l u e s
...
}
}
1005 // I f WATCHDOG e r r o r , h a n d l e t h e e r r o r − Stop outputs , update e r r o r f l a g s
, change t h e s t a t e o f t h e ESC .
i f ( watchdog == 0 )
{
...
1010 ...
}
// Check i f t h e A p p l i c a t i o n S t a t u s i n t h e ESC i s ” Input ”
i f (App . s t a t e )
{
1015 set Inputs () ; // Update t h e i n p u t s t o be s e n t t o t h e master
TXPDO update ( ) ; // Send t h e updated i n p u t s through SPI w r i t e f u n c t i o n
}
}
Listing 4.5: Application loop performs the read/write from/to the ESC
1020 The difference functionalities are seggregated into different files as shown in Table 4.1
below.
Clock Synchronized Signal We can make use of the ESC’s precise clock to cyclically
generate a signal to the MBB. This signal is generated from the DC sub-system in the
ESC, hence prior to the signal generation, the clocks need to synchronized with the ref-
1025 erence. Repeating what was in the design chapter, the DC synchronization occurs in the
SAFE-OP state and then in the OP state, the sync signal is generated cyclically. There
are two such signals available to be used from the ESC - SYNC0 and SYNC1. Depend-
ing on the direction of the signal, it is called either SYNC0 /SYNC1 (ESC to MBB) or
LATCH0 /LATCH1 (MBB to ESC).
1030 In this project we use one SYNC0 signal as shown in Figure 4.3. This interrupt is
used to trigger the application task. Earlier the application task was being invoked in
the ESC task. Now we separate the state and event monitor from the actual application
task. We know from the above description that the application task is used to update
the input/outputs if the ESC is in the appropriate state. We use the SYNC interrupt
1035 to generate a more synchronized input/output update. The code Listing 4.6 shows the
external interrupt being used to invoke application task. In the project, the external
interrupt has been configured to be an ”ISR type” of interrupt as the this type of interrupt
provides the fastest response time when compared to all other interrupt types used in TI’s
DSP [24].
1040
// E x t e r n a l I n t e r r u p t g e n e r a t e d u s i n g SYNC s i g n a l from t h e ESC
//#pragma CODE SECTION( x i n t 1 i s r , ”FAST CODE RAM” ) ;
i n t e r r u p t void x i n t 1 i s r ( void )
{
1045 ...
ApplicationProcess () ;
// This i s needed t o w r i t e t o EALLOW p r o t e c t e d r e g i s t e r s
EALLOW;
// Acknowledge t h i s i n t e r r u p t t o g e t more from group 1 i n t e r r u p t s
1050 P i e C t r l R e g s . PIEACK . a l l = PIEACK GROUP1 ;
// This i s needed t o d i s a b l e w r i t e t o EALLOW p r o t e c t e d r e g i s t e r s
EDIS ;
}
Listing 4.6: SYNC interrupt used in the MBB to perform a synchronized application task.
Figure 4.3: Cyclic SYNC signal from the ESC to MBB. The SYNC signal is generated
using the precise DC clock of the ESC.
1055 Packing/Unpacking The ESC transmits/receives only packed data. The Texas Instru-
ments compiler on the other hand does not support packing/unpacking of data. Every
single structure related to the EtherCAT that consisted of uneven variable lengths had to
be manually packed and unpacked when transmitting and receiving. Bit by bit calculations
had to be done to see if the data was packed correctly or incorrectly. Figure 4.4 shows one
1060 example of packing and Listing 4.7 shows one sample unpacking function written.
Figure 4.4: Packing of three variables of different lengths (for TI, default length is 16 bit).
Listing 4.7: one unpacking function that stores the received (from ESC) mailbox
information into another local structure (at the MBB)
Figure 4.5: SPI frame with a maximum of 12 characters of SPI data (and 4 characters of
SPI header), at a time.
1
Texas Instruments DSP considers 16bits as one byte because that is the smallest addressable length.
But for this report, we consistently use a byte as 8 bits
Table 4.2: SPI Read/Write header information used to read/write data from/to the ESC.
// S t o r e t h e data t o be t r a n s m i t t e d i n l o c a l b u f f e r
...
1120 ...
// D i s a b l e g l o b a l I n t e r r u p t s
// Send data t o t h e SPI TX b u f f e r ( with d e l a y between each byte )
...
CPU DELAY US( 2 ) ;
1125 ...
...
CPU DELAY US( 1 0 ) ; // Wait f o r t h e data be t o r e c e i v e d
w h i l e ( SpiaRegs . SPIFFRX . b i t .RXFFST < j ) ; // number o f b y t e s r e c e i v e d same
a s number o f b y t e s s e n t ?
1130 ...
//Read r e l e v a n t i n f o r m a t i o n and i g n o r e t h e o t h e r s .
...
...
// Reset FIFO and SPI t o be ready t o t r a n s m i t a g a i n .
1135 ...
// Enable g l o b a l i n t e r r u p t
}
{
// I n i t i a l i z e l o c a l v a r i a b l e s
...
...
1145 /∗ C o n s t r u c t SPI−r e a d h e a d e r and s t o r e i n l o c a l b u f f e r ∗/
cmd =( o f f s e t a d d r & 0x1FE0 ) <<3; // o f f s e t a d d r [ 1 2 : 5 ] i s 1 s t a d d r e s s phase
byte , s h i f t t o upper byte
cmd |= ( ( ( o f f s e t a d d r & 0x1F ) << 3 ) | ESC ETHERCAT 3BYTEADDR) ;
r e a d p h a s e [ 0 ] = cmd ;
1150 numwords++;
r e a d p h a s e [ 1 ] = ( o f f s e t a d d r & 0xE000 ) | (ESC ETHERCAT READ WAIT <<10) |
ESC ETHERCAT WAIT ;
numwords++;
the ESC. This is shown in Figure 4.6. Failing to have a consistent description across the
devices will prohibit the ESC from functioning correctly.
Figure 4.6: ESC description files (.xml and .c) are programmed to the master, ESC and
slave for uniform ethercat communication.
To prevent the tedious task of writing a configuration file for the master and replicating
that in C code in the MBB, we use the SOES configurator tool2 which is shown in Figure
1190 4.7. Figure 4.8 shows the various settings options and the object dictionary which is the
CoE way of description. The description file to the master is written in XML Schema and
the description in the MBB is written in C. An example XML file in shown in code Listing
4.10.
2
It generates a wrong output but can be easily modified still saving enormous amounts of time
Figure 4.7: SOES configuration tool used to generate the ESC description file.
Figure 4.8: SOES configuration tool showing the configurable settings and the CANopen’s
Object dictionary way of description.
<Fmmu>MBoxState</Fmmu>
<Sm Co nt ro lB yt e=”#x26 ” D e f a u l t S i z e=” 128 ” Enable=” 1 ” S t a r t A d d r e s s=”#
x1000 ”>MBoxOut</Sm>
1210 <Sm Co nt ro lB yt e=”#x22 ” D e f a u l t S i z e=” 128 ” Enable=” 1 ” S t a r t A d d r e s s=”#
x1080 ”>MBoxIn</Sm>
<Sm Co nt ro lB yt e=”#x24 ” D e f a u l t S i z e=” 8 ” Enable=” 1 ” S t a r t A d d r e s s=”#
x1100 ”>Outputs</Sm>
<Sm Co nt ro lB yt e=”#x20 ” D e f a u l t S i z e=” 8 ” Enable=” 1 ” S t a r t A d d r e s s=”#
1215 x1180 ”>I n p u t s</Sm>
<RxPdo Fixed=” t r u e ” Mandatory=” t r u e ” Sm=” 2 ”>
...
</RxPdo>
<TxPdo Fixed=” t r u e ” Mandatory=” t r u e ” Sm=” 3 ”>
1220 ...
</TxPdo>
<Mailbox>
<CoE CompleteAccess=” f a l s e ” PdoUpload=” t r u e ” S d o I n f o=” t r u e ” />
</ Mailbox>
1225 <Dc>
<OpMode>
<Name>DC−Synchronous</Name>
<Desc>DC−Synchron</ Desc>
<A s s i g n A c t i v a t e>300</ A s s i g n A c t i v a t e>
1230 <CycleTimeSync0>1</ CycleTimeSync0>
</OpMode>
</Dc>
<Eeprom>
...
1235 </Eeprom>
...
</ EtherCATInfo>
Listing 4.10: ESC desciption file in XML Schema to be loaded into the Master and the
ESC through the master
The description file in the MBB contains one very important file which is the objectlist.
1240 The objectlist file is a list of structures that contain the same information as the XML
description file written in the master which is shown above. A small code snippet of this
file is provided in Listing 4.11.
...
1245 static const char acName1000 [ ] = ” De v ic e Type” ;
static const char acName1000 0 [ ] = ” D ev ic e Type” ;
static const char acName1008 [ ] = ” De v ic e Name” ;
static const char acName1008 0 [ ] = ” D ev ic e Name” ;
static const char acName1009 [ ] = ” Hardware V e r s i o n ” ;
1250 ...
static const char acName100A 0 [ ] = ” S o f t w a r e V e r s i o n ” ;
static const char acName1018 [ ] = ” I d e n t i t y Object ” ;
static const char acName1018 00 [ ] = ”Number o f Elements ” ;
static const char acName1018 01 [ ] = ” Vendor ID” ;
1255 static const char acName1018 02 [ ] = ” Product Code” ;
s t a t i c c o n s t c h a r acName1018 03 [ ] = ” R e v i s i o n Number” ;
s t a t i c c o n s t c h a r acName1018 04 [ ] = ” S e r i a l Number” ;
...
...
1260 s t a t i c c o n s t c h a r acName1C00 01 [ ] = ” Communications Type SM0” ;
s t a t i c c o n s t c h a r acName1C00 02 [ ] = ” Communications Type SM1” ;
s t a t i c c o n s t c h a r acName1C00 03 [ ] = ” Communications Type SM2” ;
s t a t i c c o n s t c h a r acName1C00 04 [ ] = ” Communications Type SM3” ;
s t a t i c c o n s t c h a r acName1C12 [ ] = ” Sync Manager 2 PDO Assignment ” ;
1265 s t a t i c c o n s t c h a r acName1C12 00 [ ] = ”Number o f Elements ” ;
...
c o n s t o b j d SDO1000 [ ] =
{
{0 x0 , DTYPE UNSIGNED32, 3 2 , ATYPE RO, acName1000 0 , 0 x01901389 , NULL} ,
1270 };
c o n s t o b j d SDO1008 [ ] =
{
{0 x0 , DTYPE VISIBLE STRING , 4 0 , ATYPE RO, acName1008 0 , 0 , ” s l a v e ” } ,
};
1275 c o n s t o b j d SDO1009 [ ] =
{
{0 x0 , DTYPE VISIBLE STRING , 2 4 , ATYPE RO, acName1009 0 , 0 , ” 1 . 0 ” } ,
};
c o n s t o b j d SDO100A [ ] =
1280 {
{0 x0 , DTYPE VISIBLE STRING , 2 4 , ATYPE RO, acName100A 0 , 0 , ” 1 . 0 ” } ,
};
c o n s t o b j d SDO1018 [ ] =
{
1285 {0 x00 , DTYPE UNSIGNED8, 8 , ATYPE RO, acName1018 00 , 4 , NULL} ,
...
{0 x04 , DTYPE UNSIGNED32, 3 2 , ATYPE RO, acName1018 04 , 0 x00000000 , NULL} ,
};
1290 c o n s t o b j e c t l i s t SDOobjects [ ] =
{
{0 x1000 , OTYPE VAR, 0 , 0 , acName1000 , SDO1000 } ,
...
{0 x6003 , OTYPE RECORD, 1 6 , 0 , acName6003 , SDO6003 } ,
1295 ...
};
...
...
This chapter explains the research in the thesis. It includes two parts.
• EtherCAT performance.
1325 on to the next slave or back to the master if the next port is closed. This ”processing-on-
the-fly” is done by special hardware and hence the delay is hardware dependent and not
implementation dependent.
The update rate is proportional to the number of slaves times delay experienced by an
ethercat message frame at each slave. In the case of our Beckhoff ESC with 2 ports, the
1330 delay provided by Beckhoff is approximately 1.2µs.
The system latency - TwinCAT integrates into Windows as a kernel mode driver.
1345 What this means is as a kernel driver, TwinCAT has hardware access to the RAM and
CPU to schedule CPU time based on the project settings. But because of this integration,
higher priority windows tasks take away CPU time and this causes latency in execution
of the twincat tasks. Another contributing factor to this system latency is the Network
Interface Card (NIC). Due to the NIC being used for both ethercat and ethernet, the access
1350 to the NIC is distributed hence providing a bottleneck. In TwinCAT, it is possible to
measure the latency caused, by comparing the entry of consecutive frames and subtracting
the value with the cycle time. Figure 5.2 shows the system latency hovers around 100µs.
The cycle time cannot be made lower than this system latency. Hence the best achievable
cycle time for the current setup has been 100µs.
Table 5.1: The count of clock deviations (positive and negative deviations) and the value
in µs with respect to the reference clock.
Figure 5.3: The deviation of the local clocks compared to the reference clock during ini-
tialization of DC and during operational state. [7]
Modern PCs are getting very powerful. If deterministic computing is guaranteed on the
PC then that opens up endless possibilities to implement complex control systems. Twin-
1380 CAT provides support to several programming platforms to develop such complex control
systems to run on a conventional PC. For example, TwinCAT supports integration with
PLC programming, C++ or Simulink. It also provides interoperability support between
these platforms by using TwinCAT standard libraries. Simulink is a powerful model-based
software which is widely used to make complex control algorithms. The main advantage
1385 of using Simulink is quick prototyping.
Control Loop Delay - One performance metric that is essential for precision control is
the control loop delay. It can be defined as the delay between reading the encoder value and
1390 updating the actuator value after processing. The larger the control loop delay, the lower
the precision achievable hence it is essential to keep the control loop delays to the lowest
possible values. Figure 5.4 shows the centralized architecture and the use of timestamps
to measure the control loop delay.
The estimation used for the control loop delay τkcontrol is shown in the following equation.
1395 The delay between reading the encoder and transmitting the value to the PC as input to
the simulink controller is τkEC . The execution delay of the simulink controller is defined by
τkC . The delay between reading the encoder and transmitting the value to the PC as input
to the simulink controller is τkCA .
Figure 5.4: Centralized control architecture with the use of timestamps to measure the
control loop delay.
Figure 5.5: Simulink model of PI controller used as the central control model. This model
is run in TwinCAT runtime environment with a 1ms cyclic task.
Figure 5.6: Estimated control loop delay for the centralized control architecture.
1410 The next set of experiments, used as reference, involves a simple simulink model as
shown in figure 5.7. Using the control loop delays of this model (shown in figure 5.8), we
can calculate the actual execution delay of the PI controller in the simulink model. Figure
5.9 shows the calculated execution times for the simulink PI controller model.
Figure 5.9: Execution time of the PI controller model used as the central control algorithm
for the different experiments conducted. It can be observed that the average execution
time is about 1.5ms and in practise this leads to a considerable control precision loss.
Inference - We observe from Figure 5.9 the execution times of the simulink PI controller
1415 is approximately around 1.5ms. If we assume a typical precision loss of 1m per 250µs
(update frequency of 4KHz) that translates to a loss of 6m in case we use a centralized
architecture as in the experiment. For the current setup, with TwinCAT, using Simulink
model as a central control algorithm, we cannot yet achieve the delays achieved using a
de-centralized setup up. Also it can be observed that this delay is typically unacceptable
1420 for high precision motion control applications. Summarizing, the control loop performance
of a centralized architecture using Simulink in TwinCAT, is very poor. In the following
section, we shall explore alternative architectures that we think provide the best of both
the worlds (centralized and de-centralized architectures).
Figure 5.10: Example used to explain the control architectures - Printer with a printer
head moving in the 2D axes.
It is important to note that the network for all the control system architectures presented
1445 here are EtherCAT based.
1450 application tasks and the PC has non real time interaction with the slaves and conducts
diagnostics or network analysis.
(a) De-centralized control architecture with each slave controlling one of the axis of the H-bridge
printer.
(b) A centralized control architecture with the slaves only reading/actuating their respective axis
of the H-bridge printer. The control is part of the master (PC).
Figure 5.11: Comparing the de-centralized and centralized control architectures for the
H-bridge printer that is shown in Figure 5.10.
develop a de-centralized architecture, then atleast from the perspective of NRE costs,
there is no advantage of the centralized architecture. Ofcourse the benefits of NRE costs
also depends on the volume of production. The higher the production volume, the lower
is the NRE cost per system but for our calculations, we have assumed the volume to be
1515 consistent.
demanding applications can be scheduled to run on the DSP. QoS for the three architectures
can be summarized (color coded) as,
Security
1550 It is easier to find software that provides great security for the PC and at the same time
the PC is also more prone to security threats. This makes a centralized architecture highly
vulnerable to security risks as compared to a de-centralized architecture. There is concrete
evidence about using central master (industrial PLC) to hack into slave components and
alter their operation [27]. This leads us to believe a decentralized architecture, where only
1555 necessary data is shared with the master, maybe less prone to security attacks. Another
plausible explanation in favor of a de-centralized architecture is it is not guaranteed that
the whole system would always use one specific OEM’s equipment uniformly hence making
it less futile to target, for hackers. The hybrid architecture can be viewed essentially as a
de-centralized architecture from the security viewpoint, hence making it just as secure as
1560 the de-centralized alternative.
Scalability
To understand scalability, it is useful to understand the bottleneck to scalability for each
of the architectures. In the case of a de-centralized control architecture, the bottleneck is
the Slave device that is acting as the master for real time communication. Increasing the
1565 number of slaves is feasible only till this device (acting as the master) gets overloaded.
Similar to this is the hybrid architecture. Due to the combination of a general purpose
processor with a DSP for each slave, the combination allows for more slaves to be cascaded
hence increasing the threshold before getting overloaded.
Contrary to this, in case of a central control architecture, it is easier to scale the
1570 system because of the use of a very powerful PC as the master(which can also be upgraded
depending on the requirement).
In all the cases, the ethercat network is not the bottleneck because of it’s performance.
Also assuming correct implementation, each additional slave device is as simple or complex
as the device’s configuration.
1575 Robustness
In case of a centralized control architecture, the breakdown of the PC, the backbone of
the system, will result in breakdown of the system. For critical applications, this architec-
ture will be the least robust option. In the case of a de-centralized system, the breakdown
of one or more slaves cause localized fractures (sub-systems failing) in the system while the
1580 breakdown of the master PC will result in less serious consequences as compared to the
centralized control architecture. If a slave’s ARM processor fails in the hybrid architecture
the DSP can steer the sub-system to safe operational state while the same can be said if
the DSP of the slave fails. Hence making this architecture more robust than any of the
other two architectures.
Using a centralized architecture, the master PC has a wide suite of readily available
software applications that aid in easy diagnostics and maintenance of the system. With
the use of a PC, we can easily send data to cloud servers allowing for remote data analytics
and also access of the system’s parameters outside of the system (for example accessing
1590 the plant’s health over the phone using Internet of Things). The centralized architecture
is by far the most suitable option for this purpose.
In the hybrid architecture, each slave device consists of an ARM core (general puspose
processor). Though this processor is not as powerful as the PC, some of the advantages
mentioned above also applied to this architecture. The least effective architecture for the
1595 purpose of maintenance and diagnostics is the de-centralized architecture. The complexity
of the diagnostic tools is proportional to the DSP’s performance and ease of development.
Conclusion
Summarizing the metrics and the efficiency of the three architectures for each of the
metrics in the table 5.2 below.
Table 5.2: The three control architectures and their performance across the various metrics.
Green indicates the best of the three, while Yellow indicates a moderate performance and
Orange stands for a poor performance of the metric.
6.1 Conclusion
[9] T. Instruments, “Serial Peripheral Interface C28x,” tech. rep. viii, viii, 21, 22
[10]
1705 O. E. Society, “SOES tutorial.” ix, 27
[15] “EtherCAT.” 10
[16]
1710 “EtherCAT,” [Link] 10
[17] P. A. M. Kumar and B. S. Kumar, “A Study on the Suitability of Ethernet/IP and Ether-
CAT for Industrial Time Critical Applications,” International Journal of Future Computer
and Communication, vol. 2, 2013. 11, 12
[18] H. Boterenbrood, “CANopen - high-level protocol for CAN-bus,” Master’s thesis, NIKHEF,
1715 Amsterdam, 2000. 14
[19] B. Burgers, “Automated I/O access with CoE in Orocos,” Master’s thesis, University of
Twente, 2010. 16
[22]
1720 M. Rostan and J. E. Stubbs, “EtherCAT enabled Advanced Control Architecture,” 2010.
28
[24] N. Lethaby and S. Prasad, Using DSP/BIOS in C2800 Applications with High Interrupt
Rates. [Link] 51
[25]
1725 “Texas Instruments F28M35H52C Concerto Microcontroller.”
[Link] 70
ARM expands as Advanced RISC Machine. It is a family of processors that uses the
reduced instruction set architecture.. 70
1735 ASIC means Application Specific Integrated Circuits. In this project it refers to the
Beckhoff’s EtherCAT Slave Controller, FB1111-0141 [29]. 30, 32
BIOS means Basic Input/Output System. It is a software that describes basic functions
that the computer can do without the need to access the programs on a disk.. 82
CAN means Controller Area Network. CAN is a message based communication protocol
1740 used by devices to communicate amongst each other without necessarily the help of
a host computer.. 82
1745 Industry 4.0 is current technologies in the industrial automation which includes cloud
computing technologies and Internet of Things.. 2
ISR type is a NON BIOS type of an interrupt used in Texas Instruments controllers. It
is characterized by the keyword ”interrupt” in front of the interrupt name.. 51
MBB is the motion building blocks used at NTS-group. It is the propertiary motion
1750 control boards built around the Texaas Instruments’ digital signal processing unit
and consists of several digital/analog inputs/outputs.. 1, 82, 83
OSI refers to Open Systems Interconnection model, which is the communication protocol
specification standard that partitions a communication system into abstract layers
based on functionality.. 7
1755 RTDN means Real Time Data Network. This is a synchronous communication protocol
which uses the CAN hardware layer to achieve hard real time communication between
the MBB boards which is used for control.. 1, 4, 7, 9
SOES Simple Open EtherCAT Slave is a software framework for the EtherCAT slave
controller from the Open EtherCAT Society.. 56
TI - Texas Instruments.. 39