Campbell Scientific CR7 Measurement and Control System User Manual

Page 85

Advertising
background image

SECTION 8. PROCESSING AND PROGRAM CONTROL EXAMPLES

8-3

Every 15 minutes, the total rain is sent to Input
Storage. If the total is greater than 0, output is
redirected to Final Storage, the time is output,
and the total is sampled.

Input Location Labels:

1:Rain (mm)
2:15min tot

*

1

Table 1 Programs

01:

60

Sec. Execution Interval

01:

P3

Pulse

01:

1

Rep

02:

3

IN Card

03:

1

Pulse Input Chan

04:

2

Switch closure

05:

1

Loc [:Rain (mm)]

06:

.254

Mult

07:

0

Offset

02:

P92

If time is

01:

0

minutes into a

02:

15

minute interval

03:

10

Set high Flag 0 (output)

03:

P80

Set Active Storage Area

01:

3

Input Storage Area

02:

2

Array ID or location

04:

P72

Totalize

01:

1

Rep

02:

1

Loc Rain (mm)

05:

P89

If X<=>F

01:

2

X Loc

02:

3

>=

03:

0

F

04:

30

Then Do

06:

P80

Set Active Storage Area

01:

1

Final Storage Area

02:

25

Array ID or location

07:

P77

Real Time

01:

220

Day,Hour-Minute

08:

P70

Sample

01:

1

Rep

02:

2

Loc

09:

P95

End

8.3 SUB 1 MINUTE OUTPUT INTERVAL

SYNCHED TO REAL TIME

Instruction 92 has one minute resolution. If
processed output is required on an interval less
than one minute, Instructions 18 and 89 can be
used to set the Output Flag on a shorter
interval.

Instruction 18 takes time (tenths of seconds into
minute, minutes into day, or hours into year),
performs a modulo divide by a user specified
value and loads it into an input location.

When the modulo divisor divides evenly into the
interval, one gets a counter in an input location
that goes to 0 on a periodic interval. In this
example, tenths of seconds into the minute is
modulo divided by 300. The counter counts up
to 295 then goes to 0 (i.e., every 30 seconds;
tenths of seconds into minute has a resolution
of 0.1 seconds).

Instruction 89 is used to set the Output Flag
when the tenths of seconds counter is less than
5 (the execution interval, 0.5 seconds). With
this short program, the Output Flag could be set
when the seconds counter equaled 0.
However, if Instruction 18 followed a series of
instructions that took longer than 0.1 seconds to
execute or was in Table 2, executed at the
same interval as an extensive Table 1, the time
at which Instruction 18 was executed might be
0.1 seconds or more beyond the modulo divisor.
The value output would not equal 0. Setting the
Output Flag when the seconds counter is less
than the execution interval avoids this problem.

Using Instruction 18 keeps the output interval
synchronized with real time. If a counter
incremented within the program was used to
determine when to set the Output Flag, output
would depend on the number of times the table
was executed. The actual time of output would
depend on when the program was actually
compiled and started running. If the table
overran its execution interval (Section 1.1.1),
the output interval would not be the count
multiplied by the execution interval, but some
longer interval.

In this example a temperature (type E
thermocouple) is measured every 0.5 seconds
and the average output every 30 seconds.

Advertising