TcTimer (CE) and TwinCAT IO
Target platforms
TcTimer functionality is available on BECKHOFF CE based devices (like CX1000 / CX1020 / CX9000 / Ethernet Panel/ IPC...)
Functionality
TcTimer provides a deterministic timer allowing to execute e.g. customer C++ code instead of implementing logic within IEC61131-3 PLC languages.
The basic TcTimer is scalable from 100µs and is derived from highest CE proirity level. The TwinCAT-R3IO-API offers direct access via pointers to in/out-put image of TwinCAT IO task.
The required TwinCAT IO task can be configured remotely with TwinCAT System Manager. This tool helps to easy scan the IOs on connected fieldbusses and map the physical field IOs to logical IOs in IO-Task.
Data-consistency : After reading the input data from IO task, calculating and providing new data in the output image the C++ code can trigger the data exchange between IO task to mapped physical IOs : As a result data-consistency from logical C++ code down to physical IO level is provided.
Major differences between TcTimer and TwinCAT IO R3
General the two solutions TcTimer and R3IO are similar : Both solutions offer an API to access from C++ code the images from TwinCAT-IO-tasks.
The major differences are this :
- TcTimer functionallity only supported by CE platform (CX1000 / CX1020 / CX9000 / Ethernetpanels / IPCs...)
- R3IO functionality is supported on both platforms CE and
XP/XPE
- TcTimer allows to execute C++ code in deterministic cycles, also data-exchange to fieldbus can be triggered out of this deterministic cycle
- R3IO allows to execute C++ code which is cyclic started by
multimedia timer (not highly deterministic) to trigger
data-exchange to fieldbus.
As an alternative this data-exchange can be triggered deterministic by the IO-task itself, but in this case we recommend to access IO-Task with ADS.
Required Components
The components to implement applications are here
Priorities
// Set the Priorities of the Thread
if (CeSetThreadPriority(hThreadTask1, 26) && CeSetThreadPriority(hThreadTask2, 27))
The sample sets thread-prior to 26 and 27.
In general the user can set the thread-priority, see additional info about priorites from other threads :
- Device threads : 100-130 approx.- Beckhoff TwinCAT Timer thread : 1
- Microsoft MultiMedia Timer : 2
Depending on the requirements of your application it make sense to choose priority 3 - 64 for real time threads and priority 131 - 255 for non real time threads.