Sunteți pe pagina 1din 11

Festo AG & Co.

KG

Easy data exchange


via Festo EasyIP
Tutorial for providing an EasyIP server in CoDeSys runtime and easily
exchange data between a PC and the Festo device.

Gernot Lechner - at0gl


2 Easy data exchange via Festo EasyIP

Contents
Requirements..........................................................................................................................................3

Overview................................................................................................................................................3

EasyIP.................................................................................................................................................3

If you are running a firewall...................................................................................................................3

The CoDeSys project..............................................................................................................................5

Adding Festo_EasyIP.lib library.........................................................................................................5

Creating an "Easy_Server()" task........................................................................................................5

Festo IPC TCP/IP Application...............................................................................................................7

Example of a CoDeSys server application..............................................................................................8

CoDeSys declaration area...................................................................................................................8

CoDeSys code area.............................................................................................................................9

PLCs with byte addressing mode...........................................................................................................9

Festo AG & Co.KG


3 Easy data exchange via Festo EasyIP

Requirements
This description requires any Linux based Festo device (i. e. CPX-CEC, SBO..-Q) with CoDeSys
runtime system integrated (addressing mode = word aligned; see also PLCs with byte addressing
mode).

Overview
This documentation describes how to easily exchange data between a PC and a Festo device. It gives
detailed information on starting an EasyIP server in the CoDeSys runtime and how to connect to this
server with your PC running an EasyIP client program. To establish such a connection the program
"IPC TCP/IP Application" from Festo and the Festo_EasyIP.lib library are used.

EasyIP
EasyIP is a proprietary Ethernet protocol from Festo.
EasyIP is UDP based and uses port 995.
It allows a simple connection of different Festo controllers to form a network.

If you are running a firewall


Usually firewalls are blocking the port 995 which is the default port that EasyIP uses. To use EasyIP
you have to open this port to enable data transfer between the server and the client. This section
exemplarily shows how to prepare the Windows firewall:

Open the Windows Firewall out of the Control Panel:


[Start][Settings][Control Panel][Windows Firewall]

Switch to the "Exceptions" tab and click the "Add Port..." button.

Festo AG & Co.KG


4 Easy data exchange via Festo EasyIP

The window "Add a Port" then opens.

In the "Name" field insert any description (e.g. EasyIP).


In the field "Port number" insert the port that has to be opened for connection (995 - the default EasyIP
port).
Make sure that the choice box "UDP" is enabled.
Confirm changes by clicking the "OK" button.

Festo AG & Co.KG


5 Easy data exchange via Festo EasyIP

The CoDeSys project


Adding Festo_EasyIP.lib library
To run an EasyIP server the CoDeSys library "Festo_EasyIP.lib" has to be loaded to your CoDeSys
project. Open the Library Manager with [Window][Library Manager].

Right-click in the upper left quarter of the window and select the option "Additional Library... ".
Choose the Festo_EasyIP.lib library and add it to your project by pressing the "open" button.

Now all functions of this library can be used in your project.

Creating an "Easy_Server()" task


To run the server you have to mount the Easy_Server(PRG) of the Festo_EasyIP.lib library to a cyclic
task that lasts 10 milliseconds. Open the "Task configuration" out of the "Resources Manager" in the
"Object Organizer": [Resources][Task configuration]

Right click to the white area in the left part of the window (while "Task configuration" is marked) and
then select the "Append Task" option.

Set following task attributes:


Name: Cyclic_Easy_Server
Priority: 10

Festo AG & Co.KG


6 Easy data exchange via Festo EasyIP

Make sure that the choice box "cyclic" is selected in the "Type" field.

In the "Properties" field set an time interval of 10 milliseconds: T#10ms

Now you have to append the "Easy_Server()" program to this task. Right click to white area again and
then select the option "Append Program Call".

In the area "Program Call:" you have to add the name of the server program of the Festo_EasyIP.lib
library: Easy_Server();
Because the Easy_Server() program is in the library it doesn't appear in the dialog box that opens
when clicking the "…" button (as all other programs do you created of your own).

When downloading the project to your Festo device and starting it the EasyIP server is reachable by
any EasyIP client.

Festo AG & Co.KG


7 Easy data exchange via Festo EasyIP

Festo IPC TCP/IP Application


Start the Festo IPC TCP/IP Application and switch to the "Misc" tab. In the "RemoteHost" area you
have to insert the IP address of the Server: e.g. 192.168.2.50.

Remember the default IP settings for Festo devices:

Default IP
Device
address

CPX-
192.168.2.50
CEC
SBO..-Q-
192.168.2.10

Then open the "EasyIPDemo" window by clicking the "EasyIP" button. This client application
immediately connects to the server.

Search for the flagword you want to set (e.g. FW2000) and double-click the "Value" area to edit the
value. The fields left to the "Value" area represent the bits of this flagword.

Festo AG & Co.KG


8 Easy data exchange via Festo EasyIP

In your CoDeSys server application you can directly refer to any of these flagwords.: e.g. with the
variable

wValueFW2000 at %MW2000 : WORD;

declared in the CoDeSys declaration area.

Example of a CoDeSys server application


The following simple CoDeSys example reads the value of the flagword FW800 of the CoDeSys
memory area.
According to this value the program does the following actions:
1 - udiCounter1 (Counter number 1) increases by one each cycle
2 - udiCounter2 (Counter number 2) increases by one each cycle
3 - Reset udiCounter1 (to zero)
4 - Reset udiCounter2 (to zero)
All other values are ignored.

CoDeSys declaration area


Create a CoDeSys declaration area looking like this:

PROGRAM PLC_PRG
VAR
udiAlive : UDINT := 0; (* counter to see if program is running *)
wValueFW AT %MW800 : WORD; (* "connection" to flagword 800 *)

udiCounter1 : UDINT := 0;
udiCounter2 : UDINT := 0;

Festo AG & Co.KG


9 Easy data exchange via Festo EasyIP

END_VAR

CoDeSys code area


udiAlive := udiAlive + 1;

IF EasyIPInit = 2 THEN (* Test if EasyIP server is running *)


CASE wValueFW OF
1:
udiCounter1 := udiCounter1 + 1;

2:
udiCounter2 := udiCounter2 + 1;

3: (* reset udiCounter1 *)
udiCounter1 := 0;

4: (* reset udiCounter2 *)
udiCounter2 := 0;

END_CASE;
ELSE
(* EasyIP Server is not running *)
;
END_IF;

Now you can download this small project to your PLC and start it. Of course the Easy_Server()
program must be added to this project to as stated in section "The CoDeSys project". Start the "Festo
IPC TCP/IP Application" and make all changes as described in section "Festo IPC TCP/IP
Application". When editing the FW800 flagword according to the list above "According to this value
…According to this value According to this value "According to this value According to this value
According to this value According to this value you can see the counters udiCounter1 and udiCounter2
changing their values in CoDeSys.

PLCs with byte addressing mode


The offsets inside the library have different meanings according to the target's device option "Byte
addressing mode" at register "General" of the "Target Settings" (Object Organizer register
"Resources")

The default setting for the Festo devices are

Device Byte adressing mode Example

ADR(%MW2) =
CPX-CEC OFF
ADR(%MB4)
SBO...-Q- ADR(%MW2) =
OFF
… ADR(%MB4)
CECX-X- ADR(%MW2) =
ON
… ADR(%MB2)

Festo AG & Co.KG


10 Easy data exchange via Festo EasyIP

Byte addressing mode

Word addressing mode

Some easy example code to test the alignment during the runtime is
PROGRAM PLC_PRG
VAR
xByteAligned : BOOL; (* TRUE if "Byte adressing mode" is activated *)
END_VAR

(* (ADR(%MW2) - ADR(%MW0) = 2 for byte alignment / 4 for word alignment *)


xByteAligned := NOT(DWORD_TO_BOOL((ADR(%MW2) - ADR(%MW0) - 2)));

Basically the Festo_EasyIP.lib up to version 1.4.2 has been developed for "word addressing mode"
devices, but it works also on "byte addressing mode" devices.
The only differences are the used offsets.

The function call


Easy_R(0, (* index of the remote station's IP address *)
1, (* operand type: memory word *)
2, (* number of words to receive *)
800, (* offset of first word to be received in local station *)
600, (* offset of first word in remote (target) station *)
1000); (* offset for communication status in local station *)

may be interpreted according to the addressing mode (assuming that the remote station has word
addressing mode):

SBO...-Q, CPX-CEC:
Receive 4 Bytes (= 2 words) from remote's offset %MW600 and write them starting with local offset
%MW800 (=%MB1600). As a result remote's %MW600 is on local %MW800 and remote's
%MW601 is at local %MW801. Status is available at offset %MW1000 (=%MB2000).

Festo AG & Co.KG


11 Easy data exchange via Festo EasyIP

CECX-X-…:
Receive 4 Bytes (= 2 words) from remote's offset %MW600 and write them starting with local offset
%MW1600 (=%MB1600). As a result remote's %MW600 is on local %MW1600 and remote's
%MW601 is at local %MW1602. Status is available at offset %MW2000 (=%MB2000).

Festo AG & Co.KG

S-ar putea să vă placă și