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

IN of the type INT is fed with the value to be manipulated. The BYTE N designates the number of<br />

points which defines the presentation function. This characteristic line is then generated in an ARRAY<br />

P[0..10] with P of the type POINT which is a structure based on two INT values (X and Y).<br />

The output consists of OUT of the type INT, the manipulated value and BYTE ERR, which will indicate<br />

an error if necessary.<br />

The points P[0]..P[N-1] in the ARRAY must be sorted according to their X values, otherwise ERR<br />

receives the value 1. If the input IN is not between P[0].X and P[N-1].X, ERR=2 and OUT contains the<br />

corresponding limiting value P[0]. Y or P[N-1].Y.<br />

If N lies outside of the allowed values which are between 2 and 11, then ERR=4.<br />

Example in ST:<br />

First of all ARRAY P must be defined in the header:<br />

VAR<br />

...<br />

CHARACTERISTIC_LINE:CHARCURVE;<br />

KL:ARRAY[0..10] OF POINT:=(X:=0,Y:=0),(X:=250,Y:=50),<br />

(X:=500,Y:=150),(X:=750,Y:=400),7((X:=1000,Y:=1000));<br />

COUNTER:INT;<br />

...<br />

END_VAR<br />

Then we supply CHARCURVE with for example a constantly increasing value:<br />

COUNTER:=COUNTER+10;<br />

CHARACTERISTIC_LINE(IN:=COUNTER,N:=5,P:=KL);<br />

The subsequent tracing illustrates the effect:<br />

RAMP_INT<br />

RAMP_INT serves to limit the ascendance or descendance of the function being fed:<br />

The input consists on the one hand out of three INT values: IN, the function input, and ASCEND and<br />

DESCEND, the maximum increase or decrease for a given time interval, which is defined by<br />

TIMEBASE of the type TIME. Setting RESET to TRUE causes RAMP_INT to be initialised anew.<br />

The output OUT of the type INT contains the ascend and descend limited function value.<br />

When TIMEBASE is set to t#0s, ASCEND and DESCEND are not related to the time interval, but<br />

remain the same.<br />

Beispiel in CFC:<br />

CoDeSys V2.3 10-57

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

Saved successfully!

Ooh no, something went wrong!