Example Using Rs-232 Mode; Rs-232 Mode Example - Campbell SDM-SIO1A Instruction Manual

Hide thumbs Also See for SDM-SIO1A:
Table of Contents

Advertisement

6.3.2.1 Example using RS-232 Mode

CRBasic Example 6-1. RS-232 Mode Example
'-----------------------------------------------------------------------
' 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 datalogger to the sensor and it then waits for a response
' before reading the data.
' The datalogger then retrieves the data and places it into a string
'-----------------------------------------------------------------------
Public
ReturnedData
as string
BeginProg
Const
SensorPort = 32
'The sensors address switch should be set to position 0
SDMSpeed
(30)
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)
'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 data","Start",1,100)
SerialIn
(ReturnedData,SensorPort,100,0,100)
SerialClose
(SensorPort)
'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
SDM-SIO1A and SDM-SIO4A Serial Input/Output Modules
* 100
'string where the data from the datalogger is stored
'Declare the serial port the sensor is set to
'Optionally set the SDMSpeed - not normally needed
'open the serial port to the sensor
'Close the serial port to the sensor
'Send data to the sensor
'Get data from the sensor
21

Advertisement

Table of Contents
loading

This manual is also suitable for:

Sdm-sio4a

Table of Contents