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.

How to measure AC Voltage using pic16f877a

Status
Not open for further replies.

koolguy

Active Member
Hello Guys,
What is the procedure of measuring AC and its freq for display in LED?
one thing more if i have a sample how to start production of it??
 
For safety if nothing else I would use a small transformer to take it down to low AC volts. Rectify and smooth and feed the DC through a voltage divider into the ADC. Upscale the readings via software for your actual mains voltage.
 
When using the suggested low-voltage transformer, use the linked "precision rectifier circuit" between the transformer and PIC input.
 
You can tell by the lights if the supply voltage drops and the frequency will not shift by more than one cycle PER DAY !!!!!
 
You can tell by the lights if the supply voltage drops and the frequency will not shift by more than one cycle PER DAY !!!!!
What this mean praticaly?
one cycle per day is there any problem.
 
What aspect of the AC voltage do you want to measure?
Peak?
Average?
RMS?

The required circuit for each is different, and progressively more complicated.

The accuracy of any measurement system is only as good as the reference voltage against which the measured value is compared.
 
Last edited:
:confused: I don't see the point in measuring mains frequency. As Colin says, it's accurate to within 1 cycle per day, so it's 50Hz or 60Hz depending where you live. Besides, there's nothing you can (legally) do to alter it :).
 
The mains frequency varies considerably, but the long-term average is kept extremely close to the nominal. The frequency tends to be slower during the day and faster at night. Depending on what you want the accuracy for, it may not be safe to assume that the mains is very accurate.

For measuring the mains voltage and frequency, I would also recommend a transformer. However, a peak detection circuit will loose a lot of information, and it is quite easy to measure a 50 Hz waveform many times per cycle, and use that to calculate the frequency and RMS or peak voltage.

The ADC on a PIC measures between the negative and positive reference voltages, usually 0 and 5 V. This needs to be well regulated as the reading depends on the reference voltage just as much as the input voltage.

Assuming that one side of the transformer is a 0 V, you need a potential divider with 3 resistors.
First from the transformer to the ADC input.
Second from the ADC input to ground
Third from the ADC input to 5 V.

You can scale the resistors to give you 0 V at the ADC input at the negative peak voltage, say -350 V, and 5 V at the ADC input at the positive peak voltage, say +350 V. Obviously you factor in the ratio of the transformer.

As long as you sample reasonably often, say 1000 times a second, you can measure the waveform quite well.

When measuring frequency, always add hysteresis. You should take the rising edge when the voltage exceeds 50 V, and the falling edge when it goes below -50 V or similar, so that you don't double count a waveform if there is a single noisy reading.

I did something very similar to this on a 3-phase application, where all three phases were being sampled. The frequency was being read in order to compensate for the increased frequency of the mains on a machine that needed great accuracy over periods of hours not days, and it only ran at night.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top