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
Содержание CR1000
Страница 2: ......
Страница 4: ......
Страница 6: ......
Страница 32: ......
Страница 36: ......
Страница 38: ......
Страница 40: ......
Страница 60: ...Section 4 System Quickstart Figure 16 PC200W View Line Graph 60 ...
Страница 96: ......
Страница 98: ...98 ...
Страница 302: ......
Страница 350: ...Section 8 Operation Figure 91 Pulse Sensor Output Signal Types Figure 92 Switch Closure Pulse Sensor 350 ...
Страница 453: ...Section 8 Operation Figure 115 Using the Keyboard Display 453 ...
Страница 454: ...Section 8 Operation 8 8 1 Data Display Figure 116 Displaying Data with the Keyboard Display 454 ...
Страница 456: ...Section 8 Operation Figure 118 Real Time Custom 456 ...
Страница 457: ...Section 8 Operation 8 8 1 3 Final Memory Tables Figure 119 Final Memory Tables 457 ...
Страница 458: ...Section 8 Operation 8 8 2 Run Stop Program Figure 120 Run Stop Program 458 ...
Страница 460: ...Section 8 Operation Figure 122 File Edit 460 ...
Страница 461: ...Section 8 Operation 8 8 4 PCCard Memory Card Display Figure 123 PCCard CF Card Display 461 ...
Страница 478: ......
Страница 506: ......
Страница 536: ......
Страница 636: ......
Страница 642: ......
Страница 644: ......
Страница 676: ......
Страница 677: ......