Difficulty measuring current and voltage up to 1A 120v AC, Open Energy Mon

Hello and thank you for such a great forum!

I've been doing a lot of searching and spending a lot of time on openenergymonitor.org trying to develop a tester I can use to measure up to 1 amp of AC current and 120v. I would like to use these values to calculate Wattage and Power Factor of the unit under test.

The main issue I've been having is scaling the open energy monitor from reading 100A max to 1A max and adjusting all the right values in the code to convert from UK 240v 50Hz to US 120v 60Hz with good resolution.

Initially I started by building this:
http://openenergymonitor.org/emon/buildingblocks/how-to-build-an-arduino-energy-monitor

I've breadboarded the filtering circuits, I'm using a 9vac xfmr, Arduiono Uno,

Instead of using a CT clamp, I used a:
http://www.seeedstudio.com/wiki/Grove_-_Electricity_Sensor

after tweaking some of the calibration values in the code (until I got the results I expect/matched a Kill-a-watt meter) I was able to read 70 Watts at .99 Power factor (this is the ideal result of a test this unit will be designed to perform.) but those values bounced around quite a bit (including Pf reading well above 1.00 which shouldn't be possible.)
also, when the tester is not connected (no current flowing through the CT), the wattage rests around 25W. This simply will not do.

This problem is addressed here:
http://openenergymonitor.org/emon/buildingblocks/measurement-implications-of-adc-resolution-at-low-current-values

but it basically says you cannot trust any readings below 30 watts and does not point to any solutions.

Can anyone point me to a library/project better suited to my application (measuring low AC current @ 120v to derive Pf and Wattage) or help demystify the process of scaling down the open energy monitor to give me reliable readings?

Also, I've got a sparkfun ACS712 Hall-Effect current sensor to experiment with.

Thanks!
-Nick

First, the CT on the seeedstudio board produces an AC waveform that is 1/2000th of the load circuit. As you can see from the spec sheet, a 5A AC current will produce a 2.5mA through the red doughnut. The "burden" resistor on that board is 800Ω, so the AC waveform will be 2.5mA * 800Ω = ±2V peaks when the load is drawing 5A. The Arduino analogue input pin will see -2V to +2V.

However, the Absolute Maximum rating for an analog input is -0.5V to 5.5V. Applying -2V could damage the input pin. Lucky for us, Atmel puts input protection diodes in the ATmega328 that can take up to ~1mA. These diodes will clamp the input to ~0.6V, so your chip may survive this particular setup. Some of the CT current continues to go through the burden resistor, not the 328.

It is also fortunate that you're not trying the full 5A load. With only 1A, the AC waveform will be 0.5mA * 800Ω = ±0.4V peaks, within the safe range.

Unfortunately, the protection diodes "clamp" the negative part of the waveform, which means the AnalogRead is going to return 0 for that negative half-cycle. You're losing half your data!

The solution is to "bias" the CT waveform up into the middle of the input range. Adding 2.5V is the best. Honestly, I do not understand why these "modules" are sold without a 2.5V bias! A simple solution is to use a resistor divider, say two 10k resistors in series across 5V and GND. Then hook the "GND" pin of the CT to the middle point of those two resistors, and the Vout pin of the CT to your analog input pin. This basically adds 2.5V to the CT waveform. This will avoid any clipping of the waveform, and the full 5A load will cause 0.5V to 4.5V to be read on the input pin. As mentioned in the openenergymonitor article, your sketch will decide what the zero-crossing reading will be, probably 512 or so. It will drift.

Second, this particular CT is 2000:1, so a 1A load generates a fairly small signal, 2.1V to 2.9V. You are only using about 1/5th the analog input range, so you will get readings of about 400 to 600. This is fairly coarse, when compared to the 0 to 1023 possible readings. Another way to look at it is that there are only 200 possible readings, slightly less quality than an 8-bit ADC used in full scale. You have a 10-bit ADC, and you're losing 2 bits of resolution.

The solution is to "scale" the CT waveform so that 1A load generates a signal between (let's say) 0.5V and 4.5V. You could

  • Buy a different CT module with a 400:1 ratio
  • Add an op amp circuit to multiply the signal by 5
  • Loop the load circuit wire through the CT multiple timesObviously, the last option is easiest. If you can loop it through 5 times, you will have a 2000:5 CT as desired (i.e., 400:1). Even getting the wire through twice will give you 2000:2 or 1000:1 CT, which would yield an AC waveform between 1.7V and 3.3V. Don't loop it through 2000 times! :wink:

Third, you may want to consider other input protection options (caps, series resistors, Schottky or Zener diodes etc), depending on what kind of load you have. Is it mostly resistive, like an incandescent lamp? A little inductive, like with a heater fan? Or is it purely inductive, like a pump? The more inductive your load, the bigger the transient spike when you turn it on or off. Enter "input protection" or "AC input" in the Search box above.

With a bigger range of ADC samples and both halves of the waveform, you'll get more accurate (and reasonable) E and Pf values.

Cheers,
/dev

Great response,
Thank you for including the math too. Very thorough, much appreciated. :slight_smile:

To answer your question, my load is partially inductive. It's a 40-70W LED Driver.

I have a few questions

After reading the first section of your reply:
-I believe I've already biased the output of the CT with my breadboard circuit, it's the same one OEM recommends for the CT clamps. Home | OpenEnergyMonitor

-I tried replacing my CT with a Hall-Effect breakout from sparkfun

I fed the output of this sensor directly to the analog input of the arduino and I do receive the 512 value you mention. That value alternates above and below 512 relative to the input of the hall effect but at 185ma/A output, this gives me poor resolution as well. My understanding is that I can increase the sensitivity of the hall with the use of a ferrite ring and some extra wire though. or maybe I can find a 1 or 2a rated hall-effect.

Would using an isolated hall-effect solve the input protection issues you warn about?

In the meantime I'm going to try what you suggested and loop the wire through the CT a few times, it seems like a fairly elegant solution. :slight_smile:

To answer your question, my load is partially inductive. It's a 40-70W LED Driver.

Without using a scope, I have no idea what kind of spikes to expect, but I would guess it's only during startup. The PS may have soft start to prevent the inrush... or not. If you scale the CT output up so that 1A is 2.5v ± 2V, then a 3A spike on startup would induce 2.5V±6V, or-5.5V to +8.5V on the analog input. There are various opinions on using diodes for clamping. I have used two 2.7V Zeners in parallel with the 10KΩ dividers (tied together at the 2.5V bias point) back-to-back, across the CT (see schematic in next post). I'd do something like that regardless of what I expected because, well, you know...

-I believe I've already biased the output

If we only knew your complete schematic, hint, hint.

-I tried replacing my CT with a Hall-Effect sensor

Some people have used them with great success, especially with software filtering. I've also seen that they can be noisy, so I just stayed with the CT approach. If you're calculating Pf, you want more samples, and too much filtering (e.g., averaging) can reduce your sample rate. The CT is kind of a LP filter anyway.

but at 185mV/A output, this gives me poor resolution

fixt. :slight_smile:

Would using an isolated hall-effect solve the input protection issues you warn about?

Hmmm, what's an "isolated" hall-effect sensor? This sensor provides protection from 2100V spikes on the input before "something" propagates through to the 5V side. It can handle a 100A spike, but I think you don't need input protection with this sensor: it can only output 5V, not 18.5V. [1]

Protection is only required for a CT, which is basically current-oriented (let's keep it simple for now, ignoring transformer saturation and the voltage drop across the load wire). Pushing 5A through the load wire will induce 1/2000th the same current in the CT. That current must flow. It is this current through the burden resistor that creates a voltage: V = I * R.

The problem isn't that you need isolation from a voltage spike from the load. Rather, the over-voltage occurs because a spike in the load current (and therefore a spike in the induced CT current) will cause a voltage spike across the burden resistor (e.g., 8.5V above).

My understanding is that I can increase the sensitivity of the hall with the use of a ferrite ring and some extra wire

I can't find any projects that have done that. It is mentioned here, but I'm not one to wind my own inductors, either. It also states that you may be more susceptible to noise.

Cheers,
/dev


1 I can't find anything in the datasheet that says this explicitly, but because they are using various internal amps, filters and other magic to eventually output a voltage, I think the output voltage is limited to the rails. Datasheets for some other sensors explicitly state over-voltage and reverse voltage protection, or even saturation. Maybe someone else has a definite answer about the ACS-712?

Oopsies! I realized last night that the Zener description I gave was incorrect... A schematic is always better:

My CT was 1000:1, with a burden resistor of 200Ω. I also changed the previous post.

Cheers,
/dev