Campbell Scientific CR1000 Measurement and Control System User Manual

Page 207

Advertising
background image

Section 7. Installation

207

 

• Does the record have a delimiter character, e.g. ",", spaces, or tabs? These

delimiters are useful for parsing the record into usable numbers.

• Will the sensor be sending multiple data strings? Multiple strings usually

require filtering before parsing.

• How fast will data be sent to the CR1000?
• Is power consumption critical?
• Does the sensor compute a checksum? Which type? A checksum is useful to

test for data corruption.

2. Open a serial port (SerialOpen() instruction).

• Example:

SerialOpen

(Com1,9600,0,0,10000)

• Designate the correct port in CRBasic.
• Correctly wire the device to the CR1000.
• Match the port's baud rate to the baud rate of the device in CRBasic.

o Use a fixed baud rate (rather than autobaud) when possible.

3. Receive serial data as a string (CRBasic SerialIn() or SerialInRecord()

command).

• Example:

SerialInRecord

(Com2,SerialInString,42,0,35,"",01)

• Declare the string variable large enough to accept the string.

o Example:

Public

SerialInString

As String

* 25

• Observe the input string in the input string variable in software numeric

monitor.

Note SerialIn() and SerialInRecord() receive the same data. SerialInRecord()
is generally used for data streaming into the CR1000, while SerialIn() is used for
data that is received in discrete blocks.

4. Parse (split up) the serial string (CRBasic SplitStr() command).

• Separates string into numeric and / or string variables.
• Example:

SplitStr

(InStringSplit,SerialInString,"",2,0)

• Declare an array to accept the parsed data.

o Example:

Public

InStringSplit(2)

As String

o Example:

Public

SplitResult(2)

As Float

Advertising