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.

IEC Operators and additional norm extending functions<br />

Example in FBD:<br />

Example in IL:<br />

LD 16#45<br />

SHL 2<br />

ST<br />

erg_byte<br />

10.4 Selection Operators<br />

All selection operations can also be performed with variables. For purposes of clarity we will limit our<br />

examples to the following which use constants as operators.<br />

SEL<br />

Binary Selection.<br />

OUT := SEL(G, IN0, IN1) means:<br />

OUT := IN0 if G=FALSE;<br />

OUT := IN1 if G=TRUE.<br />

IN0, IN1 and OUT can be any type of variable, G must be BOOL. The result of the selection is IN0 if G<br />

is FALSE, IN1 if G is TRUE.<br />

Example in IL:<br />

LD TRUE<br />

SEL 3,4<br />

ST Var1 (* Result ist 4 *)<br />

LD FALSE<br />

SEL 3,4<br />

ST Var1 (* Result ist 3 *)<br />

Example in ST:<br />

Var1:=SEL(TRUE,3,4); (* Result is 4 *)<br />

Example in FBD:<br />

Note:<br />

Note that an expression occurring ahead of IN1 or IN2 will not be processed if IN0 is TRUE.<br />

MAX<br />

Maximum function. Returns the greater of the two values.<br />

OUT := MAX(IN0, IN1)<br />

IN0, IN1 and OUT can be any type of variable.<br />

Example in IL:<br />

CoDeSys V2.3 10-9

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

Saved successfully!

Ooh no, something went wrong!