Académique Documents
Professionnel Documents
Culture Documents
User Manual
CoDeSys SP Runtime System
for KRC1 V2.2.2 or later and
VKRC1 V1.2 or later
1 INTRODUCTION .....................................................................................................................................................5
2 INSTALLATION .......................................................................................................................................................5
2.1 SYSTEM AND INSTALLATION REQUIREMENTS .........................................................................................................5
2.2 PROCEDURE: ......................................................................................................................................................5
2.3 FILES AND DIRECTORIES .....................................................................................................................................7
2.3.1 Runtime system.........................................................................................................................................7
2.3.2 Development environment.........................................................................................................................8
2.3.3 OPC server................................................................................................................................................8
3 CONFIGURATION...................................................................................................................................................9
3.1 IOSYS.INI .........................................................................................................................................................9
3.2 CODESYS.INI...................................................................................................................................................10
3.2.1 DEBUG entry...........................................................................................................................................11
3.2.2 CODESIZE entry .....................................................................................................................................11
3.2.3 DATASIZE entry ......................................................................................................................................11
3.2.4 RESET entry............................................................................................................................................11
3.2.5 RELOAD entry.........................................................................................................................................11
3.2.6 CLEAROUTPUT entry.............................................................................................................................12
3.2.7 RETAIN entry ..........................................................................................................................................12
3.2.8 RETAINSIZE entry ..................................................................................................................................12
3.2.9 PORT entry..............................................................................................................................................13
3.2.10 PRIOIEC entry (CoDeSys IEC1131 tasks)............................................................................................13
3.2.11 PRIOSYSTEM entry (CoDeSys system tasks) .....................................................................................13
3.2.12 PRIOINTERNAL entry ...........................................................................................................................14
4 SERIAL CONNECTION TO THE RUNTIME SYSTEM .........................................................................................15
4.1 KRC1-SPECIFIC SETTINGS ................................................................................................................................15
4.2 CODESYS-SPECIFIC SETTINGS ..........................................................................................................................16
4.2.1 SERIAL entry...........................................................................................................................................16
4.2.2 COM entry ...............................................................................................................................................16
4.2.3 BAUDRATE entry ....................................................................................................................................16
4.2.4 STOPBITS entry......................................................................................................................................16
4.2.5 PARITY entry...........................................................................................................................................16
5 DATA EXCHANGE WITH THE KRC.....................................................................................................................17
5.1 PERIPHERAL I/OS .............................................................................................................................................17
5.1.1 Analog I/Os..............................................................................................................................................18
5.2 COMMUNICATION I/OS .......................................................................................................................................19
6 EXTERNAL LIBRARIES........................................................................................................................................20
6.1 LINKING A LIBRARY TO AN IEC1131 PROJECT .....................................................................................................20
6.2 MAKING THE LIBRARY ACCESSIBLE TO THE RUNTIME SYSTEM ..............................................................................20
6.2.1 LIBPATH entry.........................................................................................................................................20
6.2.2 LIBRARIES entry.....................................................................................................................................20
6.3 KRCLIB LIBRARY ..............................................................................................................................................21
6.3.1 Various functions .....................................................................................................................................21
6.3.1.1 Transmit notification messages ....................................................................................................................... 21
6.3.2 Read/write robot values...........................................................................................................................21
6.3.2.1 Axis data type................................................................................................................................................... 21
6.3.2.2 Position data type............................................................................................................................................. 21
6.3.2.3 Read $AXIS_ACT ............................................................................................................................................ 22
6.3.2.4 Read $POS_ACT............................................................................................................................................. 22
6.3.2.5 Read $ACT_TOOL........................................................................................................................................... 22
6.3.2.6 Read $ACT_BASE ........................................................................................................................................... 22
6.3.2.7 Read/write $OV_PRO ...................................................................................................................................... 23
6.3.2.8 Read/write $SEN_INT ...................................................................................................................................... 24
8 APPENDIX .............................................................................................................................................................26
8.1 TERMS / ABBREVIATIONS ..................................................................................................................................26
8.2 LIST OF ILLUSTRATIONS .....................................................................................................................................26
1 Introduction
The CoDeSys runtime system is an IEC1131-3 compatible Soft PLC with outstanding speed
and flexibility. It has been integrated into the KRC1 controller to accomplish automation tasks
that cannot be implemented using the KRL programming language.
Since at this time the KRC1 has no single interface for dynamically reloading software modules,
CoDeSys is loaded and parameterized via a CALL-P driver shell.
To make it possible for CoDeSys to communicate with the KRC1 and use its inputs and
outputs, a CoDeSys driver has been developed which has read and write access to the I/O
system of the KRC.
CoDeSys can also access current robot data via libraries such as $OV_PRO or $POS_ACT.
2 Installation
2.2 Procedure:
The runtime system is installed from the ModularAutomation CD. This CD also contains the
CoDeSys SP development system and the OPC server. Place the CD in the CD-ROM drive of
the KRC1. An autorun.exe starts the installation process automatically. Alternatively, this can
also be done via the command “Run...” <CD-ROM drive>:\Setup.exe, or directly by double-
clicking on the file Setup.exe in Windows Explorer. In order to be able to switch to the Windows
interface, the KRC GUI must first be minimized. To do this, click with the left mouse button on
the status bar of the KRC GUI.
The installation process for ModularAutomation is carried out in 2 phases. In Phase 1, the
required components are selected, and the corresponding files are copied. Then an update of
Winsock2 and installation of DCOM are carried out. DCOM stands for Distributed Component
Object Module; it contains the base technology for network communication. These are
Microsoft-specific applications. After DCOM and Winsock2 have been installed, turn off the
KRC1 via the main switch. Phase 1 is now complete.
Now switch the controller on again. The installation will continue with Phase 2 automatically. In
Phase 1, the installation program has already removed the shortcut to Cross3.exe from the
autostart routine, and created a shortcut to the Setup.exe from ModularAutomation. In Phase 2,
the necessary Dlls will be copied into the Windows system directory, and the necessary registry
entries will be made.
The port number from the file CoDeSys.ini will be selected and displayed. This port number is
the communication channel from the CoDeSys development system to the runtime system. To
create a TCP/IP connection at a later time, this port number must be entered in the
communication parameters. Next, the OPC server is installed, provided it has been selected as
one of the components. Then the autostart routine is adapted. This means the shortcut to the
file Setup.exe is removed and the shortcut to Cross3.exe is created. Now Windows should be
“shut down” and restarted to complete the changes to the configuration. When the KRC GUI is
run up again, the runtime system will also be loaded.
Comment:
To install the runtime system, the memory area for VxWin must be enlarged. To do this, the
installation program changes the key VxWinRAM in the registry key path
HKEY_LOCAL_MACHINE\SOFTWARE\KUKA-Roboter GmbH\Cross3\Manager\Boot\VxWin to
the following value:
The old value of VxWinRAM will be saved in VxWinRAM_OLD in the same registry key path.
3 Configuration
3.1 IOSYS.INI
Since with earlier versions it was sometimes the case that during run-up of the KRC1 the
CoDeSys runtime system was interrupted by a “watchdog error”, now it is started with the first
read call. For this reason, it must be ensured that at least one input has been configured in the
CODESYS section of IOSYS.INI. For this purpose Setup enters the line “INB511=0” in this file.
If you later need this input byte for some other purpose, you can change the line back again.
In certain circumstances it is possible that the error mentioned above may also come up when
the $CONFIG.DAT file is changed. If this happens, the program must be reloaded (menu item
Online – Load) and restarted (menu item Online – Start).
After a successful installation, the file IOSYSINI will look like this:
[DRIVERS]
...
CODESYS=13,codesysInit,CodeSysDrv.o
...
[CODESYS]
INB511=0
...
[END SECTION]
In the above example, only the passages relevant for CoDeSys are shown.
3.2 CoDeSys.INI
As is usual with the KRC, parameters for CoDeSys are set by means of an INI file. This file
must be present in the “init” directory.
;--------------------------------------------------------------------------------------
; CODESYS INITIALISATION FILE: CODESYS.INI
;--------------------------------------------------------------------------------------
;
; Section [CODESYS]: settings
;--------------------------------------------------------------------------------------
;
; Options:
;
; DEBUG: 0: no printings on Telnet-shell (default: DEBUG=0)
; 1: printings are enabled
;
; Configuration:
;
; CODESIZE: number of kbytes to be reserved for IEC1131-3 code
;
; DATASIZE: number of kbytes to be reserved for IEC1131-3 data
;
; RESET: 0: CoDeSys is not reseted (default)
; 1: a CoDeSys start is executed
;
; RELOAD: 0: CoDeSys is not stoped on reload (default)
; 1: CoDeSys is stoped and started on reload
;
; CLEAROUTPUT 0: peripheral outputs are not clear when PLC is stopped
; 1: peripheral outputs are clear when PLC is stopped
;
; RETAIN: 0: retain data management is disabled
; 1: retain data management is enabled
;
; RETAINSIZE: amount of retain data in byte
;
; PORT: Portnumber to communicate with CoDeSys-Develoment program
;
; PRIORITYIEC: VxWorks base priority of IEC1131 tasks
;
; PRIORITYSYSTEM: VxWorks priority of CoDeSys sytem tasks, must be at least
; 32 higher than PRIORITYIEC
; PRIORITYINTERNAL: VxWorks priority for internal use
;
; SERIAL: 0: disable serial connection to runtime
; 1: enable serial connection to runtime
;
; COM: number of serial port to communicate with runtime
;
; BAUDRATE: 4800, 9600, 19200, 38400, 57600, 115200
;
; STOPBITS: 1 = 1 Stop Bit, 2 = 1.5 Bits, 3 = 2 Bits
;
; PARITY: 0 = none, 1 = odd, 2 = even
;
; LIBRARIES: comma seperated list of files including PLC-firmware functions
; e.g. Test1Lib.o,Test2Lib.o
;
; LIBPATH: path of directory with PLC firmware function libraries
; e.g. C:\Programs\CoDeSys\Lib
;
;--------------------------------------------------------------------------------------
; Section [EXCHANGE]: peripheral and communication i/o
;--------------------------------------------------------------------------------------
;
; INx=INy,Xn: (1) write n bytes from ROBOT inputs starting at byte y to PLC inputs starting at byte x
; OUTx=OUTy,Xn: (2) write n bytes from PLC outputs starting at byte x to ROBOT outputs starting at byte y
; INx=OUTy,Xn: (3) write n bytes from PLC outputs starting at byte x to ROBOT inputs starting at byte y
; OUTx=INy,Xn: (4) write n bytes from ROBOT outputs starting at byte y to PLC inputs starting at byte x
;
; --> left side is PLC side, right side is ROBOT side !
;
;--------------------------------------------------------------------------------------
[CODESYS]
DEBUG=1
CODESIZE=512
DATASIZE=128
RESET=1
RELOAD=1
CLEAROUTPUT=0
RETAIN=1
RETAINSIZE=1000
PORT=5555
PRIORITYIEC=202
PRIORITYSYSTEM=234
PRIORITYINTERNAL=200
SERIAL=0
COM=2
BAUDRATE=9600
STOPBITS=1
PARITY=0
LIBRARIES=KRC.o
LIBPATH=LIB
[EXCHANGE]
;IN1=IN2,x10 ; spsInByte(2) <- krcInByte(1) (1)
;OUT3=OUT4,x10 ; spsOutByte(3) -> krcOutByte(4) (2)
;IN5=OUT6,x10 ; spsInByte(5) <- krcOutByte(6) (3)
;OUT7=IN8,x10 ; spsOutByte(8) <- krcInByte(7) (4)
These displays should only be activated while the system is being commissioned or when
looking for faults.
For this purpose, call the utility Telnet.exe and connect it with the IP address 192.0.1.1.
Ä PORT=5555 Communication with the development system will take place via port 5555.
The Port parameter in Figure 1 must correspond to the PORT entry in the file CoDeSys.ini. The
parameter address must be set to 192.0.1.1.
If another dialog should appear on your screen, quit the development environment, go to the file
CoDeSys SP.ini in the Windows directory, and in the section [CoDeSys SP] add the entry
OldCommParams=No. Then restart the development environment.
CAUTION: This entry should only be changed by persons who can foresee any effects it
might have on the overall KRC1 system!
The example below shows the necessary settings for using COM2:
[SERIAL]
COM1=DISABLE ;Win95 mouse
COM2=ENABLE ;VxWorks
CAUTION: Since the KRC uses its own drivers, such as 3964R and WTC, which define their
own settings for the serial ports when the system is run up, these drivers cannot
be used if you want CoDeSys to access the runtime system serially.
In the example given below, 3 input bytes are read from the KRC1 starting at byte 2 and written
into the CoDeSys map starting at byte 1. The I/O data are therefore read from the field bus
assigned to input bytes 2 to 4 of the KRC1.
In the second line, 6 output bytes are read from the CoDeSys map starting at byte 4 and written
into the KRC1 map starting at output byte 5. The data are output to the field bus assigned to
output bytes 5 to 10 of the KRC1.
[EXCHANGE]
IN1=IN2,x3 ;spsInByte(1) <- krcInByte(2) (1)
OUT4=OUT5,x6 ;spsOutByte(4) -> krcOutByte(5) (2)
In this case the Interbus input byte 0 would be read into byte 1 of the PLC. Output byte 4 of the
PLC would be written to Interbus byte 7.
In the first line of the example given below, 9 output bytes of the KR C1 are read starting at byte
8 and written into the input map of CoDeSys starting at byte 7.
In the second line, 12 output bytes of CoDeSys are read starting at byte 10 and written into the
input map of the KRC1 starting at byte 11.
[EXCHANGE]
IN7=OUT8,x9 ; spsInByte(7) <- krcOutByte(8) (3)
OUT10=IN11,x12 ; spsOutByte(10) -> krcInByte(11) (4)
6 External libraries
External libraries written and compiled in “C” can be accessed from CoDeSys. Such a library
comprises two parts:
• A file with a *.lib extension, which contains a description of the interface from the IEC1131
program to the library functions.
• A file with a *.o extension, which contains the executable code for the library.
TYPE Axis :
STRUCT
A1: REAL;
A2: REAL;
A3: REAL;
A4: REAL;
A5: REAL;
A6: REAL;
END_STRUCT
END_TYPE
Figure 6 - ReadAxisAct
Figure 7 - OvPro
Figure 7 shows as an example how $OV_PRO can be read, divided by 2, and then written
again.
Figure 8 - SenInt
Figure 8 shows as an example how $SEN_INT[1] can be read, incremented by 2, and then
written again.
6.3.2.9 Read/write $SEN_PREA
In order to give the KRL programmer the capability of making other KRC1 variables accessible
via the sensor interface, 20 freely available real values have been inserted. The associated
index can assigned within the range from 1 to 20.
7 Communication
In 3.2.6 and 4 a description was given of how to set the communication parameters in order to
create a connection between the runtime system and the development system on the local PC
(i.e. the KRC). In most cases, the development system is installed only on a remote computer,
which is used to control more than one runtime system, which are located on different KRC1
systems.
Figure 9 shows as an example one PC (line PC) with a development system, and 2 KRC1
systems with runtime systems, all with their respective IP addresses. It must be ensured that
the gateway.exe application is always started on the KRC systems. If this is not the case, copy
a shortcut to this application, located in the Windows system directory, into the Autostart group
of the relevant KRC1.
To establish a connection with the controller KRC1-1 in the above example, call the
communication parameters and click on “Gateway ...”. In the dialog that appears, enter the IP
address of the controller in the ComboBox “Address”. In the example, this is “172.16.0.88”.
After that you still must enter the communication parameters of the runtime system, as
described in 3.2.6.
8 Appendix