Section 7. Installation
315
7.7.18.5.6
Serial I/O Example I
CRBasic example Receiving an RS-232 String
(p. 315)
is provided as an exercise in
serial input / output programming. The example only requires the CR3000 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).
Receiving an RS-232 String
'This program example demonstrates CR3000 serial I/O features by:
' 1. Simulating a serial sensor
' 2. Transmitting a serial string via COM1 TX.
'The serial string is received at COM2 RX via jumper wire. Simulated
'air temperature = 27.435 F, relative humidity = 56.789 %.
'Wiring:
'COM1 TX (C1) ----- COM2 RX (C4)
'Serial Out Declarations
Public
TempOut
As Float
Public
RhOut
As Float
'Declare a string variable large enough to hold the output string.
Public
SerialOutString
As String
* 25
'Serial In Declarations
'Declare a string variable large enough to hold the input string
Public
SerialInString
As String
* 25
'Declare strings to accept parsed data. If parsed data are strictly numeric, this
'array can be declared as Float or Long
Public
InStringSplit(2)
As String
Alias
InStringSplit(1) = TempIn
Alias
InStringSplit(2) = RhIn
'Main Program
BeginProg
'Simulate temperature and RH sensor
TempOut = 27.435
'Set simulated temperature to transmit
RhOut = 56.789
'Set simulated relative humidity to transmit
Scan
(5,Sec, 3, 0)
'Serial Out Code
'Transmits string "*27.435,56.789#" out COM1
SerialOpen
(Com1,9600,0,0,10000)
'Open a serial port
'Build the output string
SerialOutString = "*" & TempOut & "," & RhOut & "#"
Summary of Contents for CR3000 Micrologger
Page 2: ......
Page 3: ......
Page 4: ......
Page 6: ......
Page 30: ......
Page 34: ......
Page 36: ......
Page 96: ......
Page 485: ...Section 8 Operation 485 8 11 2 Data Display FIGURE 110 Keyboard and Display Displaying Data ...
Page 487: ...Section 8 Operation 487 FIGURE 112 CR1000KD Real Time Custom ...
Page 491: ...Section 8 Operation 491 FIGURE 116 Keyboard and Display File Edit ...
Page 496: ......
Page 502: ......
Page 564: ...Section 11 Glossary 564 FIGURE 126 Relationships of Accuracy Precision and Resolution ...
Page 566: ......
Page 594: ......
Page 598: ......
Page 600: ......
Page 602: ......
Page 624: ......
Page 642: ......
Page 643: ......