TcTimer
Target platform
The TcTimer functionality is available on CE-based Beckhoff hardware devices (such as CX1000 / CX1020 / CX9000 / Ethernet panels / IPCs...)
Functionality
TcTimer represents a deterministic timer that allows the execution, for example, of a customer-specific C++ code instead of implementing the logic within the IEC 61131-3 PLC language.
The basic TcTimer is scalable from 100 µs and is derived from the highest CE priority level. The TwinCAT R3IO-API offers direct access via pointers to the I/O image of a TwinCAT IO task.
The requisite TwinCAT IO task can be configured remotely using the TwinCAT System Manager. This facilitates the scanning of the IOs on the connected fieldbus and connects the physical IOs with the logical IOs of the IO task.
Data consistency: After reading the input data from the IO task, and calculating and providing the new data in the output image, the C++ code can initiate the data exchange between the IO task and the mapped physical IOs:
As a result, the data consistency is supported from the logical C++ code to the physical IO level.
Main differences between TcTimer and TwinCAT IO R3
In general, the two solutions, TcTimer and R3IO, are similar: Both solutions offer access from the C++ code to the images of the TwinCAT IO task with API.
The main differences:
- The TcTimer function is supported by the CE platform only (CX1000 / CX1020 / CX9000 / Ethernet panels / IPCs…)
- The R3IO functionality is supported by both the CE and the XP/XPE platforms.
- TcTimer allows the execution of C++ code in deterministic cycles; in addition to that, the exchange of data to the fieldbus can be initiated from this deterministic cycle.
- R3IO allows the execution of C++ code started cyclically by a multimedia timer (not highly deterministic) in order to initiate the data exchange.
Alternatively, this data exchange can be started deterministically by the IO task itself: In this case, communication should take place by ADS from within the C++ code to the IO task.
Required components
The files required for Windows CE are located here.
Priorities
// Set the Priorities of the Thread
if (CeSetThreadPriority(hThreadTask1, 26) && CeSetThreadPriority(hThreadTask2, 27))
In the example, the thread priority is set to 26 and 27.
In general, the user is free to determine the priority of the thread; here is information on the priorities of other processes:
- Device threads : Area 100-130- Beckhoff TwinCAT timer thread : 1
- Microsoft MultiMedia Timer : 2
Depending on the requirements, a selection of the priority can be made in area 3 – 64 for real-time threads and area 131 – 255 for non real-time threads.