7 execution timing, Table 17. program timing instructions – Campbell Scientific CR1000 Measurement and Control System User Manual
Page 135

Section 7. Installation
135
Note Measurement tasks have priority over other tasks such as processing and
communication to allow accurate timing needed within most measurement
instructions.
Care must be taken when initializing variables when multiple sequences are used
in a program. If any sequence relies on something (variable, port, etc.) that is
initialized in another sequence, there must be a handshaking scheme placed in the
CRBasic program to make sure that the initializing sequence has completed
before the dependent task can proceed. This can be done with a simple variable or
even a delay, but understand that the CR1000 operating system will not do this
handshaking between independent tasks.
A similar concern is the reuse of the same variable in multiple tasks. Without
some sort of messaging between the two tasks placed into the CRBasic program,
unpredictable results are likely to occur. The SemaphoreGet() and
SemaphoreRelease() instruction pair provide a tool to prevent unwanted access
of an object (variable, COM port, etc.) by another task while the object is in use.
Consult CRBasic Editor Help for information on using SemaphoreGet() and
SemaphoreRelease().
7.7.3.7 Execution Timing
Timing of program execution is regulated by timing instructions listed in the
following table.
Table 17. Program Timing Instructions
Instructions General
Guidelines Syntax
Form
Scan() / NextScan
Use in most programs. Begins
/ ends the main scan.
BeginProg
Scan()
'.
'.
'.
NextScan
EndProg
SlowSequence /
EndSequence
Use when measurements or
processing must run at slower
frequencies than that of the
main program.
BeginProg
Scan()
'.
'.
'.
NextScan
SlowSequence
Scan()
'.
'.
'.
NextScan
EndSequence
EndProg