Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Energy meter design

Status
Not open for further replies.

desperadogear

New Member
hello folks,

im planning to build an energy meter for 230V, 2A and around 5% accuracy using an 8bit AVR microcontroller. My inspiration is AVR465 application note .. https://www.electro-tech-online.com/custompdfs/2007/02/doc2566.pdf


The first challenge that i faced is whether to use a tranformerless powersupply or not..

In the application note mentioned above, a transformerless power supply was used (see power supply.png attachement) where this was the description given "The power supply is based on halfway rectification. During negative half-wavescapacitor C1 is charged and during positive half-waves the capacitor is drained.Zener diode D1 (minus the forward voltage of diode D2) dictates to which voltage C2 is charged. Voltage regulator U1 uses the energy stored in C2 to produce a stable output voltage. Resistor R1 controls the charge and discharge of C1 and also limits the current flow through zener diode D1."

where C1 is 0.68uF Metallised Polyester Capacitor, R1 is 470ohms , D2 1N4004 is Diode, 1A, 400V, D1 is Zener Diode , 500mW, 15V .
C2 is 470 uF electrolytic capacitor, U1 is Linear Regulator, 3.3V.
I wish to replace U1 with 7805 regulator to get 5V output.

I trust Atmel people very much but wished to hear from Senior members of electro-tech-online. please see this and review the circuit( is it safe, would it have any side effects ?)

The second challenge is the current front end. I have a 10:1 current transformer and the one that was specified in the application note was 2500:1 far different from the one i have... So i have decided to use a series resistor 0.1 ohms between line,load and neutral and measure the voltage across the resistor(refer to current.png in attachments) by giving it to microcontroller's inbuilt analog to digital converter through an amplifier built using lm358 with gain just enough to bring it in the range of the in built voltage reference 2.56V in the microcontroller.

for example max current =2A rms
voltage across resistor=2A * 0.1 ohms = 200 mV rms

after an opamp amplifier with gain 4. voltage is 200 mV *4= 800 mV rms=2 *square root(2) *.8 peak to peak approx 2.56 V

I was wondering if this would be a safe way to measure current

suggestions and advice greatly appreciated...
 

Attachments

  • design.JPG
    design.JPG
    67 KB · Views: 1,345
  • powersupply.PNG
    powersupply.PNG
    14.1 KB · Views: 2,033
This isn't for charging people is it?

If our electricity meter was as simple as that I would just connect all the loads from the live to earth and it wouldn't register.:) I suppose you could get round this by measuring the live but it's not as safe as the neutral.

Does your meter just take the peak voltage then work out the RMS by multiplying it by root2?

This is fine for linear loads that draw a sinusoidal waveform but it won't work with circuits that draw funny waveforms like lamp dimmers and small DC power supplies or any piece of electrical equipment containing a small DC power supply.
 
Without looking in any great depth, ( which means I've missed a lot) , I have a couple of points to make. Firstly, resistors have a voltage rating, the standard half-watt ones being 250 volts peak. If you exceed this, they tend to go all nasty and non-linear. Use two or three lower value ones in series for the high voltage bits. The capacitors, at 47uf, look well large enough to cause no trouble, but beware of phase shifts if you use lower values.
If you sample voltage and current close together and multiply, then take the average of a lot of multiplied samples over a full cycle of mains, you wil deal with all the bad waveshape and power factor problems without involving difficult math like square roots.
 
spuffock said:
If you sample voltage and current close together and multiply, then take the average of a lot of multiplied samples over a full cycle of mains, you wil deal with all the bad waveshape and power factor problems without involving difficult math like square roots.
Excellent idea but if you want to do that you need to remove the low pass filter and add a full wave precision rectifier to the input. The sample rate should also be at least double the highest harmonic you want to sample. I would probably recomend sampling up to the 50th harmonic so your sample rate would need to be 50×50×2 = 5kHz assuming a 50Hz supply.
 
You have an ordinary old LM358 dual opamp. The circuit is supposed to have an LMV358 new one which has a rail-to-rail output voltage swing. You have its input incorrectly biased.
 
Thanks to everyone for patiently helping me.

hero999 said:
Does your meter just take the peak voltage then work out the RMS by multiplying it by root2?

Im building an energy meter(*prototype*) that measures and displays current, voltage, power, energy seperately on a seven segment display.

For measuring the active power im going to take the average of product of voltage and current samples over a full cycle .

For measuring current/voltage separately i would take the average of squares of instantaneous samples and square root it as Mr.spuffock said.


Hero999 said:
Excellent idea but if you want to do that you need to remove the low pass filter and add a full wave precision rectifier to the input.The sample rate should also be at least double the highest harmonic you want to sample. I would probably recomend sampling up to the 50th harmonic so your sample rate would need to be 50×50×2 = 5kHz assuming a 50Hz supply.

why should i do this . cant i calculate rms value for the un-rectified signal.??
The sampling frequency is dictatated by the microcontroller that im using (AVR ATMEGA8) I can make it maximum 153kHz
for 4 MHz crystal, so no problem..


thank you @audio guru. Im gonna replace lm358 with lmv358

I was wondering what this calibration was. I just know it as the process of setting the tobe measured values of an instrument. AVR465 application note was talking about calibration of energy meter using EEPROm. What is this digital calibration? Would i need this??
 
desperadogear said:
The sampling frequency is dictatated by the microcontroller that im using (AVR ATMEGA8) I can make it maximum 153kHz
That's more than high enough, I wouldn't think there's any point in going any higher than 5kHz anyway, this isn't high quality audio, it's mains frequency power.

desperadogear said:
cant i calculate rms value for the un-rectified signal.??
Of course you can but can the ADC on the PIC measure negitive voltages?

A fullwave presicion rectifier is probably the easiest way of getting round this.

**broken link removed**
**broken link removed**
The above circuit also has the advantage of having gain so you can set it to what you like. You could also save parts by using a quad opamp like the TL082 to build two precision rectifiers (one for the voltage and one for the current).

You'll also need a bipolar power supply but that's easy.
 

Attachments

  • Xformerless bipol PSU.GIF
    Xformerless bipol PSU.GIF
    3.4 KB · Views: 18,131
Last edited:
The TL084 is a quad opamp. The TL082 is a dual. The TL081 ia a single.
 
very impressive circuit Mr.@Hero999..I was planning to DC bias the signal to exactly (Vref/2) where Vref is the reference voltage available in the microcontroller, so that zero value would come exactly midway to the ADC value and the positive extreme would be ADC register full and negative extreme would be ADC register zero.

Il give a try to the above mentioned circuit as it would make my job of getting back the voltage from ADC register simpler.
 
Hero999,
i have redesigned the circuit as you suggested (see circuit2.jpg)
The problem with that circuit is that the component names are not clear in the picture can you help me with that. And can i use IC741 as opamp or any better suggestions. I'd need a gain of 8 such that for 2 A current
the voltage across the 0.1 ohm resistor R2 is 200mV rms (200*1.414 mV Vp) and the output of the opamp would be (200*1.414 *gain mV Vp)=(200*1.414*8)mV Vp= 2.26V which would fall under the reference voltage of the microcontroller Vref=2.56V


. Have also modified my previous design(see circuit1.jpg) where i didnt use dual power supply and used lmv358 but DC biased to adjust the signal to fit between 0 to Vref.

which one is better?? any suggestions?
currently im testing them both ..

ps:
I guess i figured out this auto-digital-calibration thing. Its the ability of the instrument to automatically measure the range of input and adjust the gain and to correct errors such that accuracy is better...
 

Attachments

  • circuit1.JPG
    circuit1.JPG
    107.1 KB · Views: 847
  • circuit2.JPG
    circuit2.JPG
    122 KB · Views: 925
I se there are various opinions on this . No low pas filters are to be used, unles you are also using input rectifiers. If using rectifiers you are restricted to pure resistive loads, anything with a reactive component wil give ridiculous erors. The inputs should be biased to half the range of the adc. A god way to calibrate is to set up with a resistive load and a couple of multimeters, and bung a fat paper capacitor acros the load. As long as the curent is stil within range of the adc, there should be no change in the power reading.
Excuse the speling, I am fed up with corecting this keyboard which wil not type double leters. Filterkeys is OF.
 
You can't use an old 741 opamp because it needs at least plus 5V and minus 5V to power it, its inputs don't work when they are anywhere near the positive or negative supply voltage and the output doesn't swing very far.

When biased properly, the LMV358 works fine from a single 5V supply, its inputs work down to 0V and its output swings the full supply voltage (rail-to-rail).
 
desperadogear said:
The problem with that circuit is that the component names are not clear in the picture can you help me with that. And can i use IC741 as opamp or any better suggestions.
It doesn't matter, it's low frequency so use the LM741, TL084, LM324 etc. Do watch the current consumption though if you're using a transformerless power supply as it can't provide more than about 15mA depending on the size of the capacitor.

If you can't read the resistor component labels then just remmeber it's simple an inverting and non-inverting amplifier connected together with diodes in their outputs, the formula for the gain is identical to the formua for an inverting and non-inverting amp.

audioguru said:
The TL084 is a quad opamp. The TL082 is a dual. The TL081 ia a single.
I knew that, the last number denotes the number of op-amps in the chip.

audioguru said:
You can't use an old 741 opamp because it needs at least plus 5V and minus 5V to power it
Can't he just use a higher power supply voltage then?

Swap the 5.1V zenners for 12V zenners, assuming the PIC can take 12V, if not use a separate 5V regulator for the PIC.
 
It gets complicated if you use an old 741 opamp to feed the 5V max input to a pic. With a 5V supply, the output high voltage of the 741 will be very low. With a 12V supply it is much too high.

The Cmos inputs of a PIC have protection diodes that can protect the input from a signal voltage that is too high if you use a series resistor to limit the current.
 
:-? im confused now... i tried to get myself lmv358 but its out of stock here and unavailable. Shall i go ahead with IC741 and a seperate 12 supply. Micro controller can take till 5V only...

If you can't read the resistor component labels then just remmeber it's simple an inverting and non-inverting amplifier connected together with diodes in their outputs, the formula for the gain is identical to the formula for an inverting and non-inverting amp.
thanks for that.
and i better change to a transformer powersupply to avoid current consumption prob..
 
Last edited:
Coming back late, since an email has just notified me that this thread was updated last month, I am dismayed to find that we have collectively done it again. We should by now have a neat little unit, accurate to better than half a percent, logging KWh or KVAh, running from a little lithium cell for better than a year and being none the worse for power cuts, and what do I find?
I find the poor bugger who wanted to build it running around the museums trying to find obsolete components to build something that works with a waveform only seen in laboratories, and wondering about starting another thread about the cross section of the copper busbars used to bring its power in. Maybe even heatsinks.He was better off when the thread started.
I should take up knitting.
 
back in action

i was doing this energy meter project without any purpose and just as a hobby and to learn more things. so had to keep this aside for few weeks . I got back to it now.

hero999,
I have tried to construct a tranformerless dps based on your suggestion. Please refer to your post in the above mentioned thread. I have observed that 1M ohm was giving an output of 3.6V, -3.6V
500kohm 3.9v,-3.9v
250kohm 4.2v,-4.2v
100kohm 4.79V,-4.79V


so finally i decided to go with 100kohm , but when i connected this supply to TL084 the voltage across the rails dropped to 2.5V. Again when i disconnect the supply from tl084 it shows 9.54V(4.8v-(-4.8v))

can you please tell me how could i modify this to use the dual power supply design that you suggested..

your circuit seems to work fine when used with lm358 or anything else but not tl084 . i wonder why.. what could have not favoured for tl084.

thanks in advance
 
desperadogear said:
your circuit seems to work fine when used with lm358 or anything else but not tl084 . i wonder why.. what could have not favoured for tl084.

Thje LM358 has low power opamps. The LM324 is its quad version.
Look at the supply current for the different opamps on their datasheets:
LM358= 0.5mA to 1.2mA for each opamp. Four is 2.0ma to 4.8mA.
TL084= 1.4mA to 2.5mA for each opamp. Four is 5.6mA to 10mA.
 
desperadogear said:
so finally i decided to go with 100kohm , but when i connected this supply to TL084 the voltage across the rails dropped to 2.5V. Again when i disconnect the supply from tl084 it shows 9.54V(4.8v-(-4.8v))
You are changing the wrong component value, to get more current you need to increase the value of the 470nF capacitor. The 1M resistor is just a bleeder resistor that discharges the capacitor when the power is disconnected.

Also don't use any more op-amps than you really need, don't use a quad if you only need two opamps and if you need three use a dual and a single op-amp.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top