This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

measuring 220V ac with MCU

I want to measure 220V ac with MCU.

Instead of using step down transformer, I want to use voltage divider of 1M & 3.3K.

So that 0V-220Vac gets reduced to 0V-0.724Vac.



Since it will also include negative peaks & MCU cannot measure negative values unless I put some offset to it.

So I have added 2.5Vdc offset.



Now I know that this can be done by opamp as an adder. But since I have -ve going peaks in ac voltage, so do I need to add -ve supply rail to opamp or opamp can add both volatges without using negative rails as one of voltage is going negative.?







1. Do I need negative rails?

2. What should be right opamp for this application?

3. Any reference schematic or any application node explaining measurement of 220V will be helpful

  • Aamir Ali1 said:
    I want to use voltage divider of 1M & 3.3K.

    I would change the 3.3k to two 6.8k resistors. The first is connected to ground and the second to your 2.5V ADC reference.

    This will feed the adc with 1.25V at 0 VAC. 

    Peter

  • Having mains around MCU board with just a resistor as a barrier is not very safe.
    Why do you need to measure mains?, do you just need to know if it's on?

    To DC offset a voltage-divided AC voltage you should feed it to a series capacitor that has the other side
    pull-up and pull-down as to reach a 1.25v equilibrium that is feed to the mcu a/d

    Think of the series-cap as a membrane between two water tanks, the mcu A/D tank is at 1.25meters height
    now someone is pushing and pulling on the membrane (a AC voltage) the water level will go +- compared to its resting state. If the A/C voltage is very slow when a larger membrane is needed (= higher uF) 

  • You can rectify your AC to get ½ sine’s or on the way of Peter but this gives asymmetrical result but a little modified gives you perfect data for your ADC. For safety use two 1/4–Watt sized resistors in series from your line.

  • I tried to simulate the circuit & it is giving correct results.

    1. I don't understand the function of 1M? What its purpose.

    2. This ciruit works if I give negative supply to -Vee pin of opamp. For generating negative supply I have to add another ciruit.

    Can we do it without negative supply.

  • No, the Op-Amp can be of a rail-to-rail type, you don’t need a negative supply voltage. The three resistors are acting as a divider, if the input voltage is ‘0’ then the 1M is in parallel with the lower 2M and both together in series with the upper 2M and so dividing the 5Vref, (5V/(2M+((1M*2M)/(1M+2M)))) * ((1M*2M)/(1M+2M)) = 1.25V.

  • You can try something like this:

    P.S. OpAmp is signle supply +5V

  • BTW: You don’t need an Op-Amp, you can directly feed the signal to an ADC only the ADC’s (and also for the Op-Amp) impedance must be high enough.

  • 12-bit ADC input MUX on resistance is max 2k.

  • Vents Kanders said:
    MUX on resistance is max 2k.

    Ok this is the series resistance and now the input impedance (parallel resistance).

  • Oh, yes, left out the important part - 1k with some XX pF LPF for S&H. Leakage current at VCC or VSS is pretty insignificant - 50nA. (Dont know about different voltage levels..)

  • Specs are bit changed:

    Now I have to measure 300V ac max. I took 330Vrms ac (467V peak) to be on safer. Have to remove opamp for cost reduction.
    Directly put that pin to MCU for measurement by level shifting the signal.

    1. What i had done is redice the 2M resistors to 10K each, to reduce the impedence on analog pin of MCU.
    & reduce 1M resistor to 5K (half of 10K)

    2. Divided the ac voltage by two resistors to 2.5V peak or 5V peak to peak.

    3. planning to level shift this ac signal to 2.5V. So that at MCU adc pin, signal appears as moving from 0-5V. (ac)

    4. I have attached the circuit. (zoom in to see it)

    5. But problem is circuit now is on dc bias of 1.455V dc. If we do analysis by superposition, I can find out this.


    But I want to level shift the signal so that it stays on 2.5V dc bias & also appears as low impdence source to analog pin of MCU i.e less than 10K.
    What resistor values i should choose

     

    2318.Design1 - Copy (2).pdf

  • It looks like you want to have it like this;

  • Hi I have made some circuit & did some simulation. Only place I am stuck now is selection of capacitor which would act
    as low pass filter as system will be bit noisy. (as on page 6 of attached pdf)

    I have attached my simulation results in a pdf file. (Move right clockwise the pdf once)
    Originally mu circuit will have 330V ac rms & 50Hz. But for simualion I taken 1Hz.


    1. First page: It is the actual circuit which I will be used. It will divide the 330V ac & used 5V for dc offsetting by reistor divider.

    2. Second page: I have applied superposition theorem. I have removed 5V dc source i.e ground it.
    Equivalent voltage comes out to 1.774V ac rms i.e circuit forms a voltage divider of 1850K: 10K

    3. Third page: I have applied superposition theorem. I have removed 330 ac source i.e ground it.
    Equivalent voltage comes out to 2.487 dc i.e circuit forms a voltage divider of 20K: 19.79K

    4. Fourth page: TO measurement thevenin resistance at adc pin, I have grounded all other voltage sources. & checked thevenin resistance
    comes out to be 9.946K or 10K approx.

    5. Fifth page: Shows the equivalent circuit diagram when 330V ac rms is applied.
    Divided ac signal is riding over dc voltage with thevenin resistance.

    6. Sixth page: Now since circuit will be bit noisy. so I want to place a small capacitor so that it act as low pass filter.
    So that ripple from dc source is grounded.
    But i don't know how it will react. What phase shift it will introduce?
    Will it affect the ac waveform shape?
    Don't know if its correct to place capacitor here or not?

    3718.Untitled.pdf

  • Aamir Ali1 said:
    Now since circuit will be bit noisy. so I want to place a small capacitor so that it act as low pass filter.
    So that ripple from dc source is grounded.

    When your digital (/analogue) circuit is noisy than this is the wrong way.

    When the input voltage is noisy then the low distortion frequencies can be digitally filtered out. The high distortion frequencies will be filtered out by the RC. The phase shift here is about 150uS.

     

  • Thanks Leo for your kind support.

    1. I have placed 0.1uF as I said earlier & simulated in multisim.

    I see correct results. then why you said it will be wrong.

    2. Why to place 330pF. How to calculate its value. What type of capacitor it is polyster??

    3. I am using multisim for simulation. What software are you using? 

    1. Maybe I misunderstood this but in your earlier post under 6. you mend noise from dc source, as I understood local on the board and not from ac input. This noise you can’t eliminate here.

    2. The lower the capacitor the less phase shift you have and also the capacitor will attenuate the AC input signal with an unknown value. Here I have created a more-or-less double-T-filter, the values are from experience but you can find a lot of information and calculation tools on the TI Analogue web-site. In filters it’s preferable to use ceramic capacitor due to the precise characteristics, polyester isn’t.

    3. I’m using TINA, there is a free (limited) version available also from the TI analogue web-site.

  • Aamir Ali1 said:
    Have to remove opamp for cost reduction.

    I presume that is so you have enough money left over to buy liability insurance to cover the funeral costs of the poor sap who accidentally touches this thing (and the lawsuit by family members afterward).

    Seriously. You should highly consider an isolated measurement approach.

  • Brian Boorman said:
    Seriously. You should highly consider an isolated measurement approach

    Seriously; Do you really want to say that all retro LED bulbs needs a transformer isolation?

  • >Have to remove opamp for cost reduction.

    Cost only comes in to factor when you need to manufacture 1000's
    And then you need UL, ETL or CE approval (that cost $1000's) as resellers will not carry your item without it.

    So I don't recommend you do stuff that involves 220v to resale until you have plenty of cash and years of experience.

  • Leo, in your calculation/simulation you forgot that 230V AC (and now 330V AC) means 325V peak (467V peak).
    Your proposed resistor network gives ~1.25VAC, shifted by 1.25V for 230V AC. You simulated it with 233.5VPP, which is jsut 165V AC. So the 1.85M are (much) too low. For 330VAC, 3.71M are required, for 230V, 2.58M.

  • Jens-Michael Gross said:
    Leo, in your calculation/simulation you forgot that 230V AC (and now 330V AC) means 325V peak (467V peak).
    Your proposed resistor network gives ~1.25VAC, shifted by 1.25V for 230V AC. You simulated it with 233.5VPP, which is jsut 165V AC. So the 1.85M are (much) too low. For 330VAC, 3.71M are required, for 230V, 2.58M.

    Your right, so you see I’m a completely analogue dyslectic person (when the TI analogue web-site wouldn’t be there…). But one thing I expect you would comment on was my statement about low frequency filtering, all corrected now.

  • I see you have changed the diagrams in your second post.

    And yes, I noticed the missing series resistor from the multiplexer in your schematics. But I indeed overlooked that you mentioned the filter effect. Mainly because I wrote my reply for your first post with diagrams, before you posted the second.

**Attention** This is a public forum