24.01.2015 Views

PLC Programming

  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

9 - DDE Communication with CoDeSys<br />

9 DDE Communication with CoDeSys<br />

CoDeSys has a DDE (dynamic data exchange) interface for reading data. CoDeSys uses this<br />

interface to provide other applications that also use a DDE Interface with the contents of control<br />

variables and IEC addresses<br />

If the GatewayDDEServer is used, which works with symbols, CoDeSys is not needed to read<br />

variables values from the <strong>PLC</strong> and to transfer them to applications with an DDE interface.<br />

Attention: Direct addresses cannot be read over the DDE server ! For this case you have to define<br />

variables in CoDeSys which are assigned to the desired addresses (AT).<br />

Attention: The DDE interface has been tested with Word 97 and Excel 97 on Windows NT 4.0. If the DDE<br />

communication fails caused by a mismatch of other versions or additionally installed programs on a<br />

computer, 3S – Smart Software Solutions cannot take any responsibility.<br />

9.1 DDE interface of the CoDeSys programming system...<br />

Activating the DDE Interface<br />

The DDE interface becomes active as soon as the <strong>PLC</strong> (or the simulation) is logged in.<br />

General Approach to Data<br />

A DDE inquiry can be divided into three parts:<br />

1. Name of the program (here: CoDeSys),<br />

2. File name and<br />

3. Variable name to be read.<br />

Name of the program: CoDeSys<br />

File name: complete project path (c:\example\example.pro).<br />

Variable name: The name of a variable as it appears in the Watch and Receipt Manager .<br />

Which variables can be read<br />

All addresses and variables are readable. Variables or addresses should be entered in the format<br />

used in the Watch and Receipt Manager<br />

Examples:<br />

%IX1.4.1 (* Reads the input 1.4.1*)<br />

<strong>PLC</strong>_PRG.TEST<br />

(* Reads the variable TEST from the POU <strong>PLC</strong>_PRG*)<br />

.GlobVar1 (* Reads the global variable GlobVar1 *)<br />

Linking variables using WORD<br />

In order to get the current value of the variable TEST from the POU <strong>PLC</strong>_PRG through the DDE<br />

interface in Microsoft WORD, a field (e.g., the date) must be inserted in WORD ('Insert' "Field"). Now<br />

when you click on the field with the right mouse button and select the command "Toggle Field Codes"<br />

you can change the field function for the chosen text. In our example, this would look as follows:<br />

{ DDEAUTO CODESYS "C:\CODESYS\PROJECT\IFMBSP.PRO" "<strong>PLC</strong>_PRG.TEST" }<br />

Click on the field with the right mouse button again, then click on "Update Field" and the desired<br />

variable content appears in the text.<br />

Linking variables using EXCEL<br />

The following must be entered in Microsoft EXCEL before you can assign a variable to a cell.<br />

CoDeSys V2.3 9-1

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!