TcCOM_Sample01_PlcToPlc
This sample describes a TcCOM communication between two PLCs.
Functionalities provided by a function block in the first PLC (also called "provider" in the sample), are called from the second PLC (also called "caller" in the sample). To this end it is not necessary for the function block or its program code to be copied. Instead the program works directly with the object instance in the first PLC.
Both PLCs must be in a TwinCAT runtime. In this connection a function block offers its methods system-wide via a globally defined interface and represents itself a TcCOM object. As is the case with every TcCOM object, such a function block is also listed at runtime in the TcCOM Objects node.
The procedure is explained in the following sub-chapters:
- Creating an FB in the first PLC that provides its functionality globally
- Creating an FB in the second PLC that, as a simple proxy, also offers this functionality there
- Execution of the sample project
Downloading the sample: TcCOM_Sample01_PlcToPlc.zip
Race Conditions in the case of Multi-Tasking (Multi-Threading) use The function block that provides its functionality globally is instantiated in the first PLC. It can be used there like any function block. In addition, if it is used from a different PLC (or, for example, from a C++ module), make sure that the methods offered are thread-safe, as the various calls could take place simultaneously from different task contexts or mutually interrupt one another, depending on the system configuration. In this case the methods must not access member variables of the function block or global variables of the first PLC. If this should be absolutely necessary, prevent simultaneous access. Observe the function TestAndSet() from the Tc2_System library. |
System requirements
TwinCAT version | Hardware | Libraries to be integrated |
---|---|---|
TwinCAT 3.1, Build 4020 | x86, x64, ARM | Tc3_Module |