Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

CR10 Programming incremental encoder


SEWESA Sep 5, 2013 08:19 PM

Hello,

I'm a bit rusty on programming the CR10X. I am using an incremental shaft encoder to a QD1. This is attached to a weighing rain recorder. When the bucket gets full and is emptied you sometimes get a negative number in the program. I want to put a subroutine or an if/then statement so that if the value is less than 0 then the value equals zero. In CRbasic this is easy but how would I go about this with a CR10X edlog program?

My current program is included. Thanks for any help.

;{CR10X}

; Seattle WFO Encoders to SAT-HDR-GOES transmitters
;
; Wiring Diagram For Precip
;
; Datalogger QD1(D) QD1(E) 436A Encoder
;
; +5V ---------- +5V +5V ---------- C
; P1 ----------- P1 S1 ----------- D
; P2 ----------- P2 S2 ----------- E
; GND ---------- G G ------------ F

*Table 1 Program
01: 60.0000 Execution Interval (seconds)

;
; Measure and record Precip
; Multiplier is at 1.0 which will make the data appear in tenths of an inch,
; due to transmitter only handling whole numbers (4.1 inches in bucket = 41.00)

1: Pulse (P3)
1: 2 Reps
2: 1 Pulse Channel 1
3: 0 High Frequency, All Counts
4: 1 Loc [ Editoro_1 ]
5: 1.0 Multiplier
6: 0.0 Offset

2: Z=X+Y (P33)
1: 3 X Loc [ Precip ]
2: 4 Y Loc [ EditoronE ]
3: 3 Z Loc [ Precip ]

3: Z=X-Y (P35)
1: 3 X Loc [ Precip ]
2: 5 Y Loc [ DownCount ]
3: 3 Z Loc [ Precip ]

; Sample Precip for roll over

4: If time is (P92)
1: 0 Minutes (Seconds --) into a
2: 1 Interval (same units as above)
3: 10 Set Output Flag High (Flag 0)

5: Set Active Storage Area (P80)
1: 3 Input Storage Area
2: 6 Loc [ Rain_4 ]

6: Sample (P70)^9961
1: 1 Reps
2: 3 Loc [ Precip ]

;
; Measure and record Battery voltage
;

7: Batt Voltage (P10)
1: 7 Loc [ Battery ]

; Convert battery voltage to hundredths of a volt due to transmitter only handling whole numbers

8: Z=X*F (P37)
1: 7 X Loc [ Battery ]
2: 100 F
3: 7 Z Loc [ Battery ]

; Sample Battery for roll over

9: If time is (P92)
1: 0 Minutes (Seconds --) into a
2: 1 Interval (same units as above)
3: 10 Set Output Flag High (Flag 0)

10: Set Active Storage Area (P80)
1: 3 Input Storage Area
2: 8 Loc [ Batt_4 ]

11: Sample (P70)^21512
1: 1 Reps
2: 7 Loc [ Battery ]

;
; Every 15 minutes, roll data over in an array
;

12: If time is (P92)
1: 0 Minutes (Seconds --) into a
2: 15 Interval (same units as above)
3: 30 Then Do

; Set source and destination for Precip
13: Z=F x 10^n (P30)
1: 11 F
2: 00 n, Exponent of 10
3: 9 Z Loc [ Src_1 ]

14: Z=F x 10^n (P30)
1: 10 F
2: 00 n, Exponent of 10
3: 10 Z Loc [ dst_1 ]

15: Beginning of Loop (P87)
1: 0000 Delay
2: 4 Loop Count

16: Indirect Move (P61)
1: 9 Source Loc [ Src_1 ]
2: 10 Destination Loc [ dst_1 ]

17: Z=X+F (P34)
1: 9 X Loc [ Src_1 ]
2: 1 F
3: 9 Z Loc [ Src_1 ]

18: Z=X+F (P34)
1: 10 X Loc [ dst_1 ]
2: 1 F
3: 10 Z Loc [ dst_1 ]


19: End (P95)
; Set source and destination for Battery
20: Z=F x 10^n (P30)
1: 16 F
2: 00 n, Exponent of 10
3: 9 Z Loc [ Src_1 ]

21: Z=F x 10^n (P30)
1: 15 F
2: 00 n, Exponent of 10
3: 10 Z Loc [ dst_1 ]

22: Beginning of Loop (P87)
1: 0000 Delay
2: 4 Loop Count

23: Indirect Move (P61)
1: 9 Source Loc [ Src_1 ]
2: 10 Destination Loc [ dst_1 ]

24: Z=X+F (P34)
1: 9 X Loc [ Src_1 ]
2: 1 F
3: 9 Z Loc [ Src_1 ]

25: Z=X+F (P34)
1: 10 X Loc [ dst_1 ]
2: 1 F
3: 10 Z Loc [ dst_1 ]

26: End (P95)
27: End (P95)


; Once an hour, store data once an hour to "Final Storage"

28: If time is (P92)
1: 1 Minutes (Seconds --) into a
2: 60 Interval (same units as above)
3: 10 Set Output Flag High (Flag 0)

29: Set Active Storage Area (P80)^26878
1: 1 Final Storage Area 1
2: 100 Array ID

30: Resolution (P78)
1: 1 High Resolution

31: Sample (P70)^28740
1: 4 Reps
2: 11 Loc [ Rain_1 ]

32: Sample (P70)^13771
1: 4 Reps
2: 15 Loc [ Batt_1 ]

; 2 minutes into the hour, write the last hours' worth of data to the transmitter

33: If time is (P92)
1: 2 Minutes (Seconds --) into a
2: 60 Interval (same units as above)
3: 30 Then Do

34: Data Transfer to HDR GOES (P126)
1: 1 Overwrite Self Timed Buffer
2: 2 18-bit Binary Format
3: 19 Result Code Loc [ GOES_Stat ]

35: End (P95)


*Table 2 Program
02: 0.0000 Execution Interval (seconds)

*Table 3 Subroutines

End Program

-Input Locations-
1 Editoro_1 5 0 1
2 Editoro_2 17 0 1
3 Precip 1 3 2
4 EditoronE 1 1 0
5 DownCount 1 1 0
6 Rain_4 1 0 1
7 Battery 1 2 2
8 Batt_4 1 0 1
9 Src_1 1 4 4
10 dst_1 1 2 6
11 Rain_1 1 1 0
12 _________ 1 1 0
13 _________ 1 1 0
14 _________ 1 1 0
15 Batt_1 1 1 0
16 _________ 1 1 0
17 _________ 1 1 0
18 _________ 1 1 0
19 GOES_Stat 1 0 1
20 _________ 0 0 0
21 _________ 0 0 0
22 _________ 0 0 0
23 _________ 0 0 0
24 _________ 0 0 0
25 _________ 0 0 0
26 _________ 0 0 0
27 _________ 0 0 0
28 _________ 0 0 0
-Program Security-
0000
0000
0000
-Mode 4-
-Final Storage Area 2-
0
-CR10X ID-
0
-CR10X Power Up-
3
-CR10X Compile Setting-
3
-CR10X RS-232 Setting-
-1
-DLD File Labels-
0
-Final Storage Labels-
0,Precip~3,9961
1,Battery~7,21512
2,100,26878
3,Rain_1~11,28740
3,_________~12
3,_________~13
3,_________~14
4,Batt_1~15,13771
4,_________~16
4,_________~17
4,_________~18


kirving Sep 5, 2013 08:39 PM

Instruction 83 is 'IF CASE X < F', so X would be your register value, fixed value 0, then maybe have a DO block to do what you need if it takes more than one instruction.

Log in or register to post/reply in the forum.