calculating p_ch1 net watts from btmon's aws and pws
-
- Posts: 11
- Joined: Tue Dec 03, 2013 4:25 pm
calculating p_ch1 net watts from btmon's aws and pws
I’m confused by the p_ch1 “net” power calc coming out of btmon (ver. 3.1.1) that gets sent to SEG. My confusion started when I tried to reproduce my p_ch1 stream downloaded from SEG using the aws and pws values written to my local SQLITE database. I’ve got Ch1 of my ECM-1240 measures power flowing in and out of my house (my PV system often generates more than I use). To reproduce p_ch1, I calculated the watts per measurement interval by subtracting adjacent aws and pws readings and dividing by the time interval, i.e., aw = (aws1-aws0) / (sec_counter1-sec_counter0). These values are the same as the “Ch1 Positive Watts” and “Channel 1 Negative Watts” reported when btmon is run with the -p option. I understand that btmon calculates “net” power = 2*pw-aw. I found that p_ch1 does equal 2*pw-aw whenever pw = 0 or pw = aw. But I’m finding that whenever pw is greater than 0 but not equal to aw, the p_ch1 value that btmon sends to SEG is aw, not 2*pw-aw. My ECM-1240's send frequency is 60 seconds, so my pw value is greater than 0 but not equal to aw whenever power flows in both directions during a 60 second measurement interval.
Can anyone help me understand this apparent inconsistency? And more importantly, show me how to calculate the p_ch1 value using the aws and pws values store in my SQLITE database?
Can anyone help me understand this apparent inconsistency? And more importantly, show me how to calculate the p_ch1 value using the aws and pws values store in my SQLITE database?
-
- Site Admin
- Posts: 4269
- Joined: Fri Jun 04, 2010 9:39 am
Re: calculating p_ch1 net watts from btmon's aws and pws
aw is the summation of used + generated.
You should be able to get your net metered data by doing:
kwh = (delta_aw - 2*delta_pw)/3600000
watt = (delta_aw - 2*delta_pw)/delta_seconds
You should be able to get your net metered data by doing:
kwh = (delta_aw - 2*delta_pw)/3600000
watt = (delta_aw - 2*delta_pw)/delta_seconds
Ben
Brultech Research Inc.
E: ben(at)brultech.com
Brultech Research Inc.
E: ben(at)brultech.com
-
- Posts: 11
- Joined: Tue Dec 03, 2013 4:25 pm
Re: calculating p_ch1 net watts from btmon's aws and pws
Thanks, ben. The problem is that the "net" kwh output sent by btmon to SEG and OEM seems to be inconsistent with these equations. Specifically, whenever pw is greater than zero and less than aw, btmon appears to set "net" kwh or watt values to aw, not aw-2*pw.ben wrote:aw is the summation of used + generated.
You should be able to get your net metered data by doing:
kwh = (delta_aw - 2*delta_pw)/3600000
watt = (delta_aw - 2*delta_pw)/delta_seconds
Could there really be such a significant calculation bug in btmon? Or could there be a configuration problem in my ECM-1240 that causes this?
-
- Site Admin
- Posts: 4269
- Joined: Fri Jun 04, 2010 9:39 am
Re: calculating p_ch1 net watts from btmon's aws and pws
It looks like the calculations are here:
I'm not seeing any issues there.
Code: Select all
pwh = ret[tag+'_pws'] / SpH
nwh = (ret[tag+'_aws'] - ret[tag+'_pws']) / SpH
prev_dwh = 0
if REVERSE_POLARITY:
ret[tag+'_pwh'] = nwh
ret[tag+'_nwh'] = pwh
prev_dwh = (prev[tag+'_aws'] - 2*prev[tag+'_pws']) / SpH
else:
ret[tag+'_pwh'] = pwh
ret[tag+'_nwh'] = nwh
prev_dwh = (2*prev[tag+'_pws'] - prev[tag+'_aws']) / SpH
ret[tag+'_wh'] = ret[tag+'_pwh'] - ret[tag+'_nwh']
ret[tag+'_dwh'] = ret[tag+'_wh'] - prev_dwh
Ben
Brultech Research Inc.
E: ben(at)brultech.com
Brultech Research Inc.
E: ben(at)brultech.com
-
- Posts: 11
- Joined: Tue Dec 03, 2013 4:25 pm
Re: calculating p_ch1 net watts from btmon's aws and pws
But take a look at the power (not energy) calcs in the section immediately preceding the one you quoted:
I didn't get very far beyond "Hello World" in my python programing class, but I think I see in the above that nw = (daws / ds) - (dpws / ds). I'm translating this as "net watts = absolute watts - positive watts". nw and pw (positive watts) are then swapped if the REVERSE_POLARITY flag is set. Finally, absolute watts ([tag+'_w'] in the code) is set negative if pw = 0.
This code seems to incorrectly calculate power as (absolute watts - positive watts) rather than (2*positive watts - absolute watts). But given my lack of python experience, I could easily be missing something.
Code: Select all
# Detect counter wraparound and deal with it
daws = ret[tag+'_aws'] - prev[tag+'_aws']
if ret[tag+'_aws'] < prev[tag+'_aws']:
daws += self.BYTE5_COUNTER_MAX
wrnmsg('energy counter wraparound detected for %s' % tag)
dpws = ret[tag+'_pws'] - prev[tag+'_pws'] #SR: dpws = delta positive watt-sec
if ret[tag+'_pws'] < prev[tag+'_pws']:
dpws += self.BYTE5_COUNTER_MAX
wrnmsg('polarized energy counter wraparound detected for %s' % tag)
# Calculate average power over the time period
ret[tag+'_w'] = daws / ds
pw = dpws / ds
nw = ret[tag+'_w'] – pw
if REVERSE_POLARITY:
ret[tag+'_pw'] = nw
ret[tag+'_nw'] = pw
else:
ret[tag+'_pw'] = pw
ret[tag+'_nw'] = nw
# The polarized count goes up only if the sign is positive, so use the
# value of polarized count to determine the sign of overall watts
if (ret[tag+'_pw'] == 0):
ret[tag+'_w'] *= -1
This code seems to incorrectly calculate power as (absolute watts - positive watts) rather than (2*positive watts - absolute watts). But given my lack of python experience, I could easily be missing something.
-
- Site Admin
- Posts: 4269
- Joined: Fri Jun 04, 2010 9:39 am
Re: calculating p_ch1 net watts from btmon's aws and pws
Hmm, try switching nw = ret[tag+'_w'] - pw
with
nw = ret[tag+'_w'] - 2*pw
with
nw = ret[tag+'_w'] - 2*pw
Ben
Brultech Research Inc.
E: ben(at)brultech.com
Brultech Research Inc.
E: ben(at)brultech.com
-
- Posts: 11
- Joined: Tue Dec 03, 2013 4:25 pm
Re: calculating p_ch1 net watts from btmon's aws and pws
Aah -I finally had time to work on this. 'nw' in the btmon code refers to negative watts, so this equation is correct. However a few lines further down, this code is incorrect:
'_w' is initially "absolute watts" and the code above is intended to convert absolute watts into "overall watts" by setting the sign positive or negative depending on the value of pw "positive watts". This works EXCEPT when pw is greater than 0 and less than aw, i.e., when power has flowed in both directions during a measurement interval. This equation seems to correctly calculate net power for all conditions:
I replaced the incorrect code with the correct equation in btmon and now the p_ch1 values that btmon sends to SEG are correct.
This seems to be a significant btmon bug that affects ECM-1240 power values from Ch1 and Ch2 (i.e., p_ch1) IF there is two-way flow of power on either channel. I found the incorrect net power readings were off by 20-30% in my system. I don't know whether this affects GEM devices. I checked and the energy (kWh) values that btmon sends to SEG (i.e., e_ch1), which are calculated in a subsequent section of btmon code, are not affected.
Code: Select all
nw = ret[tag+'_w'] - pw
Code: Select all
if (ret[tag+'_pw'] == 0):
ret[tag+'_w'] *= -1
Code: Select all
ret[tag+'_w'] = 2*pw - ret[tag+'_w']
This seems to be a significant btmon bug that affects ECM-1240 power values from Ch1 and Ch2 (i.e., p_ch1) IF there is two-way flow of power on either channel. I found the incorrect net power readings were off by 20-30% in my system. I don't know whether this affects GEM devices. I checked and the energy (kWh) values that btmon sends to SEG (i.e., e_ch1), which are calculated in a subsequent section of btmon code, are not affected.