Sample12: module communication: Using IO mapping

This article describes how two TC3 C++ modules could communicate via the usual IO mapping of TwinCAT 3: Two instances are linked via IO mapping and access the variable value periodically.

Download

Here you can access the source code for this sample.

1. Unpack the downloaded ZIP file.
2. Using a Visual Studio with TwinCAT installed, open the project via Open Project ....
3. Configure signing for this project by switching on TwinCAT signing with a right-click on Project->Properties->Tc Sign and configure your certificate and password if necessary.
For more information on signing C++ projects, click here.
4. Select your target system.
5. Build the sample (e.g. Build->Build Solution).
6. Activate the configuration by clicking on Sample12: module communication: Using IO mapping 1:.
The sample is ready for operation.

Description

Both instances are realized by means of a module class ModuleInToOut: The class cyclically copies its input data area Value to its output data area Value.
The Front instance acts as front end for the user. An input Value is transferred to the output Value via the method cycleupdate(). This output value of Front is assigned (linked) to the input "value" of the Back instance.
The Back instance copies the input Value to its output Value, which can be monitored by the user (see the following quick start steps to start debugging: Debugging a TwinCAT 3 C++ project)

Ultimately, the user can define the input value of the Front instance and observe the output value of Back.