Engineering Tip

Sometimes you want to trigger some events on exactly the same time interval, but don't want all of the events to occur at the same time.

It is easy to setup a 5-second timer trigger for 5 different events, but these will all occur at the same time due to the operation of the timer, working on boundaries rather than elapsed time. The optimal use of system resources would be to have the 5 events occur staggered by 1 second. This would have one event occurring every second, but never all 5 at once. This is particularly important for modem, or slow serial communications.

Credit should be given to Mitch Vaughn who showed me this technique many years ago.

The Mitch Vaughn Trickle Up Trigger Method

Review the following IML:

proc trickle

begin

trigger[4] = trigger[3]

trigger[3] = trigger[2]

trigger[2] = trigger[1]

trigger[1] = trigger[0]

trigger[0] = ?TrickleStart

end

This procedure is triggered once each second (sec1). The tag, TrickleStart, is also a timer trigger that is set for 5 seconds. The trigger[] array is an array of digital tags.

This procedure runs every second. When 5 seconds has elapsed, the ? operator means, "tag has changed" and a 1 is written to trigger[0]. The next second, the 1 is passed from trigger[0] to trigger[1] and trigger[0] is changed to a 0 because TrickleStart has not changed since the last time it was checked. The 1 trickles up the triggers each second and is restarted after 5 seconds.

These triggers will work for drivers or logging. Be careful about using these triggers with a math script because they do get written to a 0 the following second and you should check for a both a change and a value of 1 before using them as a real trigger.

Be sure not to use TrickleStart anywhere else in math, or you will loose the change state bit and it will not trigger.