Campbell Scientific SDM-SIO4 4-Channel Serial I/O Interface User Manual

Page 50

Advertising
background image

Section 5. Programming the Datalogger

5-18

by using Instruction 22, or a delay loop, or more efficiently by running
some of the other measurement tasks required of the datalogger. After the
minimum delay, these tasks could also include further communications with
the SDM-SIO4 to deal with one of the other sensors connected to another
port.

3. Finally the SDM-SIO4 instruction is used to read the collected data back

from the SDM-SIO4. Commands 4 or 66 are used for this function.

Example CR10X Program Using Instruction P113 Command 4

This program is written so that, on every execution interval, the datalogger will
send a string out of port 1 to command the sensor to transmit its measurements
back to the SDM-SIO4, which has a filter set up ready to receive the data.

The output formatter is set up to transmit a string as follows:

strst 101 "Send Data^J^M"

Here is how the above string works:

strst 101 – this is the command to store a sting in area 101.

Send Data – this is the command string the sensor will execute.

^J^M – this is a way of entering control characters for carriage return/linefeed

into a string

The following program example works as follows:

1. The first P113 sets up a simple filter to search for floating point numbers.

2. The first parameter of this command is used to transmit a string which will

prompt the sensor into taking measurements and then transmitting the
numbers to the SDM-SIO4.

3. A delay is required by the set up formatter command and is calculated as

follows:

delay=chars*0.26*ports.

This works out as the following: 11*0.26*1 = 2.86ms. Also you will have to
wait long enough for the sensor to respond which must include the time to
receive and transmit the data. This example is using a 9600 baud rate, and
so 11 characters could take 12ms for the sensor command and another 20
characters (21ms) for output data from the sensor. The total time before the
datalogger can get the data would therefore be 2.86+12+21 = 35.86ms. This
time does not allow for any delay that the sensor may have in executing and
taking any measurements. This example gives the sensor 4.24ms for
measurements by giving P22 a 40ms delay.

4. By doing the above, the datalogger can get the two floating point values

returned from the sensor into locations 1 and 2.

Advertising