Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shifted voltmeter #13

Open
wants to merge 3 commits into
base: stable
Choose a base branch
from

Conversation

landswellsong
Copy link

@landswellsong landswellsong commented Apr 26, 2022

I'm making a custom setup for development of a few features and needed a voltmeter for it. I have no idea what an OpenEVSE2 is and the code looks kind of dated, so I added support for a transformer based voltmeter that scales the input sine and puts it around half its VCC rather than zero. I bought it locally, so not sure how available it is, but seems to be quite common, called ZMPT101B. The thing looks like this just in case:
image

It required a voltage caclulation logic alteration as well as subtracting the offset rather than adding, and since for some reason those are unsigned for voltage (why? they are signed for current), I added a define. I also made the voltmeter-related defines redefinable in build time.

There's an additional commit allowing to drop GFI support in build-time, it doesn't really relate to the voltmeter code, but I threw it for good measure, as it might be useful for someone. (My setup has an external GFI unit)

PS: The "shifted voltmeter" name seems dumb, but I can't honestly think of anything better

@KipK
Copy link
Collaborator

KipK commented Apr 24, 2023

nice shot with those modules, they are less than 1$ on ali express and well sourced.
What adc pin did you use on the OpenEVSE module ?
OpenEVSE 2 is an experimental board. Perhaps you should keep the voltmeter settings on the #ifdef OPENEVSE_2 and just add yours in your #ifdef SHIFTED_VOLTMETER

@lincomatic
Copy link
Member

@landswellsong thanks very much for the work. I bought one of these boards several years ago, and never had the time to play with it.
I think it would make more sense to put this into my repo in the development branch. I've already copied it over

https://github.com/lincomatic/open_evse/tree/development

I made the define ZMPT101B instead of SHIFTED_VOLTMETER. After you test and give me some sample values to put into the VOLTMTER_xxx defines for this board, I will merge it into the stable branch, where it will eventually make back up to this repo. Please give is a whirl, and you can open up an issue on my repo to discuss tweaks.

@kimble4
Copy link

kimble4 commented Oct 22, 2024

Thanks for this, I've incorporated these changes into my own build and it's working well (accepting the relatively low precision inherent in measuring voltage this way).

A note about the ZMPT101B: The surface-mount input resistor on the high voltage side seems dangerously inadequate for the voltages it's exposed to. It's also alarmingly close to the mounting screw hole (nylon stand-offs seem like a good idea). I replaced the resistor on mine with a pair of 350V-rated 120k through-hole resistors in series, soldered to the pins of the screw terminal and transformer on the under-side of the board. At 240V, the 240k gives 1mA in the transformer, which means you can turn down the gain a bit for less noise.

Given the amount of current available, I also recommend fitting a fuse of some kind between the incoming supply and the ZMPT101B. An inline 20mm fuse-holder is convenient.

For what it's worth, I've connected the output of the ZMPT101B directly to the PP pin on the OpenEVSE V5.6 board, which is ADC pin 2. (The PP signal is unused if you have a tethered cable.) The 1k PP pull-up resistor does not appear to affect the signal. 5V and GND can be obtained from the programming header.

The calibration values I've used are:

#define DEFAULT_VOLT_SCALE_FACTOR (1220)
#define DEFAULT_VOLT_OFFSET (516)

Obviously the scale factor will be dependent on the input resistor value and the adjustment of the gain potentiometer. The best approach seems to be to get it in the right ballpark then adjust the pot until the reading matches that of a trusted voltmeter.

To determine the offset, I added a line of code to print the raw ADC value and disconnected the AC input to the ZMPT101B.

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.

4 participants