SDM-SIO1 Serial Input/Output Module
20
4.3.1.1
Example using RS-232 mode
'-----------------------------------------------------------------------
' Example use of the SDM-SIO1.
' This example shows how to open the a serial port using an SDM-SIO1.
' A prompt is sent from the logger to the sensor and it then waits for a response
' before reading the data.
' The logger then retrieves the data and places it into a string
'-----------------------------------------------------------------------
Public ReturnedData as string * 100
'string where the data from the logger is stored
BeginProg
Const SensorPort = 32
'Declare the serial port the sensor is set to
'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 the sensor
'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)
'Send data to the sensor
SerialIn (ReturnedData,SensorPort,100,0,100)
' Get data from the sensor
SerialClose (SensorPort)
'Close the serial port to the sensor
'(this places the SDM-SIO1 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