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.

Appendix D: CoDeSys Libraries<br />

CLK : BOOL;<br />

END_VAR<br />

VAR_OUTPUT<br />

Q : BOOL;<br />

END_VAR<br />

VAR<br />

M : BOOL := FALSE;<br />

END_VAR<br />

Q0 := CLK AND NOT M;<br />

M := CLK;<br />

END_FUNCTION_BLOCK<br />

The output Q0 and the help variable M will remain FALSE as long as the input variable CLK is FALSE.<br />

As soon as S1 returns TRUE, Q will first return TRUE, then M will be set to TRUE. This means each<br />

time the function is called up, Q will return FALSE until CLK has falling edge followed by an rising<br />

edge.<br />

Declaration example:<br />

RTRIGInst : R_TRIG ;<br />

Example in IL:<br />

CAL<br />

LD<br />

ST<br />

RTRIGInst(CLK := VarBOOL1)<br />

RTRIGInst.Q<br />

VarBOOL2<br />

Example in FBD:<br />

Example in ST:<br />

RTRIGInst(CLK:= VarBOOL1);<br />

VarBOOL2 := RTRIGInst.Q;<br />

F_TRIG<br />

The function block F_TRIG a falling edge.<br />

FUNCTION_BLOCK F_TRIG<br />

VAR_INPUT<br />

CLK: BOOL;<br />

END_VAR<br />

VAR_OUTPUT<br />

Q: BOOL;<br />

END_VAR<br />

VAR<br />

M: BOOL := FALSE;<br />

END_VAR<br />

CoDeSys V2.3 10-45

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

Saved successfully!

Ooh no, something went wrong!