CPU cores and tasks

The configuration of tasks and CPU cores is not specific to TwinCAT Vision, but is the same for all TwinCAT components. For instructions on how to do this, see Real-time settings and Task settings. The issues and considerations relating to TwinCAT Vision are described below.

A TwinCAT Vision application requires tasks for various purposes:

Configuring PLC tasks

Basically, all cyclic tasks required for TwinCAT Vision are created automatically. When a PLC is created, a task with a cycle time of 10 ms is created. This means that image processing sequences in the PLC are repeated every 10 ms. You can change the task settings under SYSTEM > Tasks > [TaskName].

CPU cores and tasks 1:

Cycle ticks

The cycle ticks multiplied by the base time of the selected CPU core (by default 1 ms) produces the above-described cycle time of the PLC.

Floating point exceptions

This setting specifies whether or not TwinCAT checks for floating point exceptions.

For Vision applications it is recommended to deactivate this option. Besides that, these error messages do not indicate the exact reason for the exception.

Watchdog stack

This setting must be activated if watchdogs are to be used in the assigned PLC program.

WARNING

Floating point exceptions

For PLC tasks that essentially execute Vision commands, it is urgently recommended that you deactivate the option "Floating point exceptions". Otherwise, unnecessary errors could occur with certain TwinCAT Vision API functions and lead to a system abort. However, this option must be active if Motion Control or Safety components are also executed on the same PLC task.

Notice

Floating point exceptions in Job Tasks

If you also use Job Tasks for Vision applications and have disabled the "Floating point exceptions" in the PLC task, you must also disable this option in the assigned Job Tasks. Otherwise exceptions and system crashes can still occur.

Configuration of device tasks

The required tasks are generated automatically when creating Vision devices. The cycle times of these tasks can be adjusted as described above. For most cases it is recommended not to change the cycle times of these tasks. This is only necessary in special cases.

If the link of a Vision device with a task should have to be adjusted, this is done on the Context tab of the respective TcCOM objects of a GigE Vision camera or File Source object:

CPU cores and tasks 2:

The following TcCOM objects must be linked to a cyclic task, if they are used:

If suitable tasks already exist under the selected device name when creating a Vision device, they can optionally be reused. In this case the following window appears; click Yes to confirm the reuse:

CPU cores and tasks 3:
CPU cores and tasks 4:

Reuse of device tasks

When reusing device tasks, it should be ensured that they are not used by several Vision devices at the same time.

Assignment to CPU cores

The assignment of tasks to CPU cores takes place in the TwinCAT project under SYSTEM > Real-Time > Settings. In multi-core systems, TwinCAT enables a distinction between Windows cores and isolated cores. With Windows cores, the operating system and the TwinCAT application share the processor time. The real-time portion can be limited to between 10% and 90%. In contrast, isolated cores are fully available to the TwinCAT application. For this reason, the use of isolated cores is recommended for Vision applications.

To display the current CPU core configuration of the target system, click Read from Target.

CPU cores and tasks 5:

To change the CPU core configuration of the target system, click Set on Target and select the desired distribution of divided and isolated cores.

CPU cores and tasks 6:

After that the target system must be restarted.

CPU cores and tasks 7:

Recommendation

We recommend using at least one dedicated, isolated core for the Vision tasks (device and PLC). If there is a large load on the TcVnService due to the saving or loading of images (by camera streams, a File Source Control or direct from the PLC), we recommend reserving one core entirely for Windows or severely limiting the real-time portion of a core.

If multiple Tasks are assigned to a core, priority must be considered. As a rule, tasks with shorter cycle times should be assigned a higher priority.