Campbell Scientific CR1000 Measurement and Control System User Manual

Page 221

Advertising
background image

Section 7. Installation

221

 

then

TempData(1,1,2) = "TOP", TempData(1,1,3) = "OP", _
TempData(1,1,1) = "STOP"

To handle single-character manipulations, declare the string with a size of 1. That
single-character string can be used to search for specific characters. In the
following example, the first character of a larger string is determined:

Public

TempData

As String

* 1

TempData = LargerString

If

TempData = "S"

Then

A single character can be retrieved from any position in a string using the third
dimension. To retrieve the fifth character of a larger string, follow this example:

Public

TempData

As String

* 1

TempData = LargerString(1,1,5)

 

Q: How can I get SerialIn(), SerialInBlock(), and SerialInRecord() to read
extended characters?

A: Open the port in binary mode (mode 3) instead of PakBus-enabled mode
(mode 0).

 

Q: Tests with an oscilloscope showed the sensor was responding quickly, but the
data were getting held up in the internals of the CR1000 somewhere for 30 ms or
so. Characters at the start of a response from a sensor, which come out in 5 ms,
were apparently not accessible by the program for 30 ms or so; in fact, no data
were in the serial buffer for 30 ms or so.

A: As a result of internal buffering in the CR1000 and / or external interfaces, data
may not appear in the serial port buffer for a period ranging up to 50 ms
(depending on the serial port being used). This should be kept in mind when
setting timeouts for the SerialIn() and SerialOut() instructions, or user-defined
timeouts in constructs using the SerialInChk() instruction.

 

Q: What are the termination conditions that will stop incoming data from being
stored?

A: Termination conditions:

TerminationChar

argument is received

MaxNumChars

argument is met

TimeOut

argument is exceeded

SerialIn() does NOT stop storing when a Null character (&h00) is received
(unless a NULL character is specified as the termination character). As a string
variable, a NULL character received will terminate the string, but nevertheless
characters after a NULL character will continue to be received into the variable
space until one of the termination conditions is met. These characters can later be
accessed with MoveBytes() if necessary.

Q: How can a variable populated by SerialIn() be used in more than one
sequence and still avoid using the variable in other sequences when it contains old
data?

Advertising