Example cr10x program using interrupts – Campbell Scientific SDM-SIO4 4-Channel Serial I/O Interface User Manual

Page 57

Advertising
background image

Section 5. Programming the Datalogger

5-25

*Table 2 Program

02: 0.0000

Execution Interval (seconds)

*Table 3 Subroutines

End Program

Example CR10X Program using Interrupts

Sensors with fast data output or where very close time stamping is required
would need to be read using the hardware interrupt output from the SDM-SIO4
in combination with an interrupt-driven subroutine in the datalogger (only the
CR10/10X currently support this mode). This output on the SDM-SIO4 pulses
high when there is data available from one of the serial ports.

This program will deal with sensors that send data at random intervals. It uses
the IO line to cause an interrupt to the datalogger program if data is available.
The IO line is always automatically pulsed by the SDM-SIO4 when data is
available – see ‘SDM Port’ in Section 1 for details. This should be
connected to control port 8 for this example.

A typical filter that could be used is as follows:

fltst 200 "t[data]A5xff"

This filter works as follows:

t[data] – this filter waits for an exact string match before it starts the next filter.
In this case it is waiting for the sensor to send the string ‘data’.

A5 – this filter sets up a 250ms filter time out. This time out should be long
enough for the sensor to transmit all of its data.

x – this filter marks the start of the data set. In this case the data set is two
floating point numbers.

f – this filter searches for the first ASCII floating point number to convert.

f – this filter searches for the second ASCII floating point number to convert.

*Table 1 Program

01: 2

Execution Interval (seconds)

;set control port 8 to i/p so it can be used as an interrupt

1: Set Port(s) (P20)

1:

8999

C8..C5 = input/nc/nc/nc

2:

9999

C4..C1 = nc/nc/nc/nc

;do filter setup only if flag one is clear

2: If Flag/Port (P91)

1:

21

Do if Flag 1 is Low

2:

30

Then Do

Advertising