8-1
SECTION 8. PROCESSING AND PROGRAM CONTROL EXAMPLES
The following examples are intended to illustrate the use of Processing and Program Control
Instructions, flags, dual Final Storage, and the capability to direct the results of Output Processing
Instructions to Input Storage.
The specific examples may not be as important as some of the techniques employed, for example:
Directing Output Processing to Input Storage is used in the Running Average and Rainfall Intensity
examples (8.1 and 8.2).
Flag tests are used in the Running Average, Interrupt Subroutine, Converting Wind Direction, and
Saving Data Prior to Event examples (8.1, 8.5, 8.7 and 8.8).
An algorithm for a down counter is used in the Saving Data Prior to Event example (8.8).
As in Section 7 these examples are not complete programs to be taken verbatim. They need to be
altered to fit specific needs.
8.1 COMPUTATION OF RUNNING
AVERAGE
It is sometimes necessary to compute a running
average (i.e., the average covers a fixed
number of samples and is continuously updated
as new samples are taken). Because the
output interval is shorter than the averaging
period, Instruction 71 cannot be used; the
algorithm for computing this average must be
programmed by the user. The following
example demonstrates a program for
computing a running average.
In this example, each time a new measurement
is made (in this case the CR510 internal
temperature) an average is computed for the 10
most recent samples. This is done by saving all
10 temperatures in contiguous input locations
and using the Spatial Average Instruction (51)
to compute the average. The temperatures are
stored in locations 2 through 11. Each time the
table is executed, the new measurement is
stored in location 11 and the average is stored
in location 1. The Block Move Instruction (54) is
then used to move the temperatures from
locations 3 through 11 down by 1 location; the
oldest measurement (in location 3) is lost when
the temperature from location 4 is written over
it.
PROGRAM
*
Table 1 Program
01:
10.0
Execution Interval (seconds)
01:
Internal Temperature (P17)
1: 11
Loc [ Temp_i ]
02:
Spatial Average (P51)
1: 10
Swath
2:
2
First Loc [ Temp_i_9 ]
3:
1
Avg Loc [ Av_10smpl ]
03:
Block Move (P54)
1:
9
No. of Values
2:
3
First Source Loc [ Temp_i_8 ]
3:
1
Source Step
4:
2
First Destination Loc [ Temp_i_9 ]
5:
1
Destination Step
04:
Do (P86)
1: 10
Set Output Flag High
05:
Sample (P70)
1:
1
Reps
2:
1
Loc [ Av_10smpl ]
INPUT LOCATIONS
1 Av_10smpl
7 Temp_i_4
2 Temp_i_#9
8 Temp_i_3
3 Temp_i_8
9 Temp_i_2
4 Temp_i_7
10 Temp_i_1
5 Temp_i_6
11 Temp_i
6 Temp_i_5
Содержание CR510
Страница 1: ...CR510 DATALOGGER OPERATOR S MANUAL REVISION 2 03 COPYRIGHT c 1986 2003 CAMPBELL SCIENTIFIC INC ...
Страница 2: ...This is a blank page ...
Страница 4: ...This is a blank page ...
Страница 10: ...This is a blank page ...
Страница 44: ...SECTION 1 FUNCTIONAL MODES 1 14 This is a blank page ...
Страница 56: ...SECTION 3 INSTRUCTION SET BASICS 3 8 ...
Страница 104: ...SECTION 8 PROCESSING AND PROGRAM CONTROL EXAMPLES 8 8 This is a blank page ...
Страница 128: ...SECTION 10 PROCESSING INSTRUCTIONS 10 8 This is a blank page ...
Страница 144: ...SECTION 12 PROGRAM CONTROL INSTRUCTIONS 12 10 This is a blank page ...
Страница 172: ...SECTION 14 INSTALLATION AND MAINTENANCE 14 10 This is a blank page ...
Страница 176: ...APPENDIX A GLOSSARY A 4 This is a blank page ...
Страница 184: ...This is a blank page ...
Страница 188: ...APPENDIX D DATALOGGER INITIATED COMMUNICATIONS D 4 This is a blank page ...
Страница 196: ...APPENDIX F MODBUS ON THE CR10 X AND CR510 F 4 This is a blank page ...
Страница 197: ...APPENDIX G TD OPERATING SYSTEM ADDENDUM FOR CR510 CR10X AND CR23X MANUALS ...
Страница 198: ...This is a blank page ...
Страница 200: ...This is a blank page ...
Страница 206: ...TABLE DATA ADDENDUM AD 6 This is a blank page ...
Страница 222: ...TD ADDENDUM SECTION 1 FUNCTIONAL MODES AD 1 8 This is a blank page ...
Страница 238: ...TD ADDENDUM SECTION 8 PROCESSING AND PROGRAM CONTROL EXAMPLES AD 8 10 This is a blank page ...
Страница 240: ...This is a blank page ...