Functions That Mark Time or Events

You can create expressions that watch for a certain time to arrive or for a value to change, becoming true only when the specified event has occurred.  This can be useful for creating a calculation that is to be run on a regular basis or for signaling that a given change has occurred.

 

When used in an expression, (as opposed to VTS code) these functions will remain latched after they have been triggered.    To reset them for the next event, you will need the Latch() function, which is described at the end of this topic.

 

AbsTime(Enable, Interval, Offset)                When Enable is true, this function will become true when the given time Interval (expressed in seconds) has passed.  An offset can be used to delay the trigger.

    AbsTime(1, 60, 0)

                                                Changes from 0 to 1 on the minute mark

    AbsTime(1, 3600, 0)

                                                Changes from 0 to 1 on the hour mark

    AbsTime(1, 3600, 10)

                                                Changes from 0 to 1, ten seconds after the hour mark

 

Latch(SetFunction, ResetFunction)              Latches on when the SetFunction becomes true, then latches off when the ResetFunction becomes true.  When the Latch resets to off or false, both of the included functions are also reset.

    Latch(AbsTime(1, 10, 0), AbsTime(1, 10, 5))

                                                    Switches on every 10 seconds and off 5 seconds later.

 

Watch(InitialValue, Variable1, …)               Returns a 1 when any change occurs in the value of any of the given variables.  The InitialValue parameter will usually be set to 0, so that this function will switch from 0 to 1 when one of the watched variables changes in value.

    Watch(0, Variable(“TankLevel_1”)\value)

                                                 Initially has a value of 0. Changes to 1 the moment that the level of Tank 1 changes by any amount.

 

Deadband(Variable,  ChangeAmount)      Returns the value of the first parameter until it changes by the ChangeAmount.  Used to ignore small changes or system noise.

    Watch(0, Deadband(Variable(“TankLevel_1”)\value, 1))

                                                Initially has a value of 0. Changes to 1 the moment that the level of Tank 1 changes by at least 1%