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.

Time interval data loggin in edlog + cr10x.


Adrian Oct 27, 2010 03:01 PM

Hi forum friends.

I use a cr10x for solar radiation measurement. Programming is done in edlog. Today it run all day but at my location that's not necesary (for solar data). So I want to set a data logging interval from 4:00 to 22:00. Saving storage capacity that way.
Perhaps I misunderstood the P92 instruction use, so i want to ask if the next piece of code will do the job.


The program run this way (I hope so): The cr10x ask the sensors 1 time per second, the first P92 instruction is true just after 4:00 until 22:00 then the second P92 instruction is true and from that moment the Totalize (P72) instruction begin to run. I get the integral value over a 10 minutes time period.

;{CR10X}

;

*Table 1 Program

  01: 1         Execution Interval (seconds)




1:  Volt (Diff) (P2)

 1: 1        Reps

 2: 3        25 mV Slow Range

 3: 1        DIFF Channel

 4: 1        Loc [ Direct    ]

 5: 1        Mult

 6: 0.0      Offset



2:  Volt (Diff) (P2)

 1: 1        Reps

 2: 3        25 mV Slow Range

 3: 2        DIFF Channel

 4: 2        Loc [ CMP11     ]

 5: 1        Mult

 6: 0.0      Offset



3:  Volt (Diff) (P2)

 1: 1        Reps

 2: 3        25 mV Slow Range

 3: 3        DIFF Channel

 4: 3        Loc [ BandW     ]

 5: 1        Mult

 6: 0.0      Offset







5:  If time is (P92)

 1: 240      Minutes (Seconds --) into a

 2: 1080     Interval (same units as above)

 3: 10       Set Output Flag High (Flag 0)




6:  If time is (P92)

 1: 00       Minutes (Seconds --) into a

 2: 10       Interval (same units as above)

 3: 10       Set Output Flag High (Flag 0)



7:  Real Time (P77)

 1: 1110     Year,Day,Hour/Minute (midnight = 0000)



8:  Totalize (P72)

 1: 1        Reps

 2: 1        Loc [ Direct    ]





9:  Totalize (P72)

 1: 1        Reps

 2: 2        Loc [ CMP11     ]





10:  Totalize (P72)

 1: 1        Reps

 2: 3        Loc [ BandW     ]





If the code above doesn't meet my expectations, how can it be done?

Thanks, Adrian.


kirving Oct 27, 2010 05:53 PM

I don't think the above code is correct. I'd suggest setting a flag based on the time of day, then use that flag as a condition for logging. In pseudo code, maybe something like:

P92 240 1440 11
' if time is 240 into 1440 minutes interval, set flag F1

P92 1320 1440 21
' if time is 1320 into 1440 minutes interval, clear flag F1

Then put the output flag statement in an if-block on that flag:

P91 11 30
' if flag F1 is high, DO (11 may not be correct)

P92 0 10 10
' if time is 0 into a 10 minutes interval, set flag F0

P77 ...
P72 ...
P72 ...

P95
' DONE -- this ends the DO-block begun with P91

This is untested, and I've guessed at a few things, but I think the idea is about right.

This approach, setting and clearing the flag at specific times, is not very robust, and it would be better to change the logic for setting the flag so it is true anytime after 0400 and before 2200.


kirving Oct 27, 2010 06:12 PM

The problem reminds me of our need to have cameras take pictures only during daylight hours, which varies a lot at high latitudes. Our approach is to estimate the elevation of the sun (angle above the horizon), then enable the camera using a setpoint angle, e.g., -10 degrees (the sun is 10 deg below the horizon).

If the sun elevation is calculated in subroutine 1, then this code enables actions based on the angle, e.g., logging data:

P86 1
' DO subroutine 1

P89 14 3 -10 30
' if loc14 >= -10 then DO

P92 0 10 10
' if time is 0 into 10 minutes interval, set flag F0

P77...

P72...
...

P95
' DONE -- end of DO block started in P89 above

I'll just include the subroutine here without annotation and in abbreviated form. Latitude, longitude, and 'timezone longitude' must be set in the first three instructions.

P85 1 ' subroutine 1
P30 68.53 0 11 ' degrees latitude in loc11, N is positive
P30 149.42 0 12 ' degrees longitude in loc12, W is positive(?)
P30 135 0 13 ' timezone longitude in loc13, UTC offset * -15
P18 3 0 14
P37 17 .01667 17
P33 16 17 14
P34 15 10 16
P37 16 360 16
P37 16 .00274 16
P34 16 90 16
P48 16 16
P37 16 -23.45 16
P35 13 12 13
P37 13 .06667 13
P33 13 14 13
P37 13 15.0 12
P34 12 90 14
P48 14 14
P34 11 -90 11
P36 11 14 14
P33 14 16 14 ' result, elevation of sun, is in loc14
P95

I could provide more explanation if anyone is interested.


ChipsNSalsa Oct 27, 2010 06:22 PM

Untested, but I think this is pretty robust. I've also utilized reps in the totalize instruction because the three input locations your totalizing are sequential.

1: Time (P18)
1: 1 Minutes into current day (maximum 1440)
2: 0 Mod/By
3: 4 Loc [ NowMin ]

2: If (X<=>F) (P89)
1: 4 X Loc [ NowMin ]
2: 3 >=
3: 240 F
4: 30 Then Do

3: If (X<=>F) (P89)
1: 4 X Loc [ NowMin ]
2: 4 <
3: 1320 F
4: 30 Then Do

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

5: Real Time (P77)
1: 1110 Year,Day,Hour/Minute (midnight = 0000)

6: Totalize (P72)
1: 3 Reps
2: 1 Loc [ Direct ]

7: End (P95)

8: End (P95)

* Last updated by: ChipsNSalsa on 10/27/2010 @ 2:42 PM *


Adrian Oct 27, 2010 08:10 PM

kirving, ChipsNSalsa, thanks a lot for your responses.

My first thinking approach was in the direction ChipsNSalsa indicate because it looks more like "traditional programming",but I wanted to take a look the buit-in edlog "funtions".

So, I see this was wrong:

5:  If time is (P92)

 1: 240      Minutes (Seconds --) into a
 2: 1080     Interval (same units as above)
 3: 10       Set Output Flag High (Flag 0)

This code set the flag high at 400 and will do the same every 18 hours (1080 minutes)? Or I don't get it yet?
If it works that way I understand why it isn't robust. Thank kirving for make note that.

I used 3 diferent Totalize instruction to keep track the instrument name in the output.


I'll back with more questions later.

Adrian


kirving Oct 27, 2010 08:40 PM

The P92 instruction is true only at the given time into the given interval, so 'P92 240 1080 10' sets flag F0 high at 240 minutes into an interval of 1080 minutes. Nothing happens *at* 1080 minutes. (*)

The code I showed uses two P92s, one to trigger at 04:00, the other at 22:00 hours, and each is only true at those specific times. The reason this isn't robust is that if the flag was turned off, e.g., by a manual command using the keypad, at 06:00 hours, it wouldn't turn on again until 04:00 the next day.

The other poster used arithmetic comparisons to reach the logging code based on the current time, so cannot be broken the way my more fragile event-driven code could be.

(*) Note that 'P92 240 1080 10' is equivalent to 'P92 240 1440', as the interval parameter is modulo the max value (1440 minutes or 60 seconds) of the interval.


ChipsNSalsa Oct 27, 2010 08:42 PM

When you have a structure like

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

5: Real Time (P77)
1: 1110 Year,Day,Hour/Minute (midnight = 0000)

6: Totalize (P72)
1: 3 Reps
2: 1 Loc [ Direct ]

every scan the totalize instruction actually executes regardless of the If Time condition defined. When the If Time condition is not true the current measurement value is simply added to an accumulator (for the totalize instruction) in intermediate storage. Only if the If Time condition is true does the output flag get set high resulting in the accumulated value being output to final storage and clearing of the accumulator in intermediate storage.

Let's say that you had a 1 second scan rate and your "Direct" measurement remained at a value of 1 for the entire 10 minute period. Every 10 minutes you would get 600 (60 seconds * 10 minutes) output to final storage.

* Last updated by: ChipsNSalsa on 10/27/2010 @ 2:45 PM *

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