Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
159
Добавлен:
11.10.2020
Размер:
2.81 Mб
Скачать

Appendix D: - The CoDeSys Libaries

Because of the additional integral part, an overflow can come about by incorrect parameterization of the controller, if the integral of the error ∆ becomes too great. Therefore for the sake of safety a BOOLean output called OVERFLOW is present, which in this case would have the value TRUE. At the same time, the controller is suspended and will only be activated again by re-initialization.

PID_FIXCYCLE

The PID_FIXCYCLE controller function block:

This function block functionally corresponds to the PID controller with the exception that the cycle time is not measured automatically by an internal function but is set by input CYCLE (in seconds).

10.17.5 Signal Generators...

BLINK

The function block BLINK generates a pulsating signal. The input consists of ENABLE of the type BOOL, as well as TIMELOW and TIMEHIGH of the type TIME. The output OUT is of the type BOOL.

If ENABLE is set to TRUE, BLINK begins, to set the output for the time period TIMEHIGH to TRUE, and then afterwards to set it for the time period TIMELOW to FALSE.

Example in CFC:

GEN

The function generator generates typical periodic functions:

The inputs are a composition consisting of MODE from the pre-defined counting type GEN_MODE, BASE of the type BOOL, PERIOD of the type TIME, of two INT values CYCLES and AMPLITUDE and of the BOOLean RESET input.

The MODE describes the function which should be generated, whereby the enumeration values TRIANGLE and TRIANGLE_POS deliver two triangular functions, SAWTOOTH_RISE an ascending, SAWTOOTH_FALL a descending sawtooth, RECTANGLE a rectangular signal and SINE and COSINE the sine and cosine:

10-54

CoDeSys V2.3

Appendix D: - The CoDeSys Libaries

TRIANGLE:

TRIANGLE_POS:

SAWTOOTH_RISE: SAWTOOTH_FALL:

RECTANGLE:

SINUS:

COSINUS:

BASE defines whether the cycle period is really related to a defined time (BASE=TRUE) or whether it is related to a particular number of cycles, which means the number of calls of function block (BASE=FALSE).

PERIOD or CYCLES defines the corresponding cycle period.

AMPLITUDE defines, in a trivial way, the amplitude of the function to be generated. The function generator is again set to 0 as soon as RESET=TRUE.

Example in FBD:

CoDeSys V2.3

10-55

Appendix D: - The CoDeSys Libaries

10.17.6 Function Manipulators...

CHARCURVE

This function block serves to represent values, piece by piece, on a linear function:

IN of the type INT is fed with the value to be manipulated. The BYTE N designates the number of points which defines the presentation function. This characteristic line is then generated in an ARRAY P[0..10] with P of the type POINT which is a structure based on two INT values (X and Y).

The output consists of OUT of the type INT, the manipulated value and BYTE ERR, which will indicate an error if necessary.

The points P[0]..P[N-1] in the ARRAY must be sorted according to their X values, otherwise ERR 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 corresponding limiting value P[0]. Y or P[N-1].Y.

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

Example in ST:

First of all ARRAY P must be defined in the header:

VAR

...

CHARACTERISTIC_LINE:CHARCURVE;

KL:ARRAY[0..10] OF POINT:=(X:=0,Y:=0),(X:=250,Y:=50), (X:=500,Y:=150),(X:=750,Y:=400),7((X:=1000,Y:=1000)); COUNTER:INT;

...

END_VAR

Then we supply CHARCURVE with for example a constantly increasing value:

COUNTER:=COUNTER+10;

CHARACTERISTIC_LINE(IN:=COUNTER,N:=5,P:=KL);

The subsequent tracing illustrates the effect:

RAMP_INT

RAMP_INT serves to limit the ascendance or descendance of the function being fed:

The input consists on the one hand out of three INT values: IN, the function input, and ASCEND and DESCEND, the maximum increase or decrease for a given time interval, which is defined by TIMEBASE of the type TIME. Setting RESET to TRUE causes RAMP_INT to be initialised anew.

The output OUT of the type INT contains the ascend and descend limited function value.

When TIMEBASE is set to t#0s, ASCEND and DESCEND are not related to the time interval, but remain the same.

10-56

CoDeSys V2.3

Appendix D: - The CoDeSys Libaries

Example in CFC:

RAMP_REAL

RAMP_REAL functions in the same way as RAMP_INT, with the simple difference that the inputs IN, ASCEND, DESCEND and the output OUT are of the type REAL.

10.17.7 Analog Value Processing...

HYSTERESIS

The input to this function block consists of three INT values IN, HIGH and LOW. The output OUT is of the type BOOL.

If IN goes below the limiting value LOW, OUT becomes TRUE. If IN goes over the upper limit HIGH, FALSE is delivered.

An illustrative example:

CoDeSys V2.3

10-57

Соседние файлы в папке 759-333