SPLat Logo

fSTSinceMark [D>=22]

NOTICE: SPLat Controls has moved. We are now at 1/85 Brunel Rd, Seaford, 3198. map

fSTSinceMark [D>=22]

Calculates the time elapsed since the last MarkTime in the current task. The result is returned as a floating point number in W. This will be an integer value in the range 0 to 16,777,215 times 10mS. This instruction may only be used a MultiTrack task. It is based on the assumption that there was a prior MarkTime instruction in this task (failing which the result is unpredictable).

From dialect 20 some controllers allow you to program the 10mS basic "tick" interval over the range 1mS to 255mS via a setting in the CPU device. See the CPU device documentation for your controller.

Note

SPLat 8 bit controllers (green boards) do not support the use of task timers if Multitrack multi-tasking is not running.  In addition, on these controllers you cannot use Pause, WaitOnT, WaitOffT or WaitOnKT between a MarkTime and its corresponding fSTSinceMark or LoopIfTiming.

SPLat 32 bit controllers (black boards) have none of these restrictions.  So you can use task timers on a SPLat 32 bit controller even if you are single tasking and can use any of the Pause or Wait instructions together with MarkTime and its siblings.

See MultiTrack tutorial.

Dialect exclusions: Not available in dialects before 22.

Example:

The following program has two tasks. Timer measures the duration of an "On press" of the push button on input 16 of an MS120 and displays it on the LCD. Blinker blinks the LED on output 11 once per second as long as the button is depressed.


On 20 ;Backlight
LaunchTask Timer
LaunchTask Blinker
RunTasksForever

;Measure and display button on-time
Timer:
WaitOn 16
MarkTime ;Start timing
WaitOff 16
fSTSinceMark ;Get the elapsed time
fLoadQ 10
fMul
OBLCD_SetCur 0,0
OBLCD_fDispW 8,0
OBLCD_Text "mS"
GoTo Timer

;Blink a LED while the button is on
Blinker:
Off 11
WaitOn 16
Blinker2:
On 11
WaitOffT 16,5
GoIfT Blinker
Off 11
WaitOffT 16,95
GoIfT Blinker
GoTo Blinker2