CRBasic Example 4: RS-485 mode example
'Convert string to float
ConvertedValue = ReturnedData
'add an offset to the returned floating point value
ConvertedValue = Converte 100
SerialClose
(SensorPort)
'Close the serial port to the sensor
'this places the SDM-SIO2R into its lowest power mode
Next Scan
EndProg
B.3 Example using switched relay power
CRBasic Example 5: Switched relay mode example
'CR1000X Program showing how to use SDM-SIO2R. This program will transmit/receive
serial data and
'This program will also control the switched relay power using SDM-Generic
SequentialMode
'Sequential Mode allows for the program to have SDM-Generic
command within Conditional Statements
Public
dest
As Long
' variable holding incoming bytes from SDM device
Const
SDM_addr0
=
0
' sdm address of device communicating with. valid addresses
0-14
Const
SDM_addr1
=
1
' sdm address of device communicating with. valid addresses
0-14
Const
cmd_byte
=
7
' setup byte sent to SDM device
Public
hexVar0
As Long
' variable holding values to be sent to SDM device
Public
hexVar1
As Long
' variable holding values to be sent to SDM device
Const
num_vals_out
=
1
' number of values to be sent to SDM device. number of
bytes out - none sent
Const
source As String
=
""
' variable holding values to be sent to SDM device
Const
num_vals_in
=
0
' number of values expected to be received back from SDM
device.
Const
bytes_per_value
=
1
' number of bytes for each value sent to or received
from SDM device. one bytes
returned
Const
big_endian
=
1
' order of bytes sent or received, 0 = little endian, 1 =
big endian
Const
delay_byte
=
-0
' delay in microseconds between sending bytes (negative
means delay for incoming bytes from SDM device)
Public
Sensor_1_In As String * 50
Public
Sensor_2_In As String * 50
SDM-SIO2R Serial Input/Output Module with Switched Sensor Power
48