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.8.8.5.5 Memory Considerations<br />

Example (humidity, temperature, and pressure sensor):<br />

SerialInString = "RH= 60.5 %RH T= 23.7 °C Tdf= 15.6 °C Td=<br />

15.6 °C a= 13.0 g/m3 x= 11.1 g/kg Tw= 18.5 °C H2O=<br />

17889 ppmV pw=17.81 hPa pws 29.43 hPa h= 52.3 kJ/kg dT=<br />

8.1 °C"<br />

• Hex Pairs: Bytes are translated to hex pairs, consisting of digits 0 - 9 and<br />

letters a - f. Each pair describes a hexadecimal ASCII / ANSI code. Some<br />

codes translate to alpha-numeric values, others to symbols or non-printable<br />

control characters.<br />

Example (temperature sensor):<br />

SerialInString = "23 30 31 38 34 0D",<br />

which translates to:<br />

#01 84 cr<br />

• Binary: Bytes are processed on a bit-by-bit basis. Character 0 (Null, &b00) is<br />

a valid part of binary data streams. However, the <strong>CR1000</strong> uses Null<br />

terminated strings, so anytime a Null is received, a string is terminated. The<br />

termination is usually premature when reading binary data. To remedy this<br />

problem, the SerialInBlock() or SerialInRecord() instruction is required<br />

when reading binary data from the serial port buffer to a variable. The<br />

variable must be an array set As Long data type, as in,<br />

Dim SerialInString As Long<br />

Several points regarding memory should be considered when receiving and<br />

processing serial data.<br />

• Serial buffer: The serial port buffer, which is declared in the SerialOpen()<br />

instruction, must be large enough to hold all the data a device will send. The<br />

buffer holds the data for subsequent transfer to variables. Allocate extra<br />

memory to the buffer when needed, but recognize that added memory to the<br />

buffer reduces memory available for long term data storage.<br />

Note SerialInRecord() running in pipeline mode, with the number of bytes<br />

parameter = 0. For the digital measurement sequence to know how much room to<br />

allocate in the Scan() instruction buffers (default of 3), SerialInRecord() has to<br />

allocate itself the buffer size specified by SerialOpen() (default 10,000, an<br />

overkill), or default 3*10,000 = 30 kB of buffer space. So, while making sure<br />

enough bytes are allocated in SerialOpen() (the number of bytes per record *<br />

((records/Scan)+1) + at least one extra byte), there is reason not to make the<br />

buffer size too large. (Note that if the NumberOfBytes parameter is non-zero, then<br />

SerialInRecord() needs to allocate itself only this many bytes instead of the<br />

number of bytes specified by SerialOpen()).<br />

• Variable declarations: Variables used to receive data from the serial buffer<br />

can be declared as Public or Dim. Declaring variables as Dim has the effect<br />

of consuming less telecommunications bandwidth. When public variables are<br />

viewed in software, the entire Public table is transferred at the update<br />

interval. If the Public table is large, telecommunications bandwidth can be<br />

taxed such that other data tables are not collected.<br />

209

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

Saved successfully!

Ooh no, something went wrong!