Sample30: Timing Measurement
This article describes how to implement a TwinCAT 3 C++ module which contains time measurement functionalities.
Download
Here you can access the source code for this sample:
https://github.com/Beckhoff/TC1300_Samples/tree/main/S30-Timing
- 1. Using a Visual Studio with TwinCAT installed, open the project via Open Project ....
- 2. If you want to run the project on Windows or TwinCAT/BSD® (not required for Beckhoff RT Linux®): Configure signing for this project by right-clicking on the project on the page, selecting Project -> Properties -> TC Sign, enabling TwinCAT signing, and configuring your certificate and password if necessary.
Further information on signing C++ projects can be found in the chapter TwinCAT. - 3. Select your target system.
- 4. Build the sample (e.g. Build->Build Solution).
- 5. Activate the configuration by clicking
.
- The sample is ready for operation.
Description
This sample exclusively deals with time measurement such as
- Querying the task cycle time in nanoseconds
- Querying the task priority
- Querying the time when the task cycle starts at intervals of 100 nanoseconds since January 1, 1601 (UTC)
- Querying the distributed clock time when the task cycle starts in nanoseconds since January 1, 2000
- Querying the time when the method is called at intervals of 100 nanoseconds since January 1, 1601 (UTC)