SECTION 8. PROCESSING AND PROGRAM CONTROL EXAMPLES

13:P End Table 1

8.4SUB 1 MINUTE OUTPUT INTERVAL SYNCHED TO REAL TIME

Output can be synchronized to seconds by pressing “-” or “C” while entering the first parameter in Instruction 92. 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 (107 Temperature Probe) is measured every 0.5 seconds and the average output every 30 seconds.

Input Location Assignments:

*

1

 

Table 1 Programs

01

 

.5

Sec. Execution Interval

01:

P17

 

Module Temperature

01:1 Loc [:Ref_Temp ]

02:P14 Thermocouple Tem (DIFF)

01:

1

Rep

02:11 2.5 mV fast Range

03:

2

IN Chan

04:2 Type E (Chromel-Constantan)

05:1 Ref Temp Loc Ref_Temp

06:2 Loc [:TC_Temp ]

07:

1

Mult

08:

0

Offset

03:

P92

If time is

01:0-- minutes (seconds--) into a

02:

30

minute or second interval

03:

10

Set high Flag 0 (output)

04:

P71

Average

01:

1

Rep

02:

2

Loc TC_Temp

05:P End Table 1

8.5INTERRUPT SUBROUTINE USED TO COUNT SWITCH CLOSURES (RAIN GAGE)

Subroutines given the label of 97 or 98 will be executed when control ports 7 or 8, respectively, go high (5 V, see Instruction 85, Section 12). In this example, Subroutine 98 and control port 8 are substituted for a pulse counting channel to count switch closures on a tipping bucket rain gage.

The subroutine adds 0.254 (mm, bucket calibrated for 0.01 inch tip) to an input location and uses Instruction 22 to delay 0.2 seconds.

The delay is to insure that any switch bouncing (when closing, the contacts actually bounce off each other, making and breaking the circuit several times) has died out before the subroutine is completed. (The pulse count inputs do this automatically.) Without the delay, the subroutine could be completed and called again by a bounce, causing false counts. The interrupt has no effect while the subroutine is still being executed.

Subroutine 98 is in effect keeping a running total in Input Storage. On the output interval, this total is sampled to Final Storage and zeroed by the program in Program Table 1.

An interrupt driven subroutine can interrupt a table while the Output Flag is set. The CR10 will complete whatever instruction it is executing, execute the subroutine, and then resume executing the table.

If the subroutine always added the count to the same location and a tip occurred while the total rain was being sampled, the subroutine would add the count to the input location before the location was zeroed, causing the count to be missed.

In the example, the subroutine adds the count to an alternate location when the Output Flag is set. Program Table 1 sets the Output Flag low after zeroing the location where the normal total is kept. The value in the alternate location is then added to location 12 and then the alternate location is zeroed.

To provide comparison, this example has the 2 pulse inputs also reading rain gages. (In a real

8-5