24.01.2015 Views

PLC Programming

  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

What is What in CoDeSys<br />

2 What is What in CoDeSys<br />

2.1 Project Components...<br />

Project<br />

A project contains all of the objects in a <strong>PLC</strong> program. A project is saved in a file named after the<br />

project. The following objects are included in a project:<br />

POUs (Program Organization Units), data types, visualizations, resources, and libraries.<br />

POU (Program Organization Unit)<br />

Function<br />

Functions, function blocks, and programs are POUs which can be supplemented by actions.<br />

Each POU consists of a declaration part and a body. The body is written in one of the IEC<br />

programming languages which include IL, ST, SFC, FBD, LD or CFC.<br />

CoDeSys supports all IEC standard POUs. If you want to use these POUs in your project, you must<br />

include the library standard.lib in your project.<br />

POUs can call up other POUs. However, recursions are not allowed.<br />

A function is a POU, which yields exactly one data element (which can consist of several elements,<br />

such as fields or structures) when it is processed, and whose call in textual languages can occur as<br />

an operator in expressions.<br />

When declaring a function do not forget that the function must receive a type. This means, after the<br />

function name, you must enter a colon followed by a type.<br />

A correct function declaration can look like this example:<br />

FUNCTION Fct: INT<br />

In addition, a result must be assigned to the function. That means that function name is used as an<br />

output variable.<br />

A function declaration begins with the keyword FUNCTION.<br />

In IL a function call only can be positioned within actions of a step or within a transition.<br />

In ST a function call can be used as operand in an expression.<br />

Example in IL of a function that takes three input variables and returns the product of the first two<br />

divided by the third:<br />

Example of a function in IL<br />

CoDeSys V2.3 2-1

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

Saved successfully!

Ooh no, something went wrong!