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

then<br />

TempData(1,1,2) = "TOP", TempData(1,1,3) = "OP", _<br />

TempData(1,1,1) = "STOP"<br />

To handle single-character manipulations, declare the string with a size of 1. That<br />

single-character string can be used to search for specific characters. In the<br />

following example, the first character of a larger string is determined:<br />

Public TempData As String * 1<br />

TempData = LargerString<br />

If TempData = "S" Then<br />

A single character can be retrieved from any position in a string using the third<br />

dimension. To retrieve the fifth character of a larger string, follow this example:<br />

Public TempData As String * 1<br />

TempData = LargerString(1,1,5)<br />

Q: How can I get SerialIn(), SerialInBlock(), and SerialInRecord() to read<br />

extended characters<br />

A: Open the port in binary mode (mode 3) instead of PakBus-enabled mode<br />

(mode 0).<br />

Q: Tests with an oscilloscope showed the sensor was responding quickly, but the<br />

data were getting held up in the internals of the <strong>CR1000</strong> somewhere for 30 ms or<br />

so. Characters at the start of a response from a sensor, which come out in 5 ms,<br />

were apparently not accessible by the program for 30 ms or so; in fact, no data<br />

were in the serial buffer for 30 ms or so.<br />

A: As a result of internal buffering in the <strong>CR1000</strong> and / or external interfaces, data<br />

may not appear in the serial port buffer for a period ranging up to 50 ms<br />

(depending on the serial port being used). This should be kept in mind when<br />

setting timeouts for the SerialIn() and SerialOut() instructions, or user-defined<br />

timeouts in constructs using the SerialInChk() instruction.<br />

Q: What are the termination conditions that will stop incoming data from being<br />

stored<br />

A: Termination conditions:<br />

• TerminationChar argument is received<br />

• MaxNumChars argument is met<br />

• TimeOut argument is exceeded<br />

SerialIn() does NOT stop storing when a Null character (&h00) is received<br />

(unless a NULL character is specified as the termination character). As a string<br />

variable, a NULL character received will terminate the string, but nevertheless<br />

characters after a NULL character will continue to be received into the variable<br />

space until one of the termination conditions is met. These characters can later be<br />

accessed with MoveBytes() if necessary.<br />

Q: How can a variable populated by SerialIn() be used in more than one<br />

sequence and still avoid using the variable in other sequences when it contains old<br />

data<br />

221

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

Saved successfully!

Ooh no, something went wrong!