You are on page 1of 26

LP Elektronik GmbH

User Manual
CoDeSys SP Runtime System
for KRC1 V2.2.2 or later and
VKRC1 V1.2 or later

Responsible: Thomas Schmitt


Created: 1999-03-17
Version: 1.0
Copyright: LP Elektronik GmbH
CoDeSys SP Runtime System
for KRC1 V2.2.2 or later and
VKRC1 V1.2 or later
HISTORY
Date Author Modified Version
1999-03-17 Thomas Schmitt Created 1.0
1999-05-07 Thomas Schmitt 1.1
1999-07-07 Felix Merz Description CLEAROUTPUT modified 1.2

ã1999-05-11 • LP Elektronik GmbH CoDeSys SP für KRC Benutzerhandbuch_e.doc – Version 1.1 2 / 26


CoDeSys SP Runtime System
for KRC1 V2.2.2 or later and
VKRC1 V1.2 or later
CONTENTS

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

ã1999-05-11 • LP Elektronik GmbH CoDeSys SP für KRC Benutzerhandbuch_e.doc – Version 1.1 3 / 26


CoDeSys SP Runtime System
for KRC1 V2.2.2 or later and
VKRC1 V1.2 or later
6.3.2.9 Read/write $SEN_PREA .................................................................................................................................. 24
7 COMMUNICATION................................................................................................................................................25

8 APPENDIX .............................................................................................................................................................26
8.1 TERMS / ABBREVIATIONS ..................................................................................................................................26
8.2 LIST OF ILLUSTRATIONS .....................................................................................................................................26

ã1999-05-11 • LP Elektronik GmbH CoDeSys SP für KRC Benutzerhandbuch_e.doc – Version 1.1 4 / 26


1 Introduction CoDeSys Runtime System
for KRC1 V2.2.2 or later and
VKRC1 V1.2 or later

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.1 System and installation requirements


System requirements for installation of the runtime system:
Ä KR C1 V2.2.2 or later, or VKR C1 V1.2 or later
Ä 64 MB RAM main memory
Ä If the development environment is being installed, approx. 25 MB free hard disk space
Ä Serial mouse

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.

ã1999-05-11 • LP Elektronik GmbH CoDeSys SP für KRC Benutzerhandbuch_e.doc – Version 1.1 5 / 26


2 Installation CoDeSys Runtime System
for KRC1 V2.2.2 or later and
VKRC1 V1.2 or later

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:

VxWinRAM = 0x01100000 (DEC=17825792)

The old value of VxWinRAM will be saved in VxWinRAM_OLD in the same registry key path.

ã1999-05-11 • LP Elektronik GmbH CoDeSys SP für KRC Benutzerhandbuch_e.doc – Version 1.1 6 / 26


2 Installation CoDeSys Runtime System
for KRC1 V2.2.2 or later and
VKRC1 V1.2 or later

2.3 Files and Directories


The CoDeSys runtime system, the development environment and the OPC server consist of the
files listed below. After being installed initially or updated, these files are located in their
respective directories.

2.3.1 Runtime system


File name Function Directory
CoDeSys.o CoDeSys runtime system C:\Program Files\KRC\BIN
CoDeSysDrv.o CoDeSys driver shell C:\Program Files\KRC\DRIVERS
CoDeSys.ini CoDeSys configuration file C:\Program Files\KRC\INIT
KrcLib.o External CoDeSys library for KRC functions C:\Program Files\KRC\LIB
CoDeSys.log CoDeSys log file C:\Program Files\KRC\LOG
CoDeSys.hst CoDeSys histogram file C:\Program Files\KRC\LOG
Retain.bin CoDeSys file for retain variables C:\Program Files\KRC
(This file is created automatically when the
KRC1 is switched off!!)

ã1999-05-11 • LP Elektronik GmbH CoDeSys SP für KRC Benutzerhandbuch_e.doc – Version 1.1 7 / 26


2 Installation CoDeSys Runtime System
for KRC1 V2.2.2 or later and
VKRC1 V1.2 or later

2.3.2 Development environment


File name Function Directory
CoDeSys SP.exe CoDeSys development environment ..\english
Multi3.pro CoDeSys development environment ..\ide
Codesys.cnt CoDeSys development environment ..\ide
Codesys SP.hlp CoDeSys online help ..\english
D2htls32.dll CoDeSys online help ..\ide\english
Default.dfr CoDeSys layout for printing out ..\ide\english
Standard.LIB CoDeSys standard library ..\lib
Iecsfc.lib CoDeSys library for SFC ..\lib
KrcLib.lib CoDeSys library for sensor data ..\lib
STANDARD.OBJ CoDeSys library function ..\lib
LP.ico Icon for StartServer ..\die
Codesys.ico Icon for development environment ..\die
Ole32.dll Windows Dll C:\Windows\System32
Oleaut32.dll Windows Dll C:\Windows\System32
Advapi32.dll Windows Dll C:\Windows\System32
Msvcrt.dll Windows Dll C:\Windows\System32
Wsock32.dll Windows Dll C:\Windows\System32
Rpcrt4.dll Windows Dll C:\Windows\System32
GClient.dll Communications Dll C:\Windows\System32
GdrvBase.dll Communications Dll C:\Windows\System32
GSymbol.dll Communications Dll C:\Windows\System32
GUtil.dll Communications Dll C:\Windows\System32
Regsvr32.exe OLE registration function C:\Windows\System32
Gateway.exe Module for communication with runtime C:\Windows\System32
Dcom98.exe Microsoft DCOM ..\ide
Dcm98cfg.exe Microsoft DCOM ..\ide
Ws2setup.exe Microsoft Winsock2 update ..\ide

2.3.3 OPC server


CoDeSysOPC.exe CoDeSys OPC server ..\ide
OCS_PROXY.dll Communications Dll for OPC server ..\ide
StartServer.exe Control function for CoDeSysOPC.exe ..\ide
OPCRead.exe Test client for CoDeSysOPC server ..\ide

ã1999-05-11 • LP Elektronik GmbH CoDeSys SP für KRC Benutzerhandbuch_e.doc – Version 1.1 8 / 26


3 Configuration CoDeSys Runtime System
for KRC1 V2.2.2 or later and
VKRC1 V1.2 or later

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.

ã1999-05-11 • LP Elektronik GmbH CoDeSys SP für KRC Benutzerhandbuch_e.doc – Version 1.1 9 / 26


3 Configuration CoDeSys Runtime System
for KRC1 V2.2.2 or later and
VKRC1 V1.2 or later

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)

ã1999-05-11 • LP Elektronik GmbH CoDeSys SP für KRC Benutzerhandbuch_e.doc – Version 1.1 10 / 26


3 Configuration CoDeSys Runtime System
for KRC1 V2.2.2 or later and
VKRC1 V1.2 or later

3.2.1 DEBUG entry


This entry specifies whether test outputs are to be displayed on the TelNet shell.
Ä DEBUG=0: apart from error messages, nothing is displayed on the TelNet shell.
Ä DEBUG=1: test outputs are displayed on the TelNet shell.

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.

3.2.2 CODESIZE entry


This entry specifies how much memory space is to be made available to the runtime system for
loading program code. After an IEC1131 program translation procedure, the minimum memory
required for that program will be displayed in the output window of the development
environment. If not enough memory is available for the program, then when the program is
loaded an error message will be displayed in the development environment. If this happens,
then the parameters must be adapted accordingly.
The size of the memory space is shown in KBytes.
Ä CODESIZE=250 ;reserve 250kbytes for IEC1131 code

3.2.3 DATASIZE entry


This entry specifies how much memory space is to be made available to the runtime system for
loading data. After an IEC1131 program translation procedure, the minimum memory required
for data will be displayed in the output window of the development environment. If not enough
memory is available for the program, then when the program is loaded an error message will be
displayed in the development environment. If this happens, then the parameters must be
adapted accordingly.
The size of the memory space is shown in KBytes.
Ä DATASIZE=64 ;reserve 64kbytes for IEC1131 data

3.2.4 RESET entry


Each driver can be reset from the GUI. With this entry, the reset mode of CoDeSys can be
selected.
Ä RESET=0 CoDeSys is not affected by the user action.
Ä RESET=1 CoDeSys is stopped and subsequently restarted without the variables being affected.

3.2.5 RELOAD entry


If the user selects “Reconfigure I/O system” on the GUI, drivers are reloaded and changes in
configuration files take effect. As CoDeSys cannot be reloaded, this entry offers an opportunity
of specifying whether it should be stopped and restarted.
Ä RELOAD=0 CoDeSys is not affected by the user action.
Ä RELOAD=1 CoDeSys is stopped and subsequently restarted without the variables being affected.

ã1999-05-11 • LP Elektronik GmbH CoDeSys SP für KRC Benutzerhandbuch_e.doc – Version 1.1 11 / 26


3 Configuration CoDeSys Runtime System
for KRC1 V2.2.2 or later and
VKRC1 V1.2 or later

3.2.6 CLEAROUTPUT entry


With the aid of this entry, it can be defined whether PLC peripheral outputs are clear or not
clear when the PLC is stopped.
Ä CLEAROUTPUT=0 peripheral outputs are not clear when PLC is stopped.
Ä CLEAROUTPUT=1 peripheral outputs are clear when PLC is stopped.

3.2.7 RETAIN entry


This entry can be used to define whether remanent data should be made available to the
runtime system. In the event of a KRC power failure, these data will be saved to a file, and
reloaded when the controller is restarted.
Ä RETAIN=0 No remanent data are made available to the runtime system.
Ä RETAIN=1 Remanent data are made available to the runtime system.

3.2.8 RETAINSIZE entry


This entry specifies how many bytes are to be made available to the runtime system for
remanent data. This command is only evaluated if the entry RETAIN=1 is present. See also
3.2.4.
Ä RETAINSIZE=128 128 bytes will be reserved for remanent data

ã1999-05-11 • LP Elektronik GmbH CoDeSys SP für KRC Benutzerhandbuch_e.doc – Version 1.1 12 / 26


3 Configuration CoDeSys Runtime System
for KRC1 V2.2.2 or later and
VKRC1 V1.2 or later

3.2.9 PORT entry


This entry specifies the TCP/IP port used by the CoDeSys development environment to
communicate with the runtime module. This port number must correspond to the number
specified in the development environment under the menu item “Online – Communication
Parameters”.

Ä PORT=5555 Communication with the development system will take place via port 5555.

Figure 1 - TCP/IP communication parameters

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.

3.2.10 PRIOIEC entry (CoDeSys IEC1131 tasks)


The CoDeSys development environment allows the assignment of 32 priority levels, which can
be mapped on the runtime system by means of the PRIOIEC entry. The priority level to be
assigned to the highest-priority IEC1131 task is entered here. The default setting for this entry
is 202.
Ä PRIOIEC=202

CAUTION: This entry should only be changed by persons who can foresee any effects it
might have on the overall KRC1 system!

3.2.11 PRIOSYSTEM entry (CoDeSys system tasks)


The CoDeSys system task has the functions of communication with the development
environment, debugging and memory management. This entry must be at least 32 higher than
the PRIOIEC entry.
Ä PRIOSYSTEM=234

ã1999-05-11 • LP Elektronik GmbH CoDeSys SP für KRC Benutzerhandbuch_e.doc – Version 1.1 13 / 26


3 Configuration CoDeSys Runtime System
for KRC1 V2.2.2 or later and
VKRC1 V1.2 or later
3.2.12 PRIOINTERNAL entry
An additional priority level is necessary for internal management purposes. This priority is freely
selectable, but should be matched to the complete system.
Ä PRIORITYINTERNAL=200

ã1999-05-11 • LP Elektronik GmbH CoDeSys SP für KRC Benutzerhandbuch_e.doc – Version 1.1 14 / 26


4 Serial connection to the runtime system CoDeSys Runtime System
for KRC1 V2.2.2 or later and
VKRC1 V1.2 or later

4 Serial connection to the runtime system


Communication with the runtime system over a serial connection requires the use of a null-
modem cable to connect an external Windows PC with the KRC1. It is then necessary to adapt
the communication parameters on the external Windows PC to match the serial port in the
CoDeSys development system. To do this, call up the communication parameters and add an
additional channel with the desired parameters. After that, the communication parameters
should look like those in Figure 2 below. Then activate the channel by double-clicking on it. The
parameters entered here refer to the external Windows PC.

Figure 2 - Serial communication parameters

4.1 KRC1-specific settings


The port being used on the KRC1 controller must also be assigned to VxWin. To do this, edit
the file hw_inf.ini in the init directory. The entry COM1 or COM2 in the [SERIAL] section must
be set to ENABLE. Please note that normally the serial Windows mouse is connected to the
COM1 port. That means that if you use this connection, you will not be able to use the mouse in
Windows.

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.

ã1999-05-11 • LP Elektronik GmbH CoDeSys SP für KRC Benutzerhandbuch_e.doc – Version 1.1 15 / 26


4 Serial connection to the runtime system CoDeSys Runtime System
for KRC1 V2.2.2 or later and
VKRC1 V1.2 or later

4.2 CoDeSys-specific settings


The runtime system must also be told what the required parameters are. Again, these are
entered in the file CoDeSys.ini.

4.2.1 SERIAL entry


With this entry you specify whether serial communication is to be used.
Ä SERIAL=0 The serial connection is deactivated
Ä SERIAL=1 The serial connection is activated; the additional parameters will be evaluated

4.2.2 COM entry


With this entry you select the serial port to be used. This entry refers to the KRC side. Since the
KRC1 controller has 2 serial ports as standard, either 1 or 2 can be entered here. Please note,
however, that the first port is reserved for the Windows mouse.
Ä COM=1 The first serial port will be used; possible conflict with mouse. The 9-pin connection is located on
the front side of the controller, and is accessible from the outside.
Ä COM=2 The second serial port will be used. The 25-pin connection is located on the inside of the control
cabinet. A 9 - 25 pin adapter may be necessary.

4.2.3 BAUDRATE entry


With this entry you select the baud rate to be used to communicate with the runtime system.
This value must correspond to the one entered in the communication parameters on the
external Windows PC. The choices available are 4800, 9600, 19200, 38400, 57600 and
115200.
Ä BAUDRATE=9600

4.2.4 STOPBITS entry


With this entry you select the number of stop bits to be used for communicating with the runtime
system. This value must correspond to the one entered in the communication parameters on
the external Windows PC.
Ä STOPBITS=1 One stop bit will be used
Ä STOPBITS=2 1½ stop bits will be used
Ä STOPBITS=3 Two stop bits will be used

4.2.5 PARITY entry


With this entry you select the parity to be used for communicating with the runtime system. This
value must correspond to the one entered in the communication parameters on the external
Windows PC.
Ä PARITY=0 No parity check will be made
Ä PARITY=1 An odd parity check will be made
Ä PARITY=2 An even parity check will be made

ã1999-05-11 • LP Elektronik GmbH CoDeSys SP für KRC Benutzerhandbuch_e.doc – Version 1.1 16 / 26


5 Data exchange with the KRC CoDeSys Runtime System
for KRC1 V2.2.2 or later and
VKRC1 V1.2 or later

5 Data exchange with the KRC


Peripheral and communication I/Os are configured in the file CoDeSys.ini in the EXCHANGE
section.

5.1 Peripheral I/Os


Peripheral I/Os are involved when CoDeSys accesses inputs and outputs of the KRC that exist
physically. Figure 3 below provides a schematic representation of the interaction of the two
applications KR C1 and CoDeSys, and also shows the necessary parameters.

Figure 3 - Peripheral I/Os

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)

A corresponding IOSYS.INI file could look like this:


[INTERBUS]
INW2=0,x3
OUTW5=7,x6

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.

ã1999-05-11 • LP Elektronik GmbH CoDeSys SP für KRC Benutzerhandbuch_e.doc – Version 1.1 17 / 26


5 Data exchange with the KRC CoDeSys Runtime System
for KRC1 V2.2.2 or later and
VKRC1 V1.2 or later
5.1.1 Analog I/Os
If analog inputs and/or outputs of the field bus are to be accessed from the CoDeSys runtime
system, then these inputs and/or outputs must not be declared as such in the file IOSYS.INI.
Rather, the field bus I/Os on which the analog modules are mapped must be declared as digital
I/Os. To make these I/Os accessible to CoDeSys, the [EXCHANGE] section must be adapted
accordingly.
The I/Os must then be converted in CoDeSys to their actual analog values.

ã1999-05-11 • LP Elektronik GmbH CoDeSys SP für KRC Benutzerhandbuch_e.doc – Version 1.1 18 / 26


5 Data exchange with the KRC CoDeSys Runtime System
for KRC1 V2.2.2 or later and
VKRC1 V1.2 or later

5.2 Communication I/Os


Communication I/Os have been introduced to give CoDeSys the capability of exchanging data
with the KRC via physically non-existent inputs and outputs. Outputs configured in CoDeSys
are transferred directly to the input map of the KRC. Read accesses to inputs configured in this
way are redirected to KRC outputs. This process is illustrated in Figure 4 below.

Figure 4 - Communication I/Os

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)

ã1999-05-11 • LP Elektronik GmbH CoDeSys SP für KRC Benutzerhandbuch_e.doc – Version 1.1 19 / 26


6 External libraries CoDeSys Runtime System
for KRC1 V2.2.2 or later and
VKRC1 V1.2 or later

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.

6.1 Linking a library to an IEC1131 project


To link a library to a project, go to the development environment and call up Library Manager
via menu item “Window”. Then call the menu item “Insert - Additional Library” and open the
library file. After you have done this, you can then use the functions of the library.

6.2 Making the library accessible to the runtime system


The CoDeSys runtime system is able to dynamically reload libraries. For this purpose the
runtime system needs to know which files are to be loaded, and where they are located. Again,
this information is stored in the file CoDeSys.ini in the section [CODESYS].

6.2.1 LIBPATH entry


This entry specifies where the library files are located. The default setting for this is the \Lib
directory under the KRC directory.
Ä LIBPATH=C:\PROGRAM FILES\KRC\LIB Absolute path
Ä LIBPATH=LIB Relative path under KRC

6.2.2 LIBRARIES entry


This entry specifies which library files are to be used. The individual file names must be
separated from one another by commas. Ensure that no blank spaces appear directly before
or after the comma.
Ä LIBRARIES=KRCLib.o One library file
Ä LIBRARIES=KRCLib.o,TestLib.o Two library files

ã1999-05-11 • LP Elektronik GmbH CoDeSys SP für KRC Benutzerhandbuch_e.doc – Version 1.1 20 / 26


6 External libraries CoDeSys Runtime System
for KRC1 V2.2.2 or later and
VKRC1 V1.2 or later

6.3 KRCLib library


This library makes read/write access to robot data possible. Since the corresponding robot
functions are called every time a function block is called, it makes sense to read the values to a
variable only once per cycle, and then access the variable.

6.3.1 Various functions


6.3.1.1 Transmit notification messages
With the DisplayKCPNotifyMsg function it is possible to display notification messages in the
GUI message window. This function should not be called cyclically, since it is possible that the
message window will “overflow”. The example below shows how a one-time message can be
displayed whenever the runtime system is started.

Figure 5 - Transmit notification message

6.3.2 Read/write robot values


6.3.2.1 Axis data type
The AXIS data type contains 6 axis values in a floating-point display, and is used in the library
function ReadAxisAct.

TYPE Axis :
STRUCT
A1: REAL;
A2: REAL;
A3: REAL;
A4: REAL;
A5: REAL;
A6: REAL;
END_STRUCT
END_TYPE

6.3.2.2 Position data type


The POSITION data type contains 6 position values in a floating-point display, and a validity
byte.

ã1999-05-11 • LP Elektronik GmbH CoDeSys SP für KRC Benutzerhandbuch_e.doc – Version 1.1 21 / 26


6 External libraries CoDeSys Runtime System
for KRC1 V2.2.2 or later and
VKRC1 V1.2 or later
It is used in the library functions ReadPosAct, ReadBaseAct and ReadToolAct.
TYPE Position :
STRUCT
Valid: BYTE;
X: REAL;
Y: REAL;
Z: REAL;
A: REAL;
B: REAL;
C: REAL;
END_STRUCT
END_TYPE

6.3.2.3 Read $AXIS_ACT


The variable $AXIS_ACT mirrors the current axis actual values of the robot position and
consists of the 6 angle values A1-A6.

Figure 6 - ReadAxisAct

6.3.2.4 Read $POS_ACT


The variable $POS_ACT mirrors the current position actual values of the robot path. These
values are only valid when a LIN or CIRC command is being executed. For this reason, a
validity byte (Valid) is formed, which indicates whether the current position is valid.
This information is read with the function block ReadPosAct.
6.3.2.5 Read $ACT_TOOL
The variable $POS_TOOL mirrors the current position of the tool origin. A validity byte has
been inserted since it is possible for no tool to be active.
This information is read with the function block ReadToolAct.
6.3.2.6 Read $ACT_BASE
The variable $ACT_BASE mirrors the current position of the base origin. A validity byte has
been inserted since it is possible for no tool to be active.
This information is read with the function block ReadBaseAct.

ã1999-05-11 • LP Elektronik GmbH CoDeSys SP für KRC Benutzerhandbuch_e.doc – Version 1.1 22 / 26


6 External libraries CoDeSys Runtime System
for KRC1 V2.2.2 or later and
VKRC1 V1.2 or later

6.3.2.7 Read/write $OV_PRO


The variable $OV_PRO contains the current override of the KRC1. This value can be read with
the function block ReadOvPro, and written with WriteOvPro. If the value is written cyclically,
ensure that it can no longer be changed from the GUI.

Figure 7 - OvPro

Figure 7 shows as an example how $OV_PRO can be read, divided by 2, and then written
again.

ã1999-05-11 • LP Elektronik GmbH CoDeSys SP für KRC Benutzerhandbuch_e.doc – Version 1.1 23 / 26


6 External libraries CoDeSys Runtime System
for KRC1 V2.2.2 or later and
VKRC1 V1.2 or later
6.3.2.8 Read/write $SEN_INT
In order to give the KRL programmer the capability of making other KRC1 variables accessible
via the sensor interface, 20 freely available integer values have been inserted. The associated
index can be assigned within the range from 1 to 20.

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.

ã1999-05-11 • LP Elektronik GmbH CoDeSys SP für KRC Benutzerhandbuch_e.doc – Version 1.1 24 / 26


7 Communication CoDeSys Runtime System
for KRC1 V2.2.2 or later and
VKRC1 V1.2 or later

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.

Figure 9 - Network connection

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.

Figure 10 - Gateway communication parameters

ã1999-05-11 • LP Elektronik GmbH CoDeSys SP für KRC Benutzerhandbuch_e.doc – Version 1.1 25 / 26


8 Appendix CoDeSys Runtime System
for KRC1 V2.2.2 or later and
VKRC1 V1.2 or later
CoDeSys is not multi-resource capable at this time, i.e. the communication parameters must be
changed before connecting with any other runtime system. Since the parameters are stored in
the project, it is also possible to create an individual project for each controller.
Later versions of the development environment will contain improvements in this regard.

8 Appendix

8.1 Terms / Abbreviations


Ä CoDeSys Controller Development System
Ä KRC KUKA Roboter Controller
Ä VKRC KUKA Roboter Controller (VW version)
Ä KRL KUKA Robot Language
Ä PLC Programmable Logic Controller
Ä GUI Graphic user interface of the KRC
Ä DCOM Distributed Component Object Module

8.2 List of illustrations


Figure 1 - TCP/IP communication parameters .........................................................................................................13
Figure 2 - Serial communication parameters ............................................................................................................15
Figure 3 - Peripheral I/Os..........................................................................................................................................17
Figure 4 - Communication I/Os .................................................................................................................................19
Figure 5 - Transmit notification message..................................................................................................................21
Figure 6 - ReadAxisAct .............................................................................................................................................22
Figure 7 - OvPro........................................................................................................................................................23
Figure 8 - SenInt .......................................................................................................................................................24
Figure 9 - Network connection ..................................................................................................................................25
Figure 10 - Gateway communication parameters .....................................................................................................25

ã1999-05-11 • LP Elektronik GmbH CoDeSys SP für KRC Benutzerhandbuch_e.doc – Version 1.1 26 / 26