Saving the input values (
BUFFER output)
The BUFFER output must be always linked to a variable. The values to be delayed are contained in these variables. Each time the function block is executed a new value is saved for the IN input.
The size of the variable linked to the BUFFER output determines the number of values, which can be saved and therefore also the allowable maximum delay value:
The following applies here
Formula size
|
Meaning
|
n
|
Number of floating point values, which the BUFFER can contain.
|
T_PERIOD
|
Sampling interval of the function block
|
NOTE: As soon as a variable has been connected to the BUFFER output, it can only be replaced by a variable of the same type. To replace it with a greater variable, which would enable a higher delay value to be reached for example, the function block must be deleted and a new one put in place.
Data type of the buffer output
The BUFFER output is of the ANY type. This means any variable type can be assigned to it. It is better to define an ARRAY (table) with REAL elements. This ARRAY can contain up to 100 floating point values. With this variable type it is possible to attain a delay, which corresponds to 100 times the sampling interval of the DTIME function block.
NOTE: DTIME does only work, when the size of the actual parameter assigned to the BUFFER output is at least 4 bytes.
Valid data types are, for example, REAL, ARRAY[1..4] OF BYTE.
Invalid data types are, for example, BYTE, INT, ARRAY[1..3] OF BYTE.
If an invalid data type is connected, DTIME will not be processed and a runtime error (STATUS=2) is generated.
Procedure for large delay times
To attain delay values, which are equivalent to over 100 times the sampling interval of the function block, a larger variable must be assigned to the BUFFER parameter:
Step
|
Action
|
1
|
Define a new derived data type, e.g. a table with 200 floating point values
|
2
|
Declare a variable of this type and link it to the BUFFER parameter of the DTIME function block.
|
3
|
In this case, the maximum delay corresponds to 200 times the sampling interval of the function block
|
Dynamic modification of the
T_DELAY delay
It is possible to raise or lower the T_DELAY delay time while the program is running. As long as the re-adjusted delay time is compatible with the size of the BUFFER output, the new delay is effective immediately.
Representation of the dynamic modification to T_DELAY
If the T_DELAY value is too great in relation to the BUFFER size, it is no longer possible to save enough input values to attain the delay desired. In this case the delay remains at the longest time possible (bit 8 of the status word then goes to 1 over).
To prevent this problem it is advisable to define the dimensions of the variable assigned to the BUFFER parameter so that a possible increase in the T_DELAY can be provided for.
When T_DELAY = 0, the OUT output always corresponds to the IN input.