Several Things, Need Guidance


RJE

Recommended Posts

Greetings All

I've had the 1 second data packet from my energy monitor parsed and displayed in DF now for a couple years. Amps, volts, hi & lows graphed and logged etc but I never got around to dealing with the kWh counter. This is just a channel that is updated every second with the new value. Always increasing until I reset the monitor unit back to zero.

I'd like to display a daily kWh use bar graph for each month then at the end of the month export/log it for future reference and then start the next month.

The more I think about this the more complicated it seems and starting out on the wrong foot could be a bad thing.

Some guidance would be appreciated to start out right.

Thanks

Randy

Link to comment
Share on other sites

Yeah, doing kWh is actually a little complicated, but not too hard. I'm assuming that your kwh counter channel is showing accumulated kwh. Let's say its called simply "kwh". What you want to do is this:

1) create a sequence marked autostart (or add to an existing one) the following:

global lastKwh = -1

2) create a new channel called DailyKwh. Device type "Test", A/D, Ch#0, Timing = 0.

3) in the Event for the kwh channel (click on kwh in the workspace under CHANNELS:, then click the event tab), put:


if (kwh.time[0] % 86400 < kwh.time[1] % 86400) // day turned over
if (lastKwh != -1)
private totalKwh = kwh[0] - lastKwh
totalKwh.time = kwh.time[0]
DailyKwh.addValue(totalKwh)
endif
lastKwh = kwh[0]
endif

[/CODE]

What this does is wait until the day has turned over and then calculates the difference between the reading from beginning of yesterday and the first reading from today. The reading from yesterday is then updated with the reading from today, ready for 24 hours from now. Note that we check if lastKwh = -1, which means we haven't gone through a full day. This means that the system will not calculate a kwh total on the day DAQFactory is started because DAQFactory doesn't know the kwh reading at midnight the previous day. There are ways to avoid this, but it gets a lot harder, and hopefully you aren't restarting DAQFactory much.

Now that you have dailyKwh as a channel, you can do whatever you want with it, trend it, log it, etc.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.