Example Using Rs-232 Mode - Campbell SDM-SI01A Product Manual

Table of Contents

Advertisement

B.1 Example using RS-232 mode
'-----------------------------------------------------------------------
' Example use of the SDM-SIO1A.
' This example shows how to open a serial port using an SDM-SIO1A.
' A prompt is sent from the data logger to the sensor and it then waits for a
' response before reading the data.
' The data logger then retrieves the data and places it into a string
'-----------------------------------------------------------------------
Public
ReturnedData
BeginProg
Const
SensorPort =
'The sensors address switch should be set to position 0
SDMSpeed
(30)  'Optionally set the SDMSpeed - not normally needed
Scan(1000,mSec,0,0)
'Open serial port to RS-232 mode, 115200bps, 8-bit data, 1 stop bit,
'and no parity
SerialOpen
(SensorPort,115200,3,100,10000)  'open the serial port to
'Request data' will need to be replaced with the correct command for
'your sensor
'In this example we wait for the response 'Start' for up to 1 second
'before continuing
SerialOut
(SensorPort,"Request
SerialIn
(ReturnedData,SensorPort,100,0,100)  'Get data from the sensor
SerialClose
'this places the SDM-SIO1A into its lowest power mode
'Now there would be code to read the data out of the ReturnedData string and
'either store it as strings or convert the string into number(s).
Next Scan
EndProg
CRBasic Example 3: RS-232 mode example
as string
*
100  'string where the data from the data logger
32  'Declare the serial port the sensor is set to
(SensorPort)  'Close the serial port to the sensor
SDM-SIO1A and SDM-SIO4A Serial Input/Output Modules
'is stored
'the sensor
data","Start",1,100)  'Send data to the sensor
36

Advertisement

Table of Contents
loading

This manual is also suitable for:

Sdm-si04a

Table of Contents