OpenBK7231T_App icon indicating copy to clipboard operation
OpenBK7231T_App copied to clipboard

Update drv_bl0942.c

Open 2Fblob opened this issue 11 months ago • 0 comments

BL0942 - Changes to enable forward / reverse energy measurement CF_CNT - the 24bit variable that collected the data from active energy accumulation could overflow, causing false readings periodically. The way this varianble reports data was changed, to be cleared after every reading (by setting CF_CNT_CLR_SEL (bit [6], reg 0x19) to one). This also simplifies the calculations, without a need to deduct previous readings (Values are simpply summed to those exixting).

CF_CNT_ADD_SEL was set to it's default (bit [6], reg 0x19) - counting positive, so the variable doesn't roll over. In order to identify the direction of power flow, CF_REVP_F (bit [0], reg 0x09) is monitored. This bit indicates the direction of the last energy Pulse CF 0: forward; 1: reverse. Therefore when performing the reading, the value of CF_CNT (Accumulated energy) can be assigned to either the forward or reverse register. At the moment, being there is only one counter register, it increases it or decreases it. In order to get this behaviour, a line on the drv_bl_shared.c file had to be commented out, to allow negative values.

One other modification: register 0x14 (Active power anti-passage register) was programmed to zero out the instantaneous power at idle (for example, when device measures noise or it's own power consumption). A Value of 64 works well and still allows a 6W light bulb power consumption to be measured. It would be good to have an entry on webpage to adjust this value.

2Fblob avatar Mar 25 '24 21:03 2Fblob