“PLC_Task” Main Task

Configured tasks are displayed below the task configuration in the Program Structure. A “PLC_Task” main task is automatically created first for each task configuration. Tasks can be edited or deleted. The number behind the task indicates how many program calls are associated with the task. The task can be double-clicked to change the name. Other tasks can be extended by right-clicking them in the task configuration and choosing Add New Element > Task in the context menu.

For additional information, see CODESYS online help: “Task Configuration Editor > Configuration Dialog”.

“PLC_Task” Main Task
“PLC_Task” Main Task
“PLC_Task” Main Task

Parameter

Description

Priority (1...15)

Indicates the task priority on a scale between 1 to 15

1 = highest priority
15 = lowest priority

Task priority can affect the runtime behavior of the controller and enable watchdog for real-time priorities!

  1. Note that a set task priority in the critical range (1 .. 3) can considerably affect the runtime behavior of the controller.
  2. If you create and configure tasks in your IEC application with real-time priority (between 1 and 14), communication with the controller may be interrupted during execution.
    This can be due to overload that occurs as soon as the runtime of one or more tasks (in total) exceeds the set cycle time(s). In this case, lower-priority processes for communicating with e!COCKPIT and other tools are permanently preempted on the controller.
    The controller is then no longer accessible from the outside.
    Recommendation: If you use a task with real-time priority, also enable a watchdog for the task.
  3. This stops the processing of the entire application (PLC “STOP”) as soon as the configured cycle time is exceeded due to the longer computation time of the task.
  4. Also, configure the task cycle times to ensure the least possible jitter in processing. At runtime, the jitter is displayed in the task configuration in the “Monitoring” tab when e!COCKPIT is connected.

“Cyclic” Type

Defines the time after which the task will be restarted.

The cycle time (e.g., “200”) corresponds to the task cycle time entered in the “Interval” field in milliseconds “ms” or microseconds “µs”.

Note: When entering the task cycle time, consider system requirements. For example, in CAN bus systems, this must fit the currently set baud rate and the number of frames used on the bus.
To prevent the loss of CAN frames, also enter multiples of the task cycle time for Heartbeat, Nodeguarding and Sync.

“Event” Type

Starts the processing of the task as soon as a rising edge occurs on the variable defined in the “Event” text field

The […] button opens the Input Assistant with a list of all available global variables.

Note: If the event that controls a task comes from an input, there must be at least one task that is not event-triggered. Otherwise the inputs and outputs are never updated and the event-controlled task is never started.

“External” Type

Starts task processing as soon as the event defined in the “Event” field occurs (events dependent on the target system)

“Freewheeling” Type

Begins task processing at the start of the program and restarts automatically in a continuous loop at the end of the task (no defined cycle time)

“Status” Type

Starts task processing if the variable of the “Event” field has the value TRUE

Watchdog

Defines watchdog parameters for a task.

Depending on the device used and definitions in the respective device description, setting options (upper/lower limits, default values, units, etc.) may be different than the settings shown. The watchdog can be switched off for specific cycles.

Enable

If this option is activated, the watchdog is active. The task ends with an error status if the entered cycle time incl. set tolerance (sensitivity) is exceeded.

Several successive timeouts:
A sensitivity of 0 or 1 generates the exception error in cycle 1, a sensitivity of 2 to n generates the exception error in cycle 2 to n.

With Single Timeout:
Exception error if the cycle time of the current cycle is longer than (time * sensitivity)

Example: Cycle time 10 ms and sensitivity 5
Exception error as soon as the task (once) is longer than 50 ms.

If this option is deactivated, the watchdog is deactivated. There is no task watchdog.

[Add call]

Opens a dialog for adding a program or POU call

The dialog can likewise be opened in the Program Structure (right-click on a task > Program Call).

For additional information, see CODESYS online help: “Program Call”

[Remove Call]

Removes the selected program call

[Change Call]

Opens the Input Assistant for selecting another program or POU

[Move up]

Moves the selected program or POU up by one position in the processing sequence

[Move down]

Moves the selected program or POU down by one position in the processing sequence

[Open POU]

Opens the selected program in the programming editor