Sample
This sample shows the different ways in which the TwinCAT 3 Usermode Runtime can be used.
Sample code for these products can be obtained from the corresponding repository on GitHub: https://github.com/Beckhoff/TC170x_Samples.
There you have the option to clone the repository or download a ZIP file containing the sample.
The sample assumes that a TwinCAT 3 Usermode Runtime has been started for execution and that this has also been started with -f 0x4 to switch between different modes, as described.
There are two projects in the repository:
- TcRtSimulationExternalTick provides external control of the TwinCAT 3 Usermode Runtime. A command is sent that leads to the execution of 100 real-time ticks.
The program can be easily compiled in a Visual Studio with C++ support. Please note that you may need to adjust the AmsNetId. - TestTcOsUmRtSimulation_SelfTick is a TwinCAT solution that provides a corresponding sample to demonstrate the use of the products.
External Control (TC1701): MAIN_ExternalTick
A counter value
is counted down from 100 to 0 in normal cyclic mode. Meanwhile, "...cycling..." is displayed in a "hint" variable. The system then waits for the external ticks, which you can send using the TcRtSimulationExternalTick program
The three variants of MAIN_ExternalTick show different ways to use the same interface:
Via ADS (MAIN_ExternalTick),
as a Functions call (MAIN_ExternalTick_F),
or as a TcCOM object (MAIN_ExternalTick_ITc).
Fast As Possible (TC1702): MAIN_FastAsPossible
A counter value
is counted down from 100 to 0 in normal cyclic mode. The system then switches to RtMode_FastAsPossible and counts from 100,000 to 0. The process is repeated, which is counted in the counter Iteration.
The three variants of MAIN_FastAsPossible show different ways to use the same interface: Via ADS (MAIN_FastAsPossible); as a Functions call (MAIN_FastAsPossible_F); or as a TcCOM object (MAIN_FastAsPossible_ITc).