C++ consumer

The C++ Consumer sample retrieves a corrected timestamp from the TwinCAT system and uses it.

Download

Here you can access the source code for this sample.

1. Open the zip file that it contains in TwinCAT 3 by clicking on Open Project ….
2. Select your target system.
3. Build the sample on your local machine (e.g. Build->Build Solution).
4. Activate the configuration by clicking on C++ consumer 1:.
The sample is ready for operation.

Description

The TcNtpExternalTimeProvider is configured under System > TcCOMObjects.

Here you can parameterize your own NTP server under Parameter (Init), if the default pool.ntp.org cannot be reached.

The C++ module cyclically determines a local timestamp in the CycleUpdate() method and corrects it. It can be traced in the respective steps using the debugger. The corrected timestamp is provided as a parameter (online).

The type required for this can be configured as parameter "TimeType" in the TcCOM object.