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

• Does the record have a delimiter character, e.g. ",", spaces, or tabs These<br />

delimiters are useful for parsing the record into usable numbers.<br />

• Will the sensor be sending multiple data strings Multiple strings usually<br />

require filtering before parsing.<br />

• How fast will data be sent to the <strong>CR1000</strong><br />

• Is power consumption critical<br />

• Does the sensor compute a checksum Which type A checksum is useful to<br />

test for data corruption.<br />

2. Open a serial port (SerialOpen() instruction).<br />

• Example:<br />

SerialOpen(Com1,9600,0,0,10000)<br />

• Designate the correct port in CRBasic.<br />

• Correctly wire the device to the <strong>CR1000</strong>.<br />

• Match the port's baud rate to the baud rate of the device in CRBasic.<br />

o Use a fixed baud rate (rather than autobaud) when possible.<br />

3. Receive serial data as a string (CRBasic SerialIn() or SerialInRecord()<br />

command).<br />

• Example:<br />

SerialInRecord(Com2,SerialInString,42,0,35,"",01)<br />

• Declare the string variable large enough to accept the string.<br />

o Example:<br />

Public SerialInString As String * 25<br />

• Observe the input string in the input string variable in software numeric<br />

monitor.<br />

Note SerialIn() and SerialInRecord() receive the same data. SerialInRecord()<br />

is generally used for data streaming into the <strong>CR1000</strong>, while SerialIn() is used for<br />

data that is received in discrete blocks.<br />

4. Parse (split up) the serial string (CRBasic SplitStr() command).<br />

• Separates string into numeric and / or string variables.<br />

• Example:<br />

SplitStr(InStringSplit,SerialInString,"",2,0)<br />

• Declare an array to accept the parsed data.<br />

o Example:<br />

o<br />

Public InStringSplit(2) As String<br />

Example:<br />

Public SplitResult(2) As Float<br />

207

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

Saved successfully!

Ooh no, something went wrong!