SPLat Logo

MultiTrack (Intermediate): SuperTimers

NOTICE: Our web site is being updated, but is currently experiencing extreme slowness due to host issues. Please contact us directly.
NOTICE: SPLat Controls has moved. We are now at 1/85 Brunel Rd, Seaford, 3198. map

MultiTrack (Intermediate): SuperTimers

A companion feature to MultiTrack is the SuperTimer. The SuperTimer feature provides for timing and measuring intervals from 10mS to over 46 hours in a single, consistent mechanism. Features include:

Note: When executed inside a MultiTrack task, the FastTrack instructions with built in timing (Pause, WaitOnT, WaitOffT and WaitOnKT) use the task's SuperTimer.

We have also converted the older timing instructions like Pause, WaitOnT etc so that in dialect 16 and later they too have a range of 10mS to 46 hours.

In this lesson I will show you how to use the SuperTimer that is available in every MultiTrack task. In later lessons you will see the more advanced features.

The basis of the SuperTimer feature is a 46hour/10mS system timer that is running continuously. A time interval is generated by capturing the value of the system timer at the start of the interval and then waiting for it to have advanced by the required amount from the captured value. It turns out that if the math is done carefully (the controller takes care of all that automatically, nothing for you to worry about), even if the system timer rolls over from max to 0 during the interval, providing the interval required is less than the capacity of the timer (46 hours), everything works out OK. The caveat is that you must make sure your program can never attempt to generate or measure a single interval in excess of 46 hours (actually 46h36m12.16s)

Example: The following code is a rewrite of the main sequencer from the example in the previous lesson. I have made two functional changes:

  1. The cook time has been increased from 3 minutes to 3 hours (1,080,000 times 10mS)
  2. There is a stop button to allow the cycle to be manually cut short.

The two instructions involved in the actual timing are MarkTime and LoopIfTiming.

MarkTime simply captures the current value of the System Timer and stores it in an special register associated with each MultiTrack task. LoopIfTiming has two arguments. The first is the required interval, in this case 1,080,000. The second is where to jump to if the interval has not expired since the last MarkTime in the current task.

(Click here for some tips for working around problems with copy and paste out of Internet Explorer and HTML-help (.chm) files)

;===== The main sequencer  ============================================
MainSequence:
        WaitOnK         iStartButton    ;Wait for start command
        On              oFillValve      ;Start filling
        WaitOn          iFullProbe      ;Wait for full
        Off             oFillValve      ;Stop filling
        SetS            sHeaterEnable   ;Signal the heater to start
        SetS            sAdditiveEnable ;Signal the additive pump to run
        WaitForST       sAtTempSetPoint ;Wait for vessel to get up to temperature
        MarkTime                        ;Note the time
;In the CookLoop we sit endlessly testing for timeout and also testing the stop
;button. We do a YieldTask each time around to free up the processor for other things
CookLoop:
        YieldTask
        GoIfInK         iStopButton,CookStop
        LoopIfTiming    1080000,CookLoop        
CookStop:
        ClrS            sHeaterEnable   ;Stop the heater
        On              oDrainPump      ;Start draining 
        WaitOff         iEmptyProbe     ;Wait for it to empty
        Off             oDrainPump      ;Stop draining
        GoTo            MainSequence    ;Go back and wait for the next cycle

Exercise 1:

Graft the above code into the previous example program. Save the result with a different file name and then test it. You may find it useful to set a breakpoint at the YieldTask instruction.

Exercise 2:

There are two hazards in the above functional changes. The first is the danger of a previously latched press of the stop button. The second is the danger of stopping the process while the additive pump is still running. It may not be a good idea to be running the additive pump while the vessel is draining. Fix the problems. Hint: You will need to change the additive task over to using a SuperTimer.