; NOTE: the following CSI logger program annotations may contain errors.
; From an experimental perl module, Campbell::Program, by fnkci@uaf.edu


MODE 13
13:00  1
01:}
MODE 14

MODE 1
SCAN RATE 5
1:P10     ; BATT VOLT
1:1       ;     store in location 1

2:P17     ; INTERNAL TEMP
1:2       ;     store in location 2

3:P86     ; DO
1:44      ;     set port C4 high

4:P22     ; EXCIT w/DEL
1:1       ;     drive excitation channel E1
2:0       ;     delay 0 sec w/ excitation
3:15      ;     delay 0.15 sec after excitation
4:0       ;     with 0 mV excitation

5:P1      ; VOLT (SE)
1:1       ;     1 repetition
2:5       ;     using 2500 mV range, slow integration
3:5       ;     from input channel SE5
4:5       ;     store result in location 5
5:.1      ;     with multiplier * 0.1
6:-40     ;     and with offset + -40

6:P1      ; VOLT (SE)
1:1       ;     1 repetition
2:5       ;     using 2500 mV range, slow integration
3:6       ;     from input channel SE6
4:6       ;     store result in location 6
5:.1      ;     with multiplier * 0.1
6:0       ;     and with offset + 0

7:P86     ; DO
1:54      ;     set port C4 low

8:P86     ; DO
1:44      ;     set port C4 high

9:P22     ; EXCIT w/DEL
1:1       ;     drive excitation channel E1
2:0       ;     delay 0 sec w/ excitation
3:15      ;     delay 0.15 sec after excitation
4:0       ;     with 0 mV excitation

10:P1     ; VOLT (SE)
1:1       ;     1 repetition
2:5       ;     using 2500 mV range, slow integration
3:7       ;     from input channel SE7
4:3       ;     store result in location 3
5:.1      ;     with multiplier * 0.1
6:-40     ;     and with offset + -40

11:P1     ; VOLT (SE)
1:1       ;     1 repetition
2:5       ;     using 2500 mV range, slow integration
3:8       ;     from input channel SE8
4:4       ;     store result in location 4
5:.1      ;     with multiplier * 0.1
6:0       ;     and with offset + 0

12:P86    ; DO
1:54      ;     set port C4 low

13:P3     ; PULSE
1:1       ;     1 repetition
2:2       ;     from pulse counter P2
3:22      ;     as switch closure, discard long interval counts, output frequency (Hz)
4:7       ;     store result in location 7
5:.799    ;     with multiplier * 0.799
6:.2811   ;     and with offset + 0.2811

14:P89    ; IF X < = > F
1:7       ;     if X from location 7
2:1       ;     is =
3:.2811   ;     fixed value 0.2811
4:30      ;     then DO...

15:P30    ;     Z=F*10^exp
1:0       ;         fixed value 0
2:0       ;         times 1 (10^0)
3:7       ;         store 0 in location 7

16:P95    ; END IF-DO

17:P5     ; AC HALF BR
1:1       ;     1 repetition
2:25      ;     using 2500 mV range, reject 60 Hz
3:4       ;     from input channel SE4
4:2       ;     drive excitation channel E2
5:2500    ;     with 2500 mV excitation
6:8       ;     store result in location 8
7:720     ;     with multiplier * 720
8:0       ;     and with offset + 0

18:P2     ; VOLT (DIFF)
1:1       ;     1 repetition
2:24      ;     using 250 mV range, reject 60 Hz
3:5       ;     from input channel DIFF5
4:10      ;     store result in location 10
5:1       ;     with multiplier * 1
6:0       ;     and with offset + 0

19:P89    ; IF X < = > F
1:10      ;     if X from location 10
2:3       ;     is >=
3:0       ;     fixed value 0
4:30      ;     then DO...

20:P37    ;     Z=X*F
1:10      ;         X value from location 10
2:9.42    ;         fixed value 9.42
3:11      ;         store product in location 11

21:P37    ;     Z=X*F
1:11      ;         X value from location 11
2:1.045   ;         fixed value 1.045
3:11      ;         store product in location 11

22:P94    ; ELSE

23:P37    ;     Z=X*F
1:10      ;         X value from location 10
2:11.74   ;         fixed value 11.74
3:11      ;         store product in location 11

24:P95    ; END IF-DO-ELSE

25:P92    ; IF TIME
1:0       ;     is 0 minutes into
2:60      ;     60 minute interval
3:10      ;     set output flag F0 high, output array id 125

26:P77    ; REAL TIME
1:1220    ;     year + day(midnight=prev.day) + hour-minute(midnight=2400)

27:P71    ; AVERAGE
1:2       ;     2 repetitions
2:1       ;     value from location 1

28:P71    ; AVERAGE
1:4       ;     4 repetitions
2:3       ;     value from location 3

29:P69    ; WIND VECTOR
1:1       ;     1 repetition
2:60      ;     60 scans for standard deviation subinterval
3:0       ;     avg spd, avg dir, std dev of dir (Yamartino), for anem. & vane
4:7       ;     wind speed from location 7
5:8       ;     wind direction from location 8

30:P73    ; MAXIMUM
1:1       ;     1 repetition
2:0       ;     output value only
3:7       ;     value from location 7

31:P71    ; AVERAGE
1:1       ;     1 repetition
2:10      ;     value from location 10

32:P71    ; AVERAGE
1:1       ;     1 repetition
2:11      ;     value from location 11

33:P96    ; SERIAL OUT
1:71      ;     storage module 1

34:P0     ; NOP

MODE 2
SCAN RATE 60
1:P92     ; IF TIME
1:0       ;     is 0 minutes into
2:15      ;     15 minute interval
3:30      ;     then DO...

2:P105    ;     SDI-12 RECORDER
1:0       ;         address 0
2:0       ;         command M, initiate measurement
3:5       ;         port C5
4:13      ;         store result in location 13
5:1       ;         with multiplier * 1
6:0       ;         and with offset + 0

3:P30     ;     Z=F*10^exp
1:273.15  ;         fixed value 273.15
2:0       ;         times 1 (10^0)
3:15      ;         store 273.15 in location 15

4:P33     ;     Z=X+Y
1:3       ;         X value from location 3
2:15      ;         Y value from location 15
3:14      ;         store sum in location 14

5:P38     ;     Z=X/Y
1:14      ;         X value from location 14
2:15      ;         Y value from location 15
3:16      ;         store ratio in location 16

6:P39     ;     Z=SQRT(X)
1:16      ;         X value from location 16
2:16      ;         store square root in location 16

7:P36     ;     Z=X*Y
1:13      ;         X value from location 13
2:16      ;         Y value from location 16
3:13      ;         store product in location 13

8:P86     ;     DO
1:41      ;         set port C1 high

9:P87     ;     LOOP
1:0       ;         execute on every pass
2:13      ;         for 13 iterations

10:P86    ;         DO
1:72      ;             pulse port C2

11:P22    ;         EXCIT w/DEL
1:1       ;             drive excitation channel E1
2:1       ;             delay 0.01 sec w/ excitation
3:1       ;             delay 0.01 sec after excitation
4:0       ;             with 0 mV excitation

12:P90    ;         LOOP INDEX
1:2

13:P4     ;         EX-DEL-SE
1:2       ;             2 repetitions
2:4       ;             using 250 mV range, slow integration
3:1       ;             from input channel SE1
4:1       ;             drive excitation channel E1
5:1       ;             with delay 0.01 sec
6:250     ;             with 250 mV excitation
7:17--    ;             store result in locations 17 through 42
8:.004    ;             with multiplier * 0.004
9:0       ;             and with offset + 0

14:P95    ;     END LOOP

15:P86    ;     DO
1:51      ;         set port C1 low

16:P59    ;     BRIDGE TRANSFORM, Rs=Rf(X/(1-X))
1:26      ;         26 repetitions
2:17      ;         Rs replaces X in location 17
3:15      ;         with multiplier Rf = 15

17:P86    ;     DO
1:41      ;         set port C1 high

18:P86    ;     DO
1:43      ;         set port C3 high

19:P87    ;     LOOP
1:0       ;         execute on every pass
2:4       ;         for 4 iterations

20:P86    ;         DO
1:72      ;             pulse port C2

21:P27    ;         PERIOD AVG (SE)
1:1       ;             1 repetition
2:4       ;             period in 10e-6 seconds, range 2.0 V, max 200 kHz
3:3       ;             from input channel SE3
4:10      ;             measure for 10 cycles
5:5       ;             with timeout of 0.05 seconds
6:43--    ;             store result in locations 43 through 46
7:.001    ;             with multiplier * 0.001
8:0       ;             and with offset + 0

22:P95    ;     END LOOP

23:P86    ;     DO
1:53      ;         set port C3 low

24:P55    ;     POLYNOMIAL, F(X) = c0 + c1X + c2X^2 + c3X^3 + c4X^4 + c5X^5
1:4       ;         4 repetitions
2:43      ;         X value from location 43
3:47      ;         store F(X) in location 47
4:-.187   ;         c0 = -.187
5:.037    ;         c1 = .037
6:.335    ;         c2 = .335
7:0       ;         c3 = 0
8:0       ;         c4 = 0
9:0       ;         c5 = 0

25:P86    ;     DO
1:51      ;         set port C1 low

26:P95    ; END IF-DO

27:P92    ; IF TIME
1:0       ;     is 0 minutes into
2:60      ;     60 minute interval
3:10      ;     set output flag F0 high, output array id 227

28:P77    ; REAL TIME
1:1220    ;     year + day(midnight=prev.day) + hour-minute(midnight=2400)

29:P71    ; AVERAGE
1:1       ;     1 repetition
2:13      ;     value from location 13

30:P71    ; AVERAGE
1:25      ;     25 repetitions
2:17      ;     value from location 17

31:P71    ; AVERAGE
1:4       ;     4 repetitions
2:43      ;     value from location 43

32:P71    ; AVERAGE
1:4       ;     4 repetitions
2:47      ;     value from location 47

33:P96    ; SERIAL OUT
1:71      ;     storage module 1

34:P0     ; NOP

MODE 3
1:P0      ; NOP

MODE 10
1:50
2:91
3:0
4:573441
5:2048

MODE 12
1:0
1:0
1:0

MODE 11
1:58859
2:35198
3:1280
4:0
5:0
6:1
7:9
8:3.0859
9:0
10:0
11:2.125

;; CAUTION: experimental output tags follow:
;;
;; output array:
;;     1. id_125
;;     2. year
;;     3. day
;;     4. hhmm
;;     5. average-Loc1.logger_battery_voltage
;;     6. average-Loc2.panel_temperature_C
;;     7. average-Loc3.SE7
;;     8. average-Loc4.SE8
;;     9. average-Loc5.SE5
;;     10. average-Loc6.SE6
;;     11. vector_avg_spd-Loc7.P2
;;     12. vector_avg_dir-Loc8.SE4
;;     13. vector_dir_std_dev
;;     14. maximum-Loc7.P2
;;     15. average-Loc10.DIFF5
;;     16. average-Loc11
;;
;; output array:
;;     1. id_227
;;     2. year
;;     3. day
;;     4. hhmm
;;     5. average-Loc13
;;     6. average-Loc17
;;     7. average-Loc18
;;     8. average-Loc19
;;     9. average-Loc20
;;     10. average-Loc21
;;     11. average-Loc22
;;     12. average-Loc23
;;     13. average-Loc24
;;     14. average-Loc25
;;     15. average-Loc26
;;     16. average-Loc27
;;     17. average-Loc28
;;     18. average-Loc29
;;     19. average-Loc30
;;     20. average-Loc31
;;     21. average-Loc32
;;     22. average-Loc33
;;     23. average-Loc34
;;     24. average-Loc35
;;     25. average-Loc36
;;     26. average-Loc37
;;     27. average-Loc38
;;     28. average-Loc39
;;     29. average-Loc40
;;     30. average-Loc41
;;     31. average-Loc43
;;     32. average-Loc44
;;     33. average-Loc45
;;     34. average-Loc46
;;     35. average-Loc47
;;     36. average-Loc48
;;     37. average-Loc49
;;     38. average-Loc50
TEST