C++-samples | Sample13: Module communication: Method call C++ module to PLC ... 5. Activate the configuration by clicking . р 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. 15.12 Sample13: Module communication: Method call C++ module to PLC module | Sample13: Module communication: Method call C++ module to PLC ... This article describes how a TwinCAT C++ module calls a methods of a PLC function block via the TcCOM interface. Download You can obtain the source code for this sample here: https://github.com/Beckhoff/TC1300_Samples/tree/ main/S13-CppToPLC 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 [ } 21] . 3. Select your target system. 4. Build the sample (e.g. Build->Build Solution ). р The sample is ready for operation. 5. Activate the configuration by clicking .
Description This sample provides for communication from a C++ module to a function block of a PLC by means of method call. To this end a TcCOM interface is defined that is offered by the PLC and used by the C++ module. The PLC page as a provider in the process corresponds to the corresponding project of the TcCOM Sample 01 [ } 304] , where an PLC is considered after PLC communication. Here a Caller is now provided in C++, which uses the same interface. The PLC page adopted by TcCOM Sample 01 [ } 304] . The function block registered there as TcCOM module offers the object ID allocated to it as an output variable.
It is the C++ module’s task to make the offered interface of this function block accessible. ь A C++ project with a Cycle IO module is assumed. TwinCAT 3 286 Version: 1.19.1