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.

The Standard.lib library<br />

CTUD<br />

Function Block Incrementer/Decrementer<br />

The input variables CU, CD, RESET, LOAD as well as the output variables QU and QD are type<br />

BOOL, PV and CV are type INT.<br />

If RESET is valid, the counter variable CV will be initialized with 0. If LOAD is valid, CV will be<br />

initialized with PV.<br />

If CU has a rising edge from FALSE to TRUE, CV will be raised by 1. If CD has a rising edge from<br />

FALSE to TRUE, CV will be lowered by 1 provided this does not cause the value to fall below 0.<br />

QU returns TRUE when CV has become greater than or equal to PV.<br />

QD returns TRUE when CV has become equal to 0.<br />

Declaration example:<br />

CTUDInst : CUTD ;<br />

Example in IL:<br />

CAL<br />

LD<br />

ST<br />

LD<br />

ST<br />

LD<br />

ST<br />

CTUDInst(CU := VarBOOL2, RESET := VarBOOL3, LOAD := VarBOOL4,<br />

PV := VarINT1)<br />

CTUDInst.QU<br />

VarBOOL5<br />

CTUDInst.QD<br />

VarBOOL6<br />

CTUDInst.CV<br />

VarINT2<br />

Example in FBD:<br />

Example in ST:<br />

CTUDInst(CU := VarBOOL1, CU:= VarBOOL2, RESET := VarBOOL3, LOAD:=VarBOOL4 , PV:=<br />

VarINT1);<br />

VarBOOL5 := CTUDInst.QU ;<br />

VarBOOL6 := CTUDInst.QD ;<br />

VarINT2 := CTUDInst.CV;<br />

10.16.5 Timer...<br />

TP<br />

The function blockTimer is a trigger. TP(IN, PT, Q, ET) means:<br />

IN and PT are input variables of the BOOL and TIME types respectively. Q and ET are output<br />

variables of the BOOL and TIME types respectively. If IN is FALSE, Q is FALSE and ET is 0.<br />

10-48 CoDeSys V2.3

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

Saved successfully!

Ooh no, something went wrong!