Author Topic: Brainstorm on measuring Amps, Volts and calculating PF  (Read 1769 times)

0 Members and 1 Guest are viewing this topic.

Offline madsci1016Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
Brainstorm on measuring Amps, Volts and calculating PF
« on: November 07, 2010, 03:52:56 PM »
I'm working on a small box I can install into my breaker panel that will measure my apt's electrical load.

I was first just going to use some specialized ICs to convert the AC off current transformers and output a DC value equal to the AC RMS.

But I've had some other ideas.

Instead, I'll read the AC off the current transformers directly. Bias them at 2.5V and maybe amplify with an Op Amp to give me full range 0-5V reading. I can calculate RMS from the captured waveform. Since I would have captured the real waveform, I figured I can throw in measurement of voltage to give me PF.

But how to (safely) measure AC mains volts?

Well, since I was already going to install a regulated DC wall-wart in the panel to power the circuit, I had this idea. If instead I use an unregulated AC wall wart, I can bring in lowish voltage AC into my enclosure. I can take the unregulated AC and provide my own regulated DC from it using a half bridge rectifier and voltage regulator. And I can also measure the AC using a voltage divider.

But, hmm, how would I handle the part of the wave that goes below reference ground on the micro-controller? I'm also assuming that unregulated AV wall-warts don't vary in characteristics over time. Is this safe to assume?

Is this idea flawed? I'd love some input to my crazy ramblings.

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Brainstorm on measuring Amps, Volts and calculating PF
« Reply #1 on: November 07, 2010, 05:43:44 PM »
Hi,

Well, since I was already going to install a regulated DC wall-wart in the panel to power the circuit, I had this idea. If instead I use an unregulated AC wall wart, I can bring in lowish voltage AC into my enclosure. I can take the unregulated AC and provide my own regulated DC from it using a half bridge rectifier and voltage regulator. And I can also measure the AC using a voltage divider.
You'd need to use a transformer exclusively for measuring, as (dynamically) loading it will throw off the results. Make sure the loading of the measuring transformer (passive voltage divider) is light and static.


But, hmm, how would I handle the part of the wave that goes below reference ground on the micro-controller? I'm also assuming that unregulated AV wall-warts don't vary in characteristics over time. Is this safe to assume?
A plain transformer shouldn't vary over time, but do use one that seems to be well made physically. You'd need to test whether the influence of temperature variations is large enough to matter.

Since the measuring transformer should be a separate from the one feeding power to the measuring circuit, there shouldn't be any problem with the negative parts, as you can offset the input.
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline madsci1016Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
Re: Brainstorm on measuring Amps, Volts and calculating PF
« Reply #2 on: November 07, 2010, 09:00:02 PM »
You'd need to use a transformer exclusively for measuring, as (dynamically) loading it will throw off the results. Make sure the loading of the measuring transformer (passive voltage divider) is light and static.

I figured as much after I posted.

Even if the load is just the MCU capturing analog data, you think that would be 'dynamic' enough to vary measurements? I guess the loading when the voltage was above the rectifier cutoff and below cutoff would make for a funky looking waveform.

O well, I though I could make this slightly more simple.

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Brainstorm on measuring Amps, Volts and calculating PF
« Reply #3 on: November 07, 2010, 10:33:38 PM »
Hi,

Even if the load is just the MCU capturing analog data, you think that would be 'dynamic' enough to vary measurements?
I would think so, but I cannot but give an educated guess - how hard is it to setup a test?
A transformer, 2 voltmeters, a resistor or two and a switch.
One voltmeter goes directly to the mains.
Lets say you have a 6V transformer and load the secondary with a 4k7 resistor and with the switch add in a 680 Ohm resistor. The second voltmeter over the load and read both the voltmeters with the switch open and closed. That should give a pointer.
Time to get your hands dirty (but don't get "mained" in the process).
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline madsci1016Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
Re: Brainstorm on measuring Amps, Volts and calculating PF
« Reply #4 on: November 07, 2010, 11:18:05 PM »
My thoughts exactly. Though I have access to a rather nice oscope right now, so I was just going to use that. Now I just need to get an ac output wall wart...

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Brainstorm on measuring Amps, Volts and calculating PF
« Reply #5 on: November 08, 2010, 03:37:43 AM »
Hi,

Now I just need to get an ac output wall wart...
Any non-SMPS adapter that you have lying around will do, just remove the diode bridge (temporarily if you need it back in shape later) and tap directly at the secondary side terminals.
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline madsci1016Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
Re: Brainstorm on measuring Amps, Volts and calculating PF
« Reply #6 on: November 08, 2010, 08:04:15 PM »
Experiment completed. Barely .1V difference at 20VAC.

I'm hopeful, but will measure again while actually powering my circuit off the same AC line. 

Offline madsci1016Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
Re: Brainstorm on measuring Amps, Volts and calculating PF
« Reply #7 on: November 08, 2010, 08:52:56 PM »
I have a half bridge setup feeding a 7805 regulator. Instantly found out I can only use the bare minimum capacitor possible to smooth out the half wave, makes sense in hind site.

 I can supply 22ma @ 5V from 20VAC using 20uF of capacitance on the 1/2 bridge and minimal distortion to the waveform.

Micro controller is rated for 8mA at that voltage and speed I'm running at. So far I think I'm ok.

Now for a circuit to measure the AC that's also powering the circuit. Maintaining accuracy near/at the '0V' crossing is important for PF measuring. Hmmm...  

Would going below ground on a ADC pin actually cause damage, or would it be ok and always report 0V till it comes above ground again? Spec sheet is unclear in that regard. Probably a stupid question, but had to ask.

Actually, it looks like I can just use a 1M resistor in series with the pin and let the internal diodes do there job. This just might work.
« Last Edit: November 08, 2010, 09:04:56 PM by madsci1016 »

Offline madsci1016Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
Re: Brainstorm on measuring Amps, Volts and calculating PF
« Reply #8 on: November 08, 2010, 10:43:54 PM »
Success. Here's data captured of a waveform that's also powering the circuit capturing the data.



Looks pretty darn near what my Oscope is showing.

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Brainstorm on measuring Amps, Volts and calculating PF
« Reply #9 on: November 09, 2010, 01:19:59 AM »
Hi,

Sounds great.
What about the negative half though?
If uneven loaded, it may look different.
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline madsci1016Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
Re: Brainstorm on measuring Amps, Volts and calculating PF
« Reply #10 on: November 09, 2010, 07:37:09 AM »
What about the negative half though?
If uneven loaded, it may look different.

I'm monitoring the sine source with a an oscilloscope, both halfs look good. If anything the negative half looks 'more round' because there's no slight distortion when the diode begins conducting again. More importantly, the peaks are roughly the same voltage.

Since I can't measure the negative half of the voltage, I was just going to do all my calcs from the positive half. In fact, I think I'm going to bias my CTs from ground as well, which will make PF measuring easier without have to calibrate what true '0 crossing' is from a inaccurate voltage divider.

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Brainstorm on measuring Amps, Volts and calculating PF
« Reply #11 on: November 09, 2010, 06:14:48 PM »
Hi,

What about the negative half though?
If uneven loaded, it may look different.

I'm monitoring the sine source with a an oscilloscope, both halfs look good. If anything the negative half looks 'more round' because there's no slight distortion when the diode begins conducting again. More importantly, the peaks are roughly the same voltage.
That's now.

It strikes me a bit like if examining whether humans can give birth - to make it easier, we examine only the male population, since both kinds have the same number of arms and legs anyway ;)
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline madsci1016Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
Re: Brainstorm on measuring Amps, Volts and calculating PF
« Reply #12 on: November 09, 2010, 07:24:35 PM »
That's now. ??

It strikes me a bit like if examining whether humans can give birth - to make it easier, we examine only the male population, since both kinds have the same number of arms and legs anyway ;)


The only electrical load I can think off that would only affect one half of the waveform is my first dual heat soldering iron that used a diode for the low heat setting. And even still, it would have to be quite a hefty load to strain the megawatt Xfrmr outside my apt in only one direction of current flow to cause a difference in voltage on ether side of Gnd.

Anyway, whipped up a peak detector in code, multiplied for gain through the wall wart transformer and voltage divider, and multiplied by .707 to find RMS. Compared to my handy hand held volt meter,  I'm getting an error of +/-.5V measured off the mains. That's an error of .9%, and not to shabby IMHO. Used a variac to test over a range of mains voltages.


« Last Edit: November 09, 2010, 07:53:58 PM by madsci1016 »

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Brainstorm on measuring Amps, Volts and calculating PF
« Reply #13 on: November 09, 2010, 09:42:55 PM »
Hi,

I'm getting an error of +/-.5V measured off the mains. That's an error of .9%
That should do it then. I'd guess your hand held is worse, so it could be even less (or a bit more), but never mind such small error ;D
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline madsci1016Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
Re: Brainstorm on measuring Amps, Volts and calculating PF
« Reply #14 on: November 11, 2010, 11:30:18 AM »
Soeren, if you'd be so kind as to be my second set of eyes, do you see anything blatantly wrong with my circuit? (click for full size) Most of it's been breadboarded, but it would be nice to have a second opinion before i prototype a PCB.



brief: measures voltage off the AC transformer feeding it power, creates a split +/-supply for the op amps that boost the mV coming off two current loops. (current loops already output voltage for measurement, not current) Three turn pots; one adjusts the -gain of the voltage divider dropping down the ac voltage to be measured; and positive gains of the two op amps. All three are 20 turn models for precision.

I wanted to accommodate 100 Amp services (0-1V input, op amp gain of 4) and 200 amp services (0-2V input, op amp gain of 2) with close to full range ADC.  Also wanted to allow lower voltage AC input, though it would get tricky balancing the values of the capacitors for minimal impact on source but still having enough energy throughout cycle for the Vregs.
« Last Edit: November 12, 2010, 02:59:23 PM by madsci1016 »

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Brainstorm on measuring Amps, Volts and calculating PF
« Reply #15 on: November 11, 2010, 03:42:41 PM »
Hi,


The 1M resistors in the outputs of the op-amps is going to A/D inputs (as far as I read it) and I doubt the input impedance of the A/D inputs is large enough that it doesn't matter (a good rule is 20 times up, so they'd need to be 20MOhm).

A less crucial thing, but a good rule to follow, is that when using potentiometers as a variable resistors, always connect the wiper to the end with the lowest impedance (to supply). That would be ground in your case.

It's best to balance the impedance at both inputs of an op-amp (to improve CMRR), but it's not easy when one is variable of course. The resistor at the non-inv. input should equal the parallel combination of the trimmer and the feedback resistor (R4 and R5), so if the trimmer ends on say 50k, R1 and R3 should be (50k//100k) = 33k.

I'd make C3 and C7 larger, like 22µF, or at least 'scope the outputs - AC coupled at a high sensitivity - to check for possible tendencies to oscillate. Strike a few load changes to try and provoke it into bad behaviour, while keeping an eye on the 'scope - This is best done with a second person helping, as it's hard to probe, read 'scope, make changes, avoid electrocution and make notes all at once.

Is the uneven input capacitance (+/-) because of lower demands of the negative line, or is it to get some kind of supply sequencing?


Why 100A and 200A ranges?  Regular mains fuses wouldn't allow anything like that through anyway.
« Last Edit: November 11, 2010, 03:53:05 PM by Soeren »
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline madsci1016Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
Re: Brainstorm on measuring Amps, Volts and calculating PF
« Reply #16 on: November 11, 2010, 04:46:52 PM »
The 1M resistors in the outputs of the op-amps is going to A/D inputs (as far as I read it) and I doubt the input impedance of the A/D inputs is large enough that it doesn't matter (a good rule is 20 times up, so they'd need to be 20MOhm).

Originally, i was just following the AVR app note and using the 1M to protect the MCU while the signal goes negative and the internal diodes kick in.

ADC impedance is 100MOhm. So should R6/R7 be 1/20th that?

Quote
A less crucial thing, but a good rule to follow, is that when using potentiometers as a variable resistors, always connect the wiper to the end with the lowest impedance (to supply). That would be ground in your case.

Is this a "shorting out to case while turning screw" thing, or something else?

Quote
It's best to balance the impedance at both inputs of an op-amp (to improve CMRR), but it's not easy when one is variable of course. The resistor at the non-inv. input should equal the parallel combination of the trimmer and the feedback resistor (R4 and R5), so if the trimmer ends on say 50k, R1 and R3 should be (50k//100k) = 33k.

done.

Quote
I'd make C3 and C7 larger, like 22µF, or at least 'scope the outputs - AC coupled at a high sensitivity - to check for possible tendencies to oscillate. Strike a few load changes to try and provoke it into bad behaviour, while keeping an eye on the 'scope - This is best done with a second person helping, as it's hard to probe, read 'scope, make changes, avoid electrocution and make notes all at once.

I've been monitoring both the AC in and the DC regulated out. Haven't noticed anything, but i'll look closer. Why add more capacitance after the voltage regulators? I thought the low value was needed after the regulator just to filter out HF noise.

Quote
Is the uneven input capacitance (+/-) because of lower demands of the negative line, or is it to get some kind of supply sequencing?

lower demand.

Quote
Why 100A and 200A ranges?  Regular mains fuses wouldn't allow anything like that through anyway.

Not sure how it works over there, but here the minimum residential service is 100 Amps, as is mine. My "mains fuse" is a 100amp breaker. Most housing residences over 1000-2000 sq ft typically have a 200 amp service.

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Brainstorm on measuring Amps, Volts and calculating PF
« Reply #17 on: November 11, 2010, 05:31:16 PM »
Hi,

ADC impedance is 100MOhm. So should R6/R7 be 1/20th that?
No, it's a case of "less is more".
The 20x up is just the minimum to not load the output driving it and by this introduce errors 100x up is even better - as long as you're sure it is that high.


Quote
A less crucial thing, but a good rule to follow, is that when using potentiometers as a variable resistors, always connect the wiper to the end with the lowest impedance (to supply). That would be ground in your case.

Is this a "shorting out to case while turning screw" thing, or something else?
More a "large" piece of metal acts as a receiving antenna thing.


I've been monitoring both the AC in and the DC regulated out. Haven't noticed anything, but i'll look closer. Why add more capacitance after the voltage regulators? I thought the low value was needed after the regulator just to filter out HF noise.
It's both to reduce noise and to keep it from oscillating - hence the "try to provoke it by sudden load changes". If you see ringing at a load change, add capacitance (preferably low ESR).


Not sure how it works over there, but here the minimum residential service is 100 Amps, as is mine. My "mains fuse" is a 100amp breaker. Most housing residences over 1000-2000 sq ft typically have a 200 amp service.
No lesser fuses in between the mains and an outlet?
(I know the Brit's have a fuse in each mains jack, but I haven't seen such large jacks in the US - more like just the pins and the bare minimum of plastic to keep them together).

In DK, we have 10A, 13A or 16A each group (at 230V) and 16A to 25A is normal in 480V (2 or 3 phase) groups - but you can have as many groups as you like/can afford. That's just for residential use of course.
The master fuses in the leads into a home is way larger of course, but it's out of reach for the consumer.
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline madsci1016Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
Re: Brainstorm on measuring Amps, Volts and calculating PF
« Reply #18 on: November 11, 2010, 05:43:22 PM »
No, it's a case of "less is more".
The 20x up is just the minimum to not load the output driving it and by this introduce errors 100x up is even better - as long as you're sure it is that high.

It's what the spec sheet says. So 1M is fine then? Most AVR app notes I can find say to keep source impedance as low as possible.

Quote
More a "large" piece of metal acts as a receiving antenna thing.

Got it.

Quote
It's both to reduce noise and to keep it from oscillating - hence the "try to provoke it by sudden load changes". If you see ringing at a load change, add capacitance (preferably low ESR).

inserting and removing the RF transmitter is the best load change I can think of, and I don't see any affect.

Quote

In DK, we have 10A, 13A or 16A each group (at 230V) and 16A to 25A is normal in 480V (2 or 3 phase) groups - but you can have as many groups as you like/can afford. That's just for residential use of course.
The master fuses in the leads into a home is way larger of course, but it's out of reach for the consumer.


This is to monitor my whole apt, not just a single appliance. So I'm matching the range of the main breaker (100 Amp). Here, the consumer is responsible for the main breaker, I have full access. The amp probes will be clicked onto the leads that feed the main breaker.

Our 'group' breakers are lower, and come in multiples of 5. 5,10,15 Amp, etc.

Offline madsci1016Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
Re: Brainstorm on measuring Amps, Volts and calculating PF
« Reply #19 on: November 27, 2010, 02:18:09 PM »
Had a PCB fabbed and I populated the circuit. Ran into a few issues.

First, you were right about the caps after the power supply. The +5V is still fine, but the -5V was ringing away with any disturbance. Pretty bad too, 2Vpp ringing. Fixed with a 22uF cap.

Had an issue with one of the current channels. If the current channel was 180 deg out of phase with the voltage, the signal after the OpAmp was destroyed. Decreasing the resistor value between the op Amp output and ADC input from 1M to 10k fixed the issue.

I suspect that when the adjacent ADC pin connected to the feed AC voltage through a voltage divider goes into the below ground cutoff region of the wave, it changes the impedance of all adjacent input pins, thus destroying the signal into the ADC pin watching the current channel. Lowering the 'source impedance' fixes the issue.

Anyway, thanks for the tips Soeren.

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Brainstorm on measuring Amps, Volts and calculating PF
« Reply #20 on: November 28, 2010, 06:10:41 AM »
Hi,

Had an issue with one of the current channels. If the current channel was 180 deg out of phase with the voltage, the signal after the OpAmp was destroyed. Decreasing the resistor value between the op Amp output and ADC input from 1M to 10k fixed the issue.

I suspect that when the adjacent ADC pin connected to the feed AC voltage through a voltage divider goes into the below ground cutoff region of the wave, it changes the impedance of all adjacent input pins, thus destroying the signal into the ADC pin watching the current channel. Lowering the 'source impedance' fixes the issue.

Important thing is that you got it working (=experience under the belt :)), but I think we somehow misunderstood each other on the magnitude of the A/D-C impedance.


And about the tiny PIC controllers... You don't have to swap tools, since Atmel does the SOT23-6 package too now
http://www.atmel.com/dyn/products/product_card.asp?PN=ATtiny10
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline madsci1016Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
Re: Brainstorm on measuring Amps, Volts and calculating PF
« Reply #21 on: December 19, 2010, 04:08:36 PM »

 


Get Your Ad Here

data_list