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 & "#"
Содержание CR3000 Micrologger
Страница 2: ......
Страница 3: ......
Страница 4: ......
Страница 6: ......
Страница 30: ......
Страница 34: ......
Страница 36: ......
Страница 96: ......
Страница 200: ...Section 7 Installation 200 FIGURE 42 Running Average Frequency Response FIGURE 43 Running Average Signal Attenuation ...
Страница 485: ...Section 8 Operation 485 8 11 2 Data Display FIGURE 110 Keyboard and Display Displaying Data ...
Страница 487: ...Section 8 Operation 487 FIGURE 112 CR1000KD Real Time Custom ...
Страница 488: ...Section 8 Operation 488 8 11 2 3 Final Storage Data FIGURE 113 Keyboard and Display Final Storage Data ...
Страница 489: ...Section 8 Operation 489 8 11 3 Run Stop Program FIGURE 114 Keyboard and Display Run Stop Program ...
Страница 491: ...Section 8 Operation 491 FIGURE 116 Keyboard and Display File Edit ...
Страница 495: ...Section 8 Operation 495 Low power standby whenever possible Low power bus sets bus and modules to low power ...
Страница 496: ......
Страница 502: ......
Страница 564: ...Section 11 Glossary 564 FIGURE 126 Relationships of Accuracy Precision and Resolution ...
Страница 566: ......
Страница 594: ......
Страница 598: ......
Страница 600: ......
Страница 602: ......
Страница 624: ......
Страница 642: ......
Страница 643: ......