Section 7. Installation
302
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 CR800 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 CR800 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?
A
: A simple caution is that the destination variable should not be used in more
than one sequence to avoid using the variable when it contains old data.
However, this is not always possible and the root problem can be handled more
elegantly.
When data arrives independent from execution of the CRBasic program, such as
occurs with streaming data, measures must be taken to ensure that the incoming
data are updated in time for subsequent processes using that data. When the task
of writing data is separate from the task of reading data, you should control the
flow of data with deliberate control features such as the use of flags or a time-
stamped weigh point as can be obtained from a data table.
There is nothing unique about
SerialIn()
with regard to understanding how to
correctly write to and read from global variables using multiple sequences.
SerialIn()
is writing into an array of characters. Many other instructions write
Summary of Contents for CR800 Series
Page 2: ......
Page 4: ......
Page 6: ......
Page 32: ......
Page 34: ......
Page 54: ......
Page 92: ......
Page 310: ......
Page 446: ...Section 8 Operation 446 8 11 2 Data Display FIGURE 100 CR1000KD Displaying Data ...
Page 448: ...Section 8 Operation 448 FIGURE 102 CR1000KD Real Time Custom ...
Page 449: ...Section 8 Operation 449 8 11 2 3 Final Storage Data FIGURE 103 CR1000KD Final Storage Data ...
Page 450: ...Section 8 Operation 450 8 11 3 Run Stop Program FIGURE 104 CR1000KD Run Stop Program ...
Page 452: ...Section 8 Operation 452 FIGURE 106 CR1000KD File Edit ...
Page 456: ......
Page 462: ......
Page 523: ...Section 11 Glossary 523 FIGURE 116 Relationships of Accuracy Precision and Resolution ...
Page 524: ......
Page 526: ......
Page 556: ......
Page 558: ......
Page 560: ......
Page 597: ......