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.

Using PIC microcontroller to measure high voltage andcurrent

Status
Not open for further replies.

GraveYard_Killer

New Member
how do I measure high voltage like 220V as well as the current running through it using PIC? I would like to build one with 2X16LCD as its display.
 
Re: Using PIC microcontroller to measure high voltage andcur

GraveYard_Killer said:
how do I measure high voltage like 220V as well as the current running through it using PIC? I would like to build one with 2X16LCD as its display.

You simply convert any required readings to 0-5V DC (assuming you're using the 5V rail as a reference).

Reading 220V DC requires a simple resistive attenuator, if it's AC you'll need to rectify it in some way as well. To measure current you measure the voltage drop across a small resistor, you'll probably need to amplify this using an opamp. Again, for AC, you will need to rectify it.

To do both at once you will have to give it some careful thought, you need both readings to have the same 0V point.
 
And the ADC, microcontroller, and LCD need to have to same ground unless a complicated isolation scheme, probably optical, is employed.

Problem is, the only thing available to use for a ground is going to be the high voltage neutral instead of an earth ground. This isn't entirely safe to touch and shouldn't contact earth ground, but it is possible to use if everything is insulated. It will be a more major issue if you want to interface it with another device or a computer.
 
To add a degree of safety to the pic you could always look for a current transformer, and use a small, normal transformer to bring the 220V into the pic's range...
 
Exo said:
To add a degree of safety to the pic you could always look for a current transformer, and use a small, normal transformer to bring the 220V into the pic's range...

I notice we all seem to be assuming this is an AC supply?, yet this has never been stated - it 'might' be a DC supply?.
 
yeah, im gonna use 220V AC. how will i make 220V AC scaled to 5V? do i have to use voltage divider principle?
 
A small transfo seams the safest option to me... It doesn't have to drive any load, so it can be a really small one.

rectify the output, put a fairly big cap on it, and keep in mind you then have a RMS value and you're off
 
Exo said:
A small transfo seams the safest option to me... It doesn't have to drive any load, so it can be a really small one.

rectify the output, put a fairly big cap on it, and keep in mind you then have a RMS value and you're off

Actually you have a 'peak value', not an RMS one - but, as long as it's a sinewave, you can recalibrate to give an RMS value.

I think we still need to know more about what he's trying to do, so far the questions have been too vague for any thing other than general answers.

I'm 'presuming' he's wanting to measure power consumption, like an electric meter does?. If so, EPE did a project years ago using a 16C84 with an external A2D, using a hall-effect transducer to measure the current. The same sort of design could be done far easier now with the more modern PIC's.
 
Nigel, did that use an inductive clamp ?

I'd be a little nervous about telling someone to just use a voltage divider on mains potential when they dont know what they are doing...

I couldn't quickly find a link to something (clamp based) that may have worked and decided it was better to stay away.
Being new here, I wasn't sure what the protocol was when death is a possibility :)

BTW, not meaning to imply that you have given any potentialy dangerous info.
 
BartSimpson said:
Nigel, did that use an inductive clamp ?

No, it was a complete potted device, you connected one side of the mains to it, and took the output from the other side - when I'm at home I'll try and find the original article. The finished device works really well, I actually built one 8)

I'd be a little nervous about telling someone to just use a voltage divider on mains potential when they dont know what they are doing...

There was never any mention of mains until well down the thread, and that was only after asking!.

I couldn't quickly find a link to something (clamp based) that may have worked and decided it was better to stay away.
Being new here, I wasn't sure what the protocol was when death is a possibility :)

BTW, not meaning to imply that you have given any potentialy dangerous info.

Almost anything has the potential to be dangerous, a soldering iron or a craft knife? - to give two simple and common examples. This is a serious forum for people interested in electronics, we shouldn't need to 'baby' members - although I often do give serious warnings about truely dangerous devices like microwave power supplies!.

While you can measure the current with a clamp device, you can't do the same for voltage - a simple potential divider is commonly used for this purpose, and as also suggested you could use a mains transformer to lower the voltage and measure that. But, again at that time, we didn't even know it was an AC supply.
 
thanks for you all
i am working on graduation project and calculating power is a part of it .
i need to connect isolator to protect PIC from high voltage.
i have question about how to connect isolator to protect PIC from high voltage.
i used 4n26 IC but it doesn't work ...

i used a voltage divider to minimize voltage and shunt resistor to sense current
help please
 
you have to use voltage divider to minimize the peak to 5 volts or less
then use this valu to enter it the the ADC.
the values of the ADC must be stored in array eg. 50 values
divide this values by 50 you will get the RMS value of the volt
 
you have to use voltage divider to minimize the peak to 5 volts or less
then use this valu to enter it the the ADC.
the values of the ADC must be stored in array eg. 50 values
divide this values by 50 you will get the RMS value of the volt

Sorry, but that doesn't give you anything like the RMS value.
 
I use the Allegro current sensors in my projects. Easy to use, fully isolated, accurate, and can measure both AC and DC currents. Specifically this one...

**broken link removed**

Gives you 0 to 5V out based on the current. Can hook it right up to a uC without any other external circuitry.

For voltage, I use an linear opto-coupler, or just a single opto-coupler in the linear range if I don't need that great of accuracy.

I like to isolate everything. Mains scare me. :)
 
i tried this before
i used pic 16f877a and it worked.
i noticed that the ADC reads only the positive values, the negative values is considered zeros.
so you have to ignore zeros while filling your array. using simple if statement.

about the current you can use shunt resistor.
 
I use the Allegro current sensors in my projects. Easy to use, fully isolated, accurate, and can measure both AC and DC currents. Specifically this one...

**broken link removed**

Gives you 0 to 5V out based on the current. Can hook it right up to a uC without any other external circuitry.

Hello smanches..and apology to hijack this one.I am doing a similar thing here

If you have easily interfaced the ACS712 to the ADC of your MCU can you share something with me?..I am having a hard time doing this..since basically my 3.3v Vdd is a bit unstable but the 5v Vcc to the ACS712 (boosted from the 3.3v) is very good.

Please get back if you can here or my thread.

Thanks and regards
 
If you need very good accuracy, use a 5v reference IC to the AVdd pin, if you have it.

I have noticed lots of noise on PICs using the internal voltage reference. The ADC will also pick up some internal noise from the processor itself, so it's best to use some sort of averaging on the input to help eliminate that.

What specific problems are you having? Just noise from the 3.3V internal reference?

EDIT: Nvm, I'm reading the other thread now...
 
Last edited:
if the original poster is reading wattage (from current and voltage readings), wouldn't it make more sense to see how those electronic electric meters work?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top