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


MODE 1
SCAN RATE 60

1:P92     ; IF TIME
1:1       ;     is 1 minute into
2:180     ;     180 minute interval
3:30      ;     then DO...

2:P126    ;     HDR GOES
1:1       ;         self-timed, writes over old data
2:1       ;         floating point ASCII format
3:51      ;         store result in location 51

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

4:P126    ;         HDR GOES
1:1       ;             self-timed, writes over old data
2:1       ;             floating point ASCII format
3:52      ;             store result in location 52

5:P95     ;     END IF-DO

6:P95     ; END IF-DO

7:P92     ; IF TIME
1:2       ;     is 2 minutes into
2:180     ;     180 minute interval
3:30      ;     then DO...

8:P127    ;     HDR GOES STATUS
1:1       ;         read status
2:53      ;         store result in location 53

9:P127    ;     HDR GOES STATUS
1:2       ;         read last message status
2:66      ;         store result in location 66

10:P127   ;     HDR GOES STATUS
1:4       ;         read error register
2:80      ;         store result in location 80

11:P95    ; END IF-DO

12:P10    ; BATT VOLT
1:34      ;     store in location 34

13:P17    ; INTERNAL TEMP
1:33      ;     store in location 33

14:P3     ; PULSE
1:1       ;     1 repetition
2:1       ;     from pulse counter P1
3:21      ;     as low level AC, discard long interval counts, output frequency (Hz)
4:1       ;     store result in location 1
5:.098    ;     with multiplier * 0.098
6:0       ;     and with offset + 0

15:P4     ; EX-DEL-SE
1:1       ;     1 repetition
2:5       ;     using 2500 mV range, slow integration
3:4       ;     from input channel SE4
4:2       ;     drive excitation channel E2
5:2       ;     with delay 0.02 sec
6:2500    ;     with 2500 mV excitation
7:2       ;     store result in location 2
8:.142    ;     with multiplier * 0.142
9:0       ;     and with offset + 0

16: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:3       ;     store result in location 3
5:.8      ;     with multiplier * 0.8
6:.447    ;     and with offset + 0.447

17:P3     ; PULSE
1:1       ;     1 repetition
2:8       ;     from control port C8
3:2       ;     as switch closure
4:24      ;     store result in location 24
5:1       ;     with multiplier * 1
6:0       ;     and with offset + 0

18:P86    ; DO
1:45      ;     set port C5 high

19: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

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

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

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


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

24:P86    ; DO
1:55      ;     set port C5 low

25:P86    ; DO
1:46      ;     set port C6 high

26:P86    ; DO
1:77      ;     pulse port C7

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

28: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

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

30:P86    ; DO
1:77      ;     pulse port C7

31: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

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

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

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

35:P86    ;     DO
1:77      ;         pulse port C7

36:P2     ;     VOLT (DIFF)
1:1       ;         1 repetition
2:3       ;         using 25 mV range, slow integration
3:1       ;         from input channel DIFF1
4:46--    ;         store result in locations 46 through 49
5:1       ;         with multiplier * 1
6:0       ;         and with offset + 0

37:P95    ; END LOOP

38:P86    ; DO
1:77      ;     pulse port C7

39:P2     ; VOLT (DIFF)
1:1       ;     1 repetition
2:5       ;     using 2500 mV range, slow integration
3:1       ;     from input channel DIFF1
4:50      ;     store result in location 50
5:1       ;     with multiplier * 1
6:0       ;     and with offset + 0

40:P86    ; DO
1:56      ;     set port C6 low

41:P92    ; IF TIME
1:0       ;     is 0 minutes into
2:180     ;     180 minute interval
3:30      ;     then DO...

42:P34    ;     Z=X+F
1:9       ;         X value from location 9
2:273.15  ;         fixed value 273.15
3:37      ;         store sum in location 37

43:P20    ;     PORT SET
1:9999    ;         P8=nc, P7=nc, P6=nc, P5=nc
2:9130    ;         P4=nc, P3=set high, P2=1 ms pulse, P1=set low

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

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

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

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

48:P87    ;     LOOP
1:0       ;         execute on every pass
2:6       ;         for 6 iterations

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

50:P95    ;     END LOOP

51:P86    ;     DO
1:42      ;         set port C2 high

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

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

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

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

56:P20    ;     PORT SET
1:9999    ;         P8=nc, P7=nc, P6=nc, P5=nc
2:9908    ;         P4=nc, P3=nc, P2=set low, P1=input

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

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

59:P87    ;     LOOP
1:0       ;         execute on every pass
2:16      ;         for 16 iterations

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

61:P91    ;         IF FLAG/PORT
1:41      ;             if port C1 is high
2:30      ;             then DO...

62:P33    ;             Z=X+Y
1:39      ;                 X value from location 39
2:40      ;                 Y value from location 40
3:40      ;                 store sum in location 40

63:P95    ;         END IF-DO

64:P37    ;         Z=X*F
1:39      ;             X value from location 39
2:2       ;             fixed value 2
3:39      ;             store product in location 39

65:P95    ;     END LOOP

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

67:P38    ;     Z=X/Y
1:37      ;         X value from location 37
2:38      ;         Y value from location 38
3:41      ;         store ratio in location 41

68:P39    ;     Z=SQRT(X)
1:41      ;         X value from location 41
2:42      ;         store square root in location 42

69:P36    ;     Z=X*Y
1:40      ;         X value from location 40
2:42      ;         Y value from location 42
3:43      ;         store product in location 43

70:P37    ;     Z=X*F
1:43      ;         X value from location 43
2:.52176  ;         fixed value 0.52176
3:43      ;         store product in location 43

71:P34    ;     Z=X+F
1:43      ;         X value from location 43
2:-16     ;         fixed value -16
3:43      ;         store sum in location 43

72:P20    ;     PORT SET
1:9999    ;         P8=nc, P7=nc, P6=nc, P5=nc
2:9000    ;         P4=nc, P3=set low, P2=set low, P1=set low

73:P95    ; END IF-DO

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

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

76:P71    ; AVERAGE
1:7       ;     7 repetitions
2:3       ;     value from location 3

77:P71    ; AVERAGE
1:5       ;     5 repetitions
2:46      ;     value from location 46

78: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:1       ;     wind speed from location 1
5:2       ;     wind direction from location 2

79:P72    ; TOTALIZE
1:1       ;     1 repetition
2:24      ;     value from location 24


80:P70    ; SAMPLE
1:1       ;     1 repetition
2:43      ;     value from location 43

81:P70    ; SAMPLE
1:41      ;     41 repetitions
2:51      ;     value from location 51

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

83:P0     ; NOP

MODE 2
SCAN RATE 60

1:P92     ; IF TIME
1:0       ;     is 0 minutes into
2:5       ;     5 minute interval
3:30      ;     then DO...

2:P86     ;     DO
1:46      ;         set port C6 high

3:P87     ;     LOOP
1:0       ;         execute on every pass
2:10      ;         for 10 iterations

4:P86     ;         DO
1:77      ;             pulse port C7

5:P4      ;         EX-DEL-SE
1:1       ;             1 repetition
2:5       ;             using 2500 mV range, slow integration
3:3       ;             from input channel SE3
4:1       ;             drive excitation channel E1
5:10      ;             with delay 0.1 sec
6:2500    ;             with 2500 mV excitation
7:12--    ;             store result in locations 12 through 21
8:.0004   ;             with multiplier * 0.0004
9:0       ;             and with offset + 0

6:P59     ;         BRIDGE TRANSFORM, Rs=Rf(X/(1-X))
1:1       ;             1 repetition
2:12--    ;             Rs replaces X in locations 12 through 21
3:14.94   ;             with multiplier Rf = 14.94


7:P95     ;     END LOOP

8:P86     ;     DO
1:56      ;         set port C6 low

9:P95     ; END IF-DO

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

11:P92    ; IF TIME
1:0       ;     is 0 minutes into
2:180     ;     180 minute interval
3:13      ;     set flag F3 high

12:P91    ; IF FLAG/PORT
1:13      ;     if flag F3 is high
2:30      ;     then DO...

13:P86    ;     DO
1:46      ;         set port C6 high

14:P87    ;     LOOP
1:0       ;         execute on every pass
2:7       ;         for 7 iterations

15:P86    ;         DO
1:77      ;             pulse port C7

16:P95    ;     END LOOP

17:P87    ;     LOOP
1:0       ;         execute on every pass
2:5       ;         for 5 iterations

18:P86    ;         DO
1:77      ;             pulse port C7

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

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

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

22:P95    ;     END LOOP

23:P86    ;     DO
1:56      ;         set port C6 low

24:P86    ;     DO
1:10      ;         set output flag F0 high, output array id 224

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

26:P70    ;     SAMPLE
1:5       ;         5 repetitions
2:25      ;         value from location 25

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

28:P71    ;     AVERAGE
1:2       ;         2 repetitions
2:33      ;         value from location 33

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

30:P86    ;     DO
1:23      ;         set flag F3 low

31:P95    ; END IF-DO

32:P0     ; NOP

MODE 3
1:P0      ; NOP

MODE 10
1:100
2:64
3:0
4:1097729
5:2048

MODE 12
1:0
1:0
1:0

MODE 13
13:8
8:0

MODE 13
13:9
9:0

MODE 13
13:10
10:0

MODE 13
13:13
13:0

MODE 11
1:57542
2:17214
3:2304
4:99
5:99
6:1
7:15
8:2.9998
9:99
10:9H--
11:.375

;; CAUTION: experimental output tags follow:
;;
;; output array:
;;     1. id_174
;;     2. year
;;     3. day
;;     4. hhmm
;;     5. average-Loc3.P2
;;     6. average-Loc4.DIFF3
;;     7. average-Loc5.DIFF4
;;     8. average-Loc6.DIFF5
;;     9. average-Loc7.DIFF6
;;     10. average-Loc8.DIFF1
;;     11. average-Loc9.DIFF1
;;     12. average-Loc46
;;     13. average-Loc47
;;     14. average-Loc48
;;     15. average-Loc49
;;     16. average-Loc50.DIFF1
;;     17. vector_avg_spd-Loc1.P1
;;     18. vector_avg_dir-Loc2.SE4
;;     19. vector_dir_std_dev
;;     20. totalize-Loc24.C8
;;     21. sample-Loc43
;;     22. sample-Loc51
;;     23. sample-Loc52
;;     24. sample-Loc53
;;     25. sample-Loc54
;;     26. sample-Loc55
;;     27. sample-Loc56
;;     28. sample-Loc57
;;     29. sample-Loc58
;;     30. sample-Loc59
;;     31. sample-Loc60
;;     32. sample-Loc61
;;     33. sample-Loc62
;;     34. sample-Loc63
;;     35. sample-Loc64
;;     36. sample-Loc65
;;     37. sample-Loc66
;;     38. sample-Loc67
;;     39. sample-Loc68
;;     40. sample-Loc69
;;     41. sample-Loc70
;;     42. sample-Loc71
;;     43. sample-Loc72
;;     44. sample-Loc73
;;     45. sample-Loc74
;;     46. sample-Loc75
;;     47. sample-Loc76
;;     48. sample-Loc77
;;     49. sample-Loc78
;;     50. sample-Loc79
;;     51. sample-Loc80
;;     52. sample-Loc81
;;     53. sample-Loc82
;;     54. sample-Loc83
;;     55. sample-Loc84
;;     56. sample-Loc85
;;     57. sample-Loc86
;;     58. sample-Loc87
;;     59. sample-Loc88
;;     60. sample-Loc89
;;     61. sample-Loc90
;;     62. sample-Loc91
;;
;; output array:
;;     1. id_224
;;     2. year
;;     3. day
;;     4. hhmm
;;     5. sample-Loc25
;;     6. sample-Loc26
;;     7. sample-Loc27
;;     8. sample-Loc28
;;     9. sample-Loc29
;;     10. average-Loc12
;;     11. average-Loc13
;;     12. average-Loc14
;;     13. average-Loc15
;;     14. average-Loc16
;;     15. average-Loc17
;;     16. average-Loc18
;;     17. average-Loc19
;;     18. average-Loc20
;;     19. average-Loc21
;;     20. average-Loc33.panel_temperature_C
;;     21. average-Loc34.logger_battery_voltage
TEST