User Documentation

Table Of Contents
Appendix: Tutorial - call C function from IEC
System manual
2696790000/02/04.2020
125
Afterwards, the changed values of the variables should be accessable in the
IEC application again.
Therefore the following steps are necessary:
Creation of the IEC function
Creation of the C function and download to controller
Call of IEC function in IEC application and download
22.3 Creating the C function and download
After starting the u-create studio C++ a new project is created via File ►
New ► C/C++ Target Application in the menu bar.
In the dialog the following parameters are set:
Parameter Value
Project name myProject
Location C:\myProjects
Target
UC20-SL2000: Control PLC V<VersionNo> ARMHF Linux
KEBA control: Control PLC V<VersionNo> X86 Linux
Project Type CoDeSys IEC Functions in C
Via Finish the project is created and displayed in the project tree.
In this project a C function already exists and the predefined interface is al-
ready created.
Under myIEC_C_Call ► include in the project tree the file MyIEC_C_Call.h
is opened with a double click. In this file the structures for the input and out-
put variables are declared respectively and so the interface is adapted to the
IEC interface.
In the structure struct func1_IN the input parameters of the IEC function
are displayed. The number of parameters has to correlate and a correct type
mapping has to be done. Therefore the existing code is replaced by the fol-
lowing code in this example:
struct func1_IN {
int32_t *in_dword;
const char *in_string;
float *in_real; };
In the structure struct func1_OUT the output parameters of the IEC func-
tion are displayed. The number of parameters has to correlate and a correct
type mapping has to be done. Therefore the existing code is replaced with
the following code in this example:
struct func1_OUT {
float *out_dword;
char *out_string; };
In the structure struct func1_Instance the global variable of the IEC
function is displayed. Therefore the existing code is replaced with the follow-
ing code in this example: