04.01.2015 Views

CR1000 Manual - Campbell Scientific

CR1000 Manual - Campbell Scientific

CR1000 Manual - Campbell Scientific

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Section 7. Installation<br />

7.8.8.5.3 Output Programming Basics<br />

Applications with the purpose of transmitting data to another device usually<br />

include the following procedures. Other procedures may be required depending on<br />

the application.<br />

1. Open a serial port (SerialOpen() command) to configure it for<br />

communications.<br />

• Parameters are set according to the requirements of the communications link<br />

and the serial device.<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 />

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

2. Build the output string.<br />

• Example:<br />

SerialOutString = "*" & "27.435" & "," & "56.789" & "#"<br />

• Tip — Concatenate (add) strings together using & instead of +.<br />

• Tip — CHR() instruction is used to insert ASCII / ANSI characters into a<br />

string.<br />

3. Output string via the serial port (SerialOut() or SerialOutBlock() command).<br />

• Example:<br />

SerialOut(Com1,SerialOutString,"",0,100)<br />

• Declare the output string variable large enough to hold the entire<br />

concatenation.<br />

• Example:<br />

Public SerialOutString As String * 100<br />

• SerialOut() and SerialOutBlock() output the same data, except that<br />

SerialOutBlock() transmits null values while SerialOut() strings are<br />

terminated by a null value.<br />

7.8.8.5.4 Translating Bytes<br />

One or more of three principle data formats may end up in the SerialInString()<br />

variable (see examples in Serial Input Programming Basics (p. 206) ). Data may be<br />

combinations or variations of all of these. The manufacturer of the instrument<br />

must provide the rules by which data are to be decoded.<br />

• Alpha-numeric: Each digit represents its own alpha-numeric value. For<br />

example, R = the letter R, and 2 = decimal 2. This is the easiest protocol to<br />

translate since the literal translation is what is received from the transmitting<br />

instrument. Normally, the CRBasic program receiving the transmission will<br />

be written to parse (split) the string up and place the values in <strong>CR1000</strong><br />

variables.<br />

208

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

Saved successfully!

Ooh no, something went wrong!