User Documentation
Table Of Contents
- Table of contents
- 1 Introduction
- 2 Safety instructions
- 3 System overview
- 4 Operating behavior
- 5 Software installation
- 6 Configuration
- 7 Program development
- 8 Licensing
- 9 Device Administration (DevAdmin)
- 10 Software units
- 11 OPC UA Server
- 12 Node-RED
- 13 LongtermDiagnosticMonitor
- 14 Data recorder
- 15 Diagnostics
- 16 Maintenance
- 17 Technical data
- 18 Directives and standards
- 19 Appendix: Tutorial - creating an IEC project
- 20 Appendix: Addressing in the Ethernet (basics)
- 21 Appendix: Tutorial FoE
- 22 Appendix: Tutorial - call C function from IEC
- Index

Appendix: Tutorial - call C function from IEC
System manual
2696790000/02/04.2020
124
22 Appendix: Tutorial - call C function from IEC
The u-create system offers the possibility to call C functions in IEC created
with u-create studio C++.
Therefore a template with a predefinded interface for data exchange exists
in u-create studio C++. It is recommanded to create a function in IEC which
takes care of the call of the C function and the correct data exchange. The
data exchange itself takes place on a shared memory area. Because of this
only adresses on the memory area are transfered. The data types from IEC
and C are not compatible, so on transfer of the parameters it must be payed
attention on the correct type convertion.
Information
There is no automatically type checking. The user himself is responsible for
the correct mapping. E.g. if the size of the data types does not match, a
wrong memory area is accessed.
The example in this chapter describes the creation of a C function in u-cre-
ate studio C++ and the call in a IEC application created inu-create studio.
22.1 Preconditions and needed components
The following components are necessary:
● u-create studio C++
● u-create studio
● u-create studio project with an executable IEC application
● Fitting hardware
The creation of this example requires basic knowledge in dealing with u-cre-
ate studio and u-create studio C++.
22.2 Task
In this example application a self made C function should be called via an
IEC function in the IEC application. The IEC function provides 3 local vari-
ables with different data types (DWORD, STRING[106] and REAL) and a global
variable of type DWORD. The values of the variables should be changed in the
C function as follows:
● The global variable of type DWORD should be summated with the variable
of type DWORD
● The variable of type REAL should be multiplicated with 3.
● The variable of type STRING[106] should be extended with characters.
● The return value of the C function should be twice as much as the vari-
able of type DWORD.