Skip to content

[HLW8012] Improve stability and resolution Voltage/Current measurement - #4328

Merged
TD-er merged 3 commits into
letscontrolit:megafrom
TD-er:bugfix/HLW8012_jitter
Nov 3, 2022
Merged

[HLW8012] Improve stability and resolution Voltage/Current measurement#4328
TD-er merged 3 commits into
letscontrolit:megafrom
TD-er:bugfix/HLW8012_jitter

Conversation

@TD-er

@TD-er TD-er commented Nov 2, 2022

Copy link
Copy Markdown
Member

Every now and then there would be some fluke measurements, due to some late interrupt handling. Now the pulses on CF1 are counted as well as measured. For low pulse counts, only the duration of the last pulse is taken as it may take some time to get stable pulses. Thus then it is better to use only the last one of a period. For high pulse counts, it is better to take the duration over a longer time and then average over the nr of pulses.

Before this, the "resolution" of the mains voltage measurements were roughly 8V and thus completely unusable.
image
The resolution of the POW r1 using the code from before this PR.

And with this PR included:
image

With these changes, the resolution of the mains voltage is closely following the measured voltage of the CSE7766, used in the Sonoff POW2. (less than 0.1 V off in the same wall socket)

image
Left Sonoff POW r1, right Sonoff POW r2
Both measuring interval of 60 seconds, but not exactly at the same second.

TD-er added 3 commits November 3, 2022 00:42
Every now and then there would be some fluke measurements, due to some late interrupt handling.
Now the pulses on CF1 are counted as well as measured.
For low pulse counts, only the duration of the last pulse is taken as it may take some time to get stable pulses. Thus then it is better to use only the last one of a period.
For high pulse counts, it is better to take the duration over a longer time and then average over the nr of pulses.

Before this, the "resolution" of the mains voltage measurements were roughly 8V and thus completely unusable.
With these changes, the resolution of the mains voltage is closely following the measured voltage of the CSE7766, used in the Sonoff POW2. (less than 0.1 V off in the same wall socket)
@TD-er

TD-er commented Nov 3, 2022

Copy link
Copy Markdown
Member Author

Also made a PR to the original library for these improvements: xoseperez/hlw8012#32

@TD-er
TD-er merged commit d67c354 into letscontrolit:mega Nov 3, 2022
@TD-er
TD-er deleted the bugfix/HLW8012_jitter branch November 3, 2022 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant