go_away

Author Topic: Not So Tiny Power Meter  (Read 1080 times)

0 Members and 1 Guest are viewing this topic.

Offline madsci1016Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
Not So Tiny Power Meter
« on: December 19, 2010, 04:07:32 PM »
Hey guys,

Check out my latest project, The Not So Tiny Power Meter.

http://www.billporter.info/not-so-tiny-power-meter/


Offline TrickyNekro

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,207
  • Helpful? 15
  • 1.6L Peugeot 307 tuner
Re: Not So Tiny Power Meter
« Reply #1 on: December 19, 2010, 04:35:14 PM »
Just a question... I noticed you have been sampling the AC mains to get the voltage readings...

Why don't you use a resettable peak detector... It's just a diode, a capacitor, a transistor and some resistors...

The mains isn't a fast switching signal, still peak detector approach has been here for a longer time ;-)
For whom the interrupts toll...


P.S. I've been inactive for almost a year... Don't give promises but I'll try to complete my tutorials. I'll let you know when..

Cheers!

Offline madsci1016Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
Re: Not So Tiny Power Meter
« Reply #2 on: December 19, 2010, 04:46:25 PM »
Two reasons.

Simplicity in circuits. It's easier to change code then to change hardware after the PCB is fabbed. I always go for the simpler hardware solution because of that.

And I'm also measuring power factor & frequency, so I need accurate timing of when peak 'happened'. So 'buffering' the peak in a hardware detector is counter-productive for that.

Offline TrickyNekro

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,207
  • Helpful? 15
  • 1.6L Peugeot 307 tuner
Re: Not So Tiny Power Meter
« Reply #3 on: December 19, 2010, 08:17:22 PM »
I see... So you're able to measure the angle that current and voltage have...

That's a nice application you got there, has some physics in it  :P

What you are trying to measure is a little bit pain in the butt...

Have you thought of a comparator/pin polling approach (for a revision some day)...
You can get much more precision, not that this extra precision will do any better with the ultra slow mains,
but just asking  8) .....


BTW... I also fail to see how the ADC pin is protected from negative voltages... In the schematics you seem to be getting the voltages from the AC supply before being rectified... since the resistors are quite large at the voltage divider you aren't having any problems, but generally that's no good getting negative voltages at any pin, you know that more than I do...

And I really don't try to criticizes anyone or anything... Just trying to say an opinion... I may as well be wrong :-/
« Last Edit: December 19, 2010, 08:37:41 PM by TrickyNekro »
For whom the interrupts toll...


P.S. I've been inactive for almost a year... Don't give promises but I'll try to complete my tutorials. I'll let you know when..

Cheers!

Offline madsci1016Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
Re: Not So Tiny Power Meter
« Reply #4 on: December 19, 2010, 09:36:48 PM »
Everything has a little physics, this has way more engineering.  :P

Quote
I see... So you're able to measure the angle that current and voltage have...

Yup.

Quote
What you are trying to measure is a little bit pain in the butt...

Tell me about it....

Quote
Have you thought of a comparator/pin polling approach (for a revision some day)...
You can get much more precision, not that this extra precision will do any better with the ultra slow mains,

Hmm, explain this a little better? The trouble I had is the current clamps have very poor response with low currents, and currents near the zero crossing. The only part of the signal distinguishable above the noise is the peak, and just some random duration of the waveform before and after. I originally measured PF using zero crossing timings, but when I went to test it with the actual clamps, readings were sporadic. I O-scoped the clamps and discovered how noisy the signal was around zero crossing. That's when I realized I had to time peaks instead to measure frequency and PF.

So since the actual values of the peaks are arbitrary in regards to freq and PF, how would you use a comparator?


Quote
BTW... I also fail to see how the ADC pin is protected from negative voltages... In the schematics you seem to be getting the voltages from the AC supply before being rectified... since the resistors are quite large at the voltage divider you aren't having any problems, but generally that's no good getting negative voltages at any pin, you know that more than I do...

And I really don't try to criticizes anyone or anything... Just trying to say an opinion... I may as well be wrong :-/

Look carefully through the AVR spec sheets and you will discover how. There's clamp diodes on every IO pin, so you just need to limit current through them. In fact, there's an App note from Atmel somewhere on the web on using an AVR as a zero crossing detector for electrical disconnect equipment by simply tying an IO pin to the HV mains through a 1M resistor. Kinda scary.



Offline TrickyNekro

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,207
  • Helpful? 15
  • 1.6L Peugeot 307 tuner
Re: Not So Tiny Power Meter
« Reply #5 on: December 20, 2010, 04:25:06 AM »
BTW... I also fail to see how the ADC pin is protected from negative voltages... In the schematics you seem to be getting the voltages from the AC supply before being rectified... since the resistors are quite large at the voltage divider you aren't having any problems, but generally that's no good getting negative voltages at any pin, you know that more than I do...

And I really don't try to criticizes anyone or anything... Just trying to say an opinion... I may as well be wrong :-/


Look carefully through the AVR spec sheets and you will discover how. There's clamp diodes on every IO pin, so you just need to limit current through them. In fact, there's an App note from Atmel somewhere on the web on using an AVR as a zero crossing detector for electrical disconnect equipment by simply tying an IO pin to the HV mains through a 1M resistor. Kinda scary.

[/quote]

Doesn't it feel nice that you add doubt in your posts.... hehehe... That's a huge wow, didn't know that for sure....


Hmm, explain this a little better? The trouble I had is the current clamps have very poor response with low currents, and currents near the zero crossing. The only part of the signal distinguishable above the noise is the peak, and just some random duration of the waveform before and after. I originally measured PF using zero crossing timings, but when I went to test it with the actual clamps, readings were sporadic. I O-scoped the clamps and discovered how noisy the signal was around zero crossing. That's when I realized I had to time peaks instead to measure frequency and PF.

So since the actual values of the peaks are arbitrary in regards to freq and PF, how would you use a comparator?



That's actually an easy call... Since the mains give an almost perfect sine wave (not at the clamps but I'll talk this later), you can simply get your signal through a comparator...

Why is that... You know that when using the pin polling method you actually have a a certain frequency that the polling is happening... That also means that you can also measure time...
Take that picture for example...



Measuring the logic high time you can guess pretty accurately where the peak is.... That would be in the middle right, at least in a healthy sine wave...

Also, you can quite easily get the frequency, as the frequency would be the 1/t where t is the time between logic low to logic high transitions (or the opposite, or even better you can measure both and do the average in case your sine wave isn't so "healthy" and get an even more accurate reading)....

As for the clamps, ok... From the picture you have posted it's a little messy yup.... So why don't you add a simple low pass filter... All you need in your existing schematics is a rather small capacitor, between the signal line after the resistor and the ground if I remember the schematics correctly...

That's for a start to get a cleaner picture... It may also as well smooth the sine wave, although not so sure about this.... Depends heavily on the clamps signal.... I would guess some nanoFarad cap will do, I didn't do the math, it's nothing too serious....

Then, after the op amp amplification you can do the same as the mains voltage....

Of course you can skip the comparators with some cleaver piece of code and the ADC... But I would prefer the comparator solution to get away with the noise...

Also.... Since amplifying very small signals, you may be worried about the op amp inducing noise to your circuits.... I also think that using op amps is a little bit of an over kill...

Op amps amplify voltages.... Are you sure you don't want to sure a simple common emitter transistor amplifier.... It would make life easier, since transistors can be considered current sources and current amplifiers....

And some final piece of "advice", although I'm seriously not sure about this... Are you sure that the clamps aren't inducing a phase swift? Usually alteration of a magnet flux though a coil means alteration to the current through it, not the voltage... Even if it's producing a voltage, are you sure that this voltage is in phase with the current.... I heavily doubt what I'm saying here though.... I'm not sure about that and I should ask someone else... don't take my word for granted....

That is for now, hope I helped and not messed up things.... Keep in mind that English isn't my mother language, I'm not as good at explaining things as I'm in Greek  :P

Best Regards,
Lefteris, Greece
For whom the interrupts toll...


P.S. I've been inactive for almost a year... Don't give promises but I'll try to complete my tutorials. I'll let you know when..

Cheers!

Offline madsci1016Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
Re: Not So Tiny Power Meter
« Reply #6 on: December 20, 2010, 07:57:46 AM »
Quote
Doesn't it feel nice that you add doubt in your posts....

I did mention the clamping diodes in my blog... :-\

Quote
Also, you can quite easily get the frequency, as the frequency would be the 1/t where t is the time between logic low to logic high transitions (or the opposite, or even better you can measure both and do the average in case your sine wave isn't so "healthy" and get an even more accurate reading)....

Ok, this is what I thought you meant. It's only really effective at measuring frequency. Sine PF involves comparing two separate signals with arbitrary amplitudes, it doesn't work, since the amplitude will also affect when the logic level flips. And since I had to code peak detectors for PF, I just did it for frequency as well.

Quote
As for the clamps, ok... From the picture you have posted it's a little messy yup.... So why don't you add a simple low pass filter... All you need in your existing schematics is a rather small capacitor, between the signal line after the resistor and the ground if I remember the schematics correctly...

I tried a filter, didn't help. My best guess is that since the clamps are "self powered", they have trouble 'turning on' near zero crossing and output random junk.

Quote
Are you sure that the clamps aren't inducing a phase swift? Usually alteration of a magnet flux though a coil means alteration to the current through it, not the voltage... Even if it's producing a voltage, are you sure that this voltage is in phase with the current....

No phase shift that I observed. I'm reading .85 to .95 PF in my apartment, which is what I suspect it would be. So the signals must be close.

Offline TrickyNekro

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,207
  • Helpful? 15
  • 1.6L Peugeot 307 tuner
Re: Not So Tiny Power Meter
« Reply #7 on: December 20, 2010, 05:23:41 PM »
Quote
Doesn't it feel nice that you add doubt in your posts....

I did mention the clamping diodes in my blog... :-\


I was talking about me :-p  No worries....


Quote
Also, you can quite easily get the frequency, as the frequency would be the 1/t where t is the time between logic low to logic high transitions (or the opposite, or even better you can measure both and do the average in case your sine wave isn't so "healthy" and get an even more accurate reading)....

Ok, this is what I thought you meant. It's only really effective at measuring frequency. Sine PF involves comparing two separate signals with arbitrary amplitudes, it doesn't work, since the amplitude will also affect when the logic level flips. And since I had to code peak detectors for PF, I just did it for frequency as well.


Correct... But I never said to make the ADC obsolete... Of course it can't be replaced in that "job"

And about the clamps... Why don't you try a simple BJT transistor with some filtering etc etc etc.....
Since transistors are current devices you may have other results...
For whom the interrupts toll...


P.S. I've been inactive for almost a year... Don't give promises but I'll try to complete my tutorials. I'll let you know when..

Cheers!

 


Get Your Ad Here