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 />

A P-controller is easily generated by setting TV to a fixed value of 0.<br />

PID<br />

The PID controller function block:<br />

Unlike the PD controller, this function block contains a further DWORD input TN for the readjusting<br />

time in msec.<br />

The output, the manipulated variable (Y) is again of type REAL, and contains, unlike the PD controller,<br />

an additional integral part:<br />

Y = KP ⋅ (∆ + 1/TN ∆(t)dt + TV δ∆/δt) + Y_OFFSET<br />

The PID controller can be easily converted to a PI controller by setting TV=0.<br />

Because of the additional integral part, an overflow can come about by incorrect parameterization of<br />

the controller, if the integral of the error ∆ becomes too great. Therefore for the sake of safety a<br />

BOOLean output called OVERFLOW is present, which in this case would have the value TRUE. At<br />

the same time, the controller is suspended and will only be activated again by re-initialization.<br />

10.17.5 Signal Generators...<br />

BLINK<br />

The function block BLINK generates a pulsating signal. The input consists of ENABLE of the type<br />

BOOL, as well as TIMELOW and TIMEHIGH of the type TIME. The output OUT is of the type BOOL.<br />

If ENABLE is set to TRUE, BLINK begins, to set the output for the time period TIMEHIGH to TRUE,<br />

and then afterwards to set it for the time period TIMELOW to FALSE.<br />

Example in CFC:<br />

GEN<br />

The function generator generates typical periodic functions:<br />

The inputs are a composition consisting of MODE from the pre-defined counting type GEN_MODE,<br />

BASE of the type BOOL, PERIOD of the type TIME, of two INT values CYCLES and AMPLITUDE and<br />

of the BOOLean RESET input.<br />

The MODE describes the function which should be generated, whereby the enumeration values<br />

TRIANGLE and TRIANGLE_POS deliver two triangular functions, SAWTOOTH_RISE an ascending,<br />

CoDeSys V2.3 10-55

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

Saved successfully!

Ooh no, something went wrong!