Section 7. Installation
•
Serial buffer:
The serial port buffer, which is declared in
SerialOpen()
, must
be large enough to hold all data a device will send. The buffer holds the data
for subsequent transfer to variables. Allocate extra memory to the buffer
when needed, but recognize that memory added to the buffer reduces
final-
data memory
Note
Concerning
SerialInRecord()
running in pipeline mode with
NBytes
(number of bytes) parameter = 0:
For the digital measurement sequence to know how much room to allocate in
Scan()
buffers
(default of 3),
SerialInRecord()
allocates the buffer size specified
by
SerialOpen()
(default 10,000, an overk
ill), or default 3 • 10,000 = 30 kB of
buffer space. So, while making sure enough bytes are allocated in
SerialOpen()
(the number of bytes per record • ((records/Scan)+1) + at least one extra byte),
there is reason not to make the buffer size too large. (Note that if the
NumberOfBytes
parameter is non-zero, then
SerialInRecord()
allocates only this
many bytes instead of the number of bytes specified by
SerialOpen()
).
•
Variable Declarations
— Variables used to receive data from the serial
buffer can be declared as
Public
or
Dim
. Declaring variables as
Dim
has the
effect of consuming less telecommunication bandwidth. When public
variables are viewed in software, the entire
Public
table is transferred at the
update interval. If the
Public
table is large, telecommunication bandwidth
can be taxed such that other data tables are not collected.
•
String Declarations
— String variables are memory intensive. Determine
how large strings are and declare variables just large enough to hold the
string. If the sensor sends multiple strings at once, consider declaring a single
string variable and read incoming strings one at a time.
The CR1000 adjusts upward the declared size of strings. One byte is always
added to the declared length, which is then increased by up to another three
bytes to make the length divisible by four.
Declared string length, not number of characters, determines the memory
consumed when strings are written to memory. Consequently, large strings
not filled with characters waste significant memory.
7.9.17.5.6 Demonstration Program
CRBasic example
Receiving an RS-232 String
(p. 254)
is provided as an exercise in
serial input / output programming. The example only requires the CR1000 and a
single-wire jumper between
COM1 Tx
and
COM2 Rx
. The program simulates a
temperature and relative humidity sensor transmitting RS-232 (simulated data
comes out of
COM1
as an alpha-numeric string).
254
Summary of Contents for CR1000
Page 2: ......
Page 4: ......
Page 6: ......
Page 32: ......
Page 36: ......
Page 38: ......
Page 40: ......
Page 60: ...Section 4 System Quickstart Figure 16 PC200W View Line Graph 60 ...
Page 96: ......
Page 98: ...98 ...
Page 302: ......
Page 453: ...Section 8 Operation Figure 115 Using the Keyboard Display 453 ...
Page 456: ...Section 8 Operation Figure 118 Real Time Custom 456 ...
Page 457: ...Section 8 Operation 8 8 1 3 Final Memory Tables Figure 119 Final Memory Tables 457 ...
Page 458: ...Section 8 Operation 8 8 2 Run Stop Program Figure 120 Run Stop Program 458 ...
Page 460: ...Section 8 Operation Figure 122 File Edit 460 ...
Page 461: ...Section 8 Operation 8 8 4 PCCard Memory Card Display Figure 123 PCCard CF Card Display 461 ...
Page 478: ......
Page 506: ......
Page 536: ......
Page 636: ......
Page 642: ......
Page 644: ......
Page 676: ......
Page 677: ......