Campbell Scientific CR10 CR10 Measurement and Control - Page 111
PanlTemp, 10smplav
View all Campbell Scientific CR10 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 111 highlights
SECTION 8. PROCESSING AND PROGRAM CONTROL EXAMPLES The following examples are intended to illustrate the use of Processing and Program Control lnstructions, flags, dual Final Storage, and the capability to direct the results of Output Processing lnstructions to lnput 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 lntensity examples (8.1 and 8.2). Flag tests are used in the Running Average, lnterrupt Subroutine, Converting Wind Direction, and Saving Data Priorto Event examples (8.1,8.5,8.7 and 8.8). Control ports and the Loop are illustrated in the AM32 example (8.3). 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 shoder than the averaging period, lnstruction 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 a thermocouple 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 SpatialAverage lnstruction (51) to compute the average. The temperatures are stored in locations 11 through 20. Each time the table is executed, the new measurement is stored in location 20 and the average is stored in location 2. The Block Move Instruction (5a) is then used to move the temperatures from locations 12 through 20 down by 1 location; the oldest measurement (in location 1 1) is lost when the temperature from location 12 is written over it. lnput Location Labels; 1:PanlTemp 2:10smplav 1 1:Temp l2:Temp i-9 i-8 13:Temp 14:Temp ii--76 1S:Temp i-5 16:Temp i-4 17:Temp i-3 18:Temp i-2 19:Temp i-1 2O:Temp i Where i is current reading, i-l is previous reading, etc. " 1 01: 10 TablelPrograms Sec. Execution lnterval 01: P17 01: 1 Panel Temperature Loc [:PanlTemp] 02: 01: 02; 03: 04: 05: 06: 07: 08: P14 1 1 1 1 1 20 1 0 Thermocouple Temp (DIFF) Rep 2.5 mV slow Range lN Chan Type T (Copper-Constantan) Ref Temp Loc Panl Temp i Loc [:Temp ] Mult Offset 03: P51 01: 10 02: 11 03: 2 SpatialAverage Swath First Loc Temp i-9 Avg Loc [:1Osmplav] 8-l