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.

Historical data from CR10X?


wpns Jun 28, 2010 03:40 PM

I'm reading watt-hours with a Continental Control Systems WattNode, which gives me a pulse every watt-hour. The code in the CR10x looks like:

; Pulse Input 1 is house power positive consumption (bought from grid)
27: Pulse (P3)
1: 1 Reps
2: 1 -- Pulse Channel 1
3: 2 Switch Closure, All Counts
4: 27 Loc [ HousePlus ]
5: 1.0 Mult
6: 0.0 Offset

[...]
[...every 10 minutes...]
43: Totalize (P72)
1: 1 Reps
2: 27 Loc [ HousePlus ]

Which works fine, and logs the data, and I can harvest it later, and do my analysis.

However, I've also got some Perl code that polls the device for current status (how much water is in the cistern, what the temperature of the freezer is, etc) using something along the lines of:

(Unlock) xxxxL

(FSA) 1A

(Select output for K) 2413J

(send 'J' configuration) \x00\x40\x00\x01\x03\x04\x0B\x13\x18\x19\x1a\x00

(Dump Binary) K

parse the binary, convert to numeric, use the values for alerting, etc.

I'd _like_ to be able to look at the power consumption over (say) the last hour, and when I poll it at midnight, the power consumption for the day, etc.

I can't figure out if I should do something in the CR10X to keep track of total pulses for the day and store them somewhere that won't get zeroed out with the Totalize command, or if I have to pull the data for the day out of the FSA (which is in my SM16 storage module).

Is there an easy way to keep track of pulses for the previous day, the last hour, so far today, etc using code in the datalogger?

I guess I don't understand how the data is stored, when it's reset to zero, and how you can control them outside of the automatic Pulse and Totalize commands.

Any thoughts would be greatly appreciated!

Thanks!


Dana Jun 28, 2010 04:27 PM

The easiest option is to set two new output intervals; e.g., 24 hour and 1 hour. Each output interval keeps track of its own intermediate storage, and it is only cleared when the condition for the output interval is true and data is written to memory.

Similar to the J/K commands, the CR10X responds to the F command by returning final storage data. So you could query the datalogger for x-amount of 10 minute data and calculate some type of total from that.

Dana


wpns Jun 28, 2010 06:31 PM

Can I have running totals that aren't written to Final Storage, but can be read (and written) with the I command at any time?

If I read 'HousePlus' with PC208W, it changes every 10 seconds (the table interval), but I can't figure out how to update it with a running sum, as it's just the number of counts in the last sampling interval.

Where does the Totalize command get its' total (for the last 10 minutes) from?

Thanks!


wpns Jun 29, 2010 12:22 AM

I guess ideally I'd like to have a running total that I can compare to the power company meter, is something like that possible?

Thanks!


Dana Jun 29, 2010 04:06 PM

To answer your question about calculating a running total, I will copy a response (thanks to ChipsNSalsa) from a discussion we had in-house:

The easy way to calculate a "moving total" is to use the AvgRun (CRBasic) or P52 (Edlog) instruction and then multiply the result by the number of samples in the running average (parameter 4 of AvgRun) to get a running
total. If you want the running total to be correct during the time that the number of samples in the running average has not yet reached the number specified in the instruction, you need to use a counter to count up the number of samples involved until the number specified in the instruction is reached. Multiply the result of the running average by the counter.

I don't have an example for Edlog, but this CRBasic program is from the CR1000 manual:

Public MeasuredRain
Public TotRun, RainAvg
Const Number = 15.0

BeginProg
Scan (1,Sec,0,0)
PulseCount (MeasuredRain,1,1 ,2,0,0.01,0)
AvgRun (RainAvg,1,MeasuredRain,Number)
TotRun = Number * RainAvg
NextScan
EndProg

For the CR10X, make sure you don't have a very old OS. There was also discussion in-house about the method used to calculate running average in the CR10X OS that could result in drift if the running total was calculated from the running average over an extended time. It was changed in an OS released about 2000.

The datalogger has input locations, intermediate storage, and final storage. Each time a measurement is made, it is stored in an input location. That input location is overwritten with each measurement. If output processing other than Sample is used, then a copy of that value is also stored in Intermediate Storage. The intermediate storage holds all the values to be processed until it is time to calculate a value (total, max, min, etc) for final storage. Once the output interval is true, the final storage value is written and intermediate storage is cleared. Intermediate storage is not accessible by the user -- it is for the datalogger's use only (though you can set a flag to temporarily disable writing to intermediate storage).

I hope this helps to answer your questions.

Regards, Dana


TweedleDee Jun 29, 2010 05:07 PM

You could simply use code similar to the following. Use the *4 to enter the total value to synch up to the meter (wait until the Scan after a pules occurs to get best synch).

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

2: Z=X+Y (P33)
1: 1 X Loc [ Counts ]
2: 2 Y Loc [ Total ]
3: 2 Z Loc [ Total ] @@1


wpns Jun 30, 2010 11:08 PM

Aha, thanks for all the help. I've set up a bunch of 'input' locations, and am manipulating them as required, adding counts, moving hourly and daily totals and zeroing accumulators, etc, and then I'm reading the data with the same J/K commands as before.

Many thanks to all for pointing me in the right direction!

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