04.01.2015 Views

CR1000 Manual - Campbell Scientific

CR1000 Manual - Campbell Scientific

CR1000 Manual - Campbell Scientific

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Section 7. Installation<br />

7.7.3.7 Execution Timing<br />

Note Measurement tasks have priority over other tasks such as processing and<br />

communication to allow accurate timing needed within most measurement<br />

instructions.<br />

Care must be taken when initializing variables when multiple sequences are used<br />

in a program. If any sequence relies on something (variable, port, etc.) that is<br />

initialized in another sequence, there must be a handshaking scheme placed in the<br />

CRBasic program to make sure that the initializing sequence has completed<br />

before the dependent task can proceed. This can be done with a simple variable or<br />

even a delay, but understand that the <strong>CR1000</strong> operating system will not do this<br />

handshaking between independent tasks.<br />

A similar concern is the reuse of the same variable in multiple tasks. Without<br />

some sort of messaging between the two tasks placed into the CRBasic program,<br />

unpredictable results are likely to occur. The SemaphoreGet() and<br />

SemaphoreRelease() instruction pair provide a tool to prevent unwanted access<br />

of an object (variable, COM port, etc.) by another task while the object is in use.<br />

Consult CRBasic Editor Help for information on using SemaphoreGet() and<br />

SemaphoreRelease().<br />

Timing of program execution is regulated by timing instructions listed in the<br />

following table.<br />

Table 17. Program Timing Instructions<br />

Instructions General Guidelines Syntax Form<br />

Scan() / NextScan<br />

SlowSequence /<br />

EndSequence<br />

Use in most programs. Begins<br />

/ ends the main scan.<br />

Use when measurements or<br />

processing must run at slower<br />

frequencies than that of the<br />

main program.<br />

BeginProg<br />

Scan()<br />

'.<br />

'.<br />

'.<br />

NextScan<br />

EndProg<br />

BeginProg<br />

Scan()<br />

'.<br />

'.<br />

'.<br />

NextScan<br />

SlowSequence<br />

Scan()<br />

'.<br />

'.<br />

'.<br />

NextScan<br />

EndSequence<br />

EndProg<br />

135

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!