Commands and functions
P.
192 of 349
Special time functions
Precision timer -
programmable delay
Delay
With the help of
delay
and
after
, very short time constants can be generated, as needed for example
in the control of motion detectors (light duration, debounce against restart) or certain control
algorithms. The Enertex
®
EibPC responds even in the microsecond range.
The minimum delay time is 1 ms, the maximum adjustable delay time is approximately 30 years.
Definition
●
Function
delay
(
Signal
,
Time
)
Arguments
●
Argument
Signal
of the data type b01
●
Argument
Time
of the data type u64
Effect
●
The function starts a timer at the transition of the variable
signal
from OFF to ON and sets
the return value of the function for one cycle to ON, if the time delay is reached.
t
t
Signal
Delay
Time in ms
Time in
ms
Time in ms
Restart Timer
●
When a new OFF-ON pulse occurs during the internal timer is running, the timer restarts.
Data type result (Return)
●
Data type b01
Note:
●
Do not use
delay
in the then or else branch of an
if
statement.
●
If the
delay
(using an
if
statement and a
write
) writes a telegram, there can arise an
additional delay time of a few ms - depending on the bus load and the bus speed.
Example: Delayed variable assignment
If the variable LightActuator (Date type f16) is less than 1000f16, the variable light (data type
b01) is to go to
ON
after 10s for 1 cycle
Implementation in the user program:
Light=!delay(LightActuator<1000f16,10000u64)
Example: Delayed variable assignment
If LightButton (Type b01) is
ON
, the variable LightActuator (Type b01) is to go to
ON
after
1300 ms.
Implementation in the user program:
if delay(LightButton,1300u64) then LightActuator=1b01 endif
Alternative 1
if delay(LightButton==1b01,1300u64) then LightActuator=1b01 endif
Alternative 2
if (delay(LightButton,1300u64)==1b01) then=1b01 endif
Note that "LightActuator" is only set, but not deleted. See also the following example.
HandbuchEibPC_USA-30.odt, 2017-05-11
Enertex
®
Bayern GmbH - Erlachstraße 13 - 91301 Forchheim - [email protected]