Section 7. Installation
3. Receive serial data as a string with
SerialIn()
or
SerialInRecord()
.
̶
Example:
SerialInRecord
(Com2,SerialInString,42,0,35,"",01)
o
Declare the string variable large enough to accept the string.
̶
Example:
Public
SerialInString As String * 25
o
Observe the input string in the input string variable in a
numeric monitor
(p. 521).
Note
SerialIn()
and
SerialInRecord()
both receive data.
SerialInRecord()
is
best for receiving streaming data.
SerialIn()
is best for receiving discrete
blocks.
4. Parse (split up) the serial string using
SplitStr()
o
Separates string into numeric and / or string variables.
o
Example:
SplitStr
(InStringSplit,SerialInString,"",2,0)
o
Declare an array to accept the parsed data.
̶
Example:
Public
InStringSplit(2)
As String
̶
Example:
Public
SplitResult(2)
As Float
7.9.17.5.3 Serial I/O Output Programming Basics
Applications with the purpose of transmitting data to another device usually
include the following procedures. Other procedures may be required depending on
the application.
1. Open a serial port with
SerialOpen()
to configure it for communications.
o
Parameters are set according to the requirements of the communication
link and the serial device.
o
Example:
SerialOpen
(Com1,9600,0,0,10000)
o
Designate the correct port in CRBasic.
o
Correctly wire the device to the CR1000.
o
Match the port baud rate to the baud rate of the device in CRBasic.
o
Use a fixed baud rate (rather than auto baud) when possible.
2. Build the output string.
o
Example:
SerialOutString
= "*" & "27.435" & "," & "56.789" & "#"
o
Tip — concatenate (add) strings together using & instead of +.
o
Tip — use
CHR()
instruction to insert ASCII / ANSI characters into a
string.
252
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: ......