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.

Appendix D: CoDeSys Libraries<br />

Example in FBD:<br />

Example in ST:<br />

CTUInst(CU:= VarBOOL1, RESET:=VarBOOL2 , PV:= VarINT1);<br />

VarBOOL3 := CTUInst.Q ;<br />

VarINT2 := CTUInst.CV;<br />

CTD<br />

Function Block Decrementer:<br />

The input variables CD and LOAD as well as the output variable Q are type BOOL, the input variable<br />

PV and the output variable CV are type INT.<br />

When LOAD_ is TRUE, the counter variable CV will be initialized with the upper limit PV. If CD has a<br />

rising edge from FALSE to TRUE, CV will be lowered by 1 provided CV is greater than 0 (i.e., it<br />

doesn't cause the value to fall below 0).<br />

Q returns TRUE when CVis equal 0.<br />

Declaration example:<br />

CTDInst : CTD ;<br />

Example in IL:<br />

CAL<br />

LD<br />

ST<br />

LD<br />

ST<br />

CTDInst(CD := VarBOOL1, LOAD := VarBOOL2, PV := VarINT1)<br />

CTDInst.Q<br />

VarBOOL3<br />

CTDInst.CV<br />

VarINT2<br />

Example in FBD:<br />

Example in ST:<br />

CTDInst(CD:= VarBOOL1, LOAD:=VarBOOL2 , PV:= VarINT1);<br />

VarBOOL3 := CTDInst.Q ;<br />

VarINT2 := CTDInst.CV;<br />

CoDeSys V2.3 10-47

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

Saved successfully!

Ooh no, something went wrong!