I am a beginner in TwinCAT and is using XAE to test some functionalities.
My current program requires me to pass an array of bytes from the PLC ST program to C module instance. However TwinCAT 3 doesn't allow this and the error message says 'Structured value types not allowed in external function calls'.
Is there any workaround for this?
Is there any other way of passing a byte array to the C module instance?
Asked
Active
Viewed 239 times
1

Piper
- 149
- 11
-
Maybe you could use a global variable array. – paladin May 12 '21 at 15:45
-
@paladin But the C module cannot access global variable list in PLC(as far as I know). – Piper May 12 '21 at 16:11
-
Just create a new custom Global Variable List and use this entire list as an array. EDIT: Are you sure about that "C module cannot acces..."? I think it's able to do so. – paladin May 12 '21 at 16:25
-
@paladin Yes I'm sure of it. Can't do it this way. – Piper May 12 '21 at 16:47
1 Answers
0
In your C/C++ project you will be able to find a folder called "TMC Files". In the .tmc file you can define Data Areas for your module. You can define inputs for the module using "Input-Destination" and then defining the data structures and naming that you need. When you later instantiate your module you can link this data area to variables in your PLC code.
Here is an example of the .tmc file from my project (not using arrays but other input data types):

Mikkel
- 138
- 7
-
1Got it solved. In addition, I defined a pointer method and passed the data structure between PLC and C. – Piper May 27 '21 at 08:00
-