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 />

A: A common caution is, “The destination variable should not be used in more<br />

than one sequence to avoid using the variable when it contains old data.”<br />

However, there are more elegant ways to handle the root problem. There is<br />

nothing unique about SerialIn() with regard to understanding how to correctly<br />

write to and read from global variables using multiple sequences. SerialIn() is<br />

writing into an array of characters. Many other instructions write into an array of<br />

values (characters, floats, or longs), e.g., Move(), MoveBytes(), GetVariables(),<br />

SerialInRecord(), SerialInBlock(), etc. In all cases, when writing to an array of<br />

values, it is important to understand what you are reading, if you are reading it<br />

asynchronously, i.e., reading it from some other task that is polling for the data at<br />

the same time as it is being written, whether that other task is some other machine<br />

reading the data, like LoggerNet, or a different “Sequence”, or task, within the<br />

same machine. If the process is relatively fast, like the Move() instruction, and an<br />

asynchronous process is reading the data, this can be even worse because the<br />

“reading old data” will happen less often but is more insidious because it is so<br />

rare. It is good to know that we have ways of correctly dealing with this general<br />

problem of a different task reading data than is writing data, like semaphores, or<br />

like recording the data in a data table from the same task and then have LoggerNet<br />

read from the data table.<br />

7.8.9 TrigVar and DisableVar — Controlling Data Output and<br />

Processing<br />

TrigVar is the third parameter in the DataTable() instruction. It controls whether<br />

or not a data record is written to final storage. TrigVar control is subject to other<br />

conditional instructions such as the DataInterval() and DataEvent() instructions.<br />

DisableVar is the last parameter in most output processing instructions, such as<br />

Average(), Maximum(), Minimum(), etc. It controls whether or not a particular<br />

measurement or value is included in the affected output-processing function.<br />

For individual measurements to affect summary data, output processing<br />

instructions such as Average() must be executed whenever the data table is called<br />

from the program — normally once each Scan. For example, for an average to be<br />

calculated for the hour, each measurement must be added to a total over the hour.<br />

This accumulation of data is not affected by TrigVar. TrigVar controls only the<br />

moment when the final calculation is performed and the processed data (the<br />

average) are written to the data table. For this summary moment to occur, TrigVar<br />

and all other conditions (such as DataInterval() and DataEvent()) must be true.<br />

Expressed another way, when TrigVar is false, output processing instructions (for<br />

example, Average()) perform intermediate processing but not their final<br />

processing, and a new record will not be created.<br />

Note In many applications, output records are solely interval based and TrigVar is<br />

always set to TRUE (-1). In such applications, DataInterval() is the sole<br />

specifier of the output trigger condition.<br />

Figure Data from TrigVar Program (p. 223) shows data produced by CRBasic<br />

example Using TrigVar to Trigger Data Storage (p. 223), which uses TrigVar rather<br />

than DataInterval() to trigger data storage.<br />

222

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

Saved successfully!

Ooh no, something went wrong!