Relationship between Bus Cycle and Task

Generally, for each IEC task, the input data used is read when the task starts (1) and the written output data is transferred to the I/O driver when it ends (3) (see figure below). Implementation in the I/O driver is crucial for further transmission of the I/O data. It is responsible for determining during which time frame and at what specific time the actual transmission to the respective bus system occurs.

The PLC bus cycle task can be determined globally for all fieldbuses in the PLC settings. However, it is possible to change some of these tasks for specific fieldbuses independently of the global setting. The task with the shortest cycle time is automatically applied as the bus cycle task (setting: unspecified in the PLC settings). Normally, in this task the messages are sent to the bus.

Further tasks copy only the data from an internal buffer that is only exchanged with the real hardware during the bus cycle task.

EtherCAT Tasks
EtherCAT Tasks
Legend for Figure “EtherCAT Tasks”

No.

Description

1

Read input buffer inputs.

2

IEC task

3

Write outputs to output buffer.

4

Bus cycle

5

Input buffer

6

Output buffer

7

Copy data from/to bus

9

Bus cycle task, priority 1, 1 ms

10

Bus cycle task, priority 5

11

Bus cycle task, priority 10, interrupted by task 5

Before the IEC inputs are copied, the network messages pending from the last cycle are read.

Task Processing without “Send/Receive per Task” Option
Task Processing without “Send/Receive per Task” Option

When the “Send/Receive per Task” option is enabled in the EtherCAT Master settings, additional telegrams are sent for each task to the device and the inputs and outputs used. Channels used in a slow task are also transmitted less often. This helps reduce bus load.

Task Processing with “Send/Receive per Task” Option
Task Processing with “Send/Receive per Task” Option

Note

Undefined States due to Writing and Reading in Several Tasks

If an output is written in several tasks, because it can be overwritten, the state is undefined. If the same inputs are used in different tasks, sometimes the input changes while a task is processed. This happens when the task is interrupted by a higher-priority task, so the process image is read in again.

Remedy:
At the start of the IEC task, copy the input variables into the variables; then, in further code, only work with local variables.

Summary:
Using the same inputs and outputs for several tasks is not productive and in some cases, can cause unforeseen states.