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 Detect Exceed AC Voltage

Status
Not open for further replies.
Hello eric gibbs I like to do with built in comparator in the PIC.I'm in a such a hurry to do this with a PIC.

hi,
You could use the method described by 'mdorian' and sample the rectified, unsmoothed waveform.
[use a low voltage transformer for the ac detection circuit]

Are you able to program the PIC's adc OK.?
 
Last edited:
hi,
You could use the method described by 'mdorian' and sample the rectified, unsmoothed waveform.
[use a low voltage transformer for the ac detection circuit]

Are you able to program the PIC's adc OK.?

Thats what I had in my mind.That "mdorians" method.But I got hurt when I heard that ripple problem.

Is it ok If I sample a unsmoothed waveform?

Because for the whole project I'm using a 9V transformer.To power the V reg & to give the AD input.
 
Thats what I had in my mind.That "mdorians" method.But I got hurt when I heard that ripple problem.

Is it ok If I sample a unsmoothed waveform?

Because for the whole project I'm using a 9V transformer.To power the V reg & to give the AD input.

hi,
The transformer for the sample waveform should not be used to power other devices.
As the load of the other devices change, so will the sampled waveform.!

Calculate the maximum sampling/testing loop rate for your program and lets know that value.:)
 
I mean like this.What about that?
 

Attachments

  • Power AN0.PNG
    Power AN0.PNG
    5.2 KB · Views: 241
I mean like this.What about that?

hi Suraj,
I would not recommend using the PIC/7805 transformer for the low voltage 'ac' that you are going to sample.
Use a small say 2.5VA 4.5V/6V transformer and a low power rectifier to drive the adc input [ resistor scaling]

I have just written a quickie program for your application, using the 12F675 and its running in my simulator.
 
Hi Eric thanks for spending time on this.

So that means do I have to use two transformers?One for PIC power supply & other for AD input?

I'm still in a doubt about the hardware.How to connect the AD input & the Power for PIC.
 
Hi Eric thanks for spending time on this.

So that means do I have to use two transformers?One for PIC power supply & other for AD input?

I'm still in a doubt about the hardware.How to connect the AD input & the Power for PIC.

Let me know the details of the transformer you are using for the sampling waveform and we can work out the details.
 
My mains voltage is 230V AC/50Hz.

I need to turn on a LED when main voltage goes to 240V.

How to do that? What method should I use?

Why do you want to do this?
 
hi Suraj,
Take a look at these two attachments.
Its a simple demo program, works in the Simulator.

I have included the *.asm and *.bas [txt] [both same program]
 

Attachments

  • suraj1a.asm
    2.5 KB · Views: 149
  • suraj1a.txt
    568 bytes · Views: 159
Last edited:
Why are you using a PIC, a comparator with in-built referance will just just as much hardware, cost less and won't require any programming.
 
hi Suraj,
Take a look at these two attachments.
Its a simple demo program, works in the Simulator.

I have included the *.asm and *.bas [txt] [both same program]

Hello eric gibbs thanks for your help.

PIC has only max 5V input ADC.Can you tell what reference to use?
I think in this case reference means the output voltage to analog input.:) ex:230V -->2.5V

ref240 = 127 'choose to suit R1/R2
I think this for 2.5V am I right?

If I can scale the 230V AC to 5V ADC I can write the software.Still I'm struggling about what hardware to use.

I have again attached my earlier drawing please tell me is that the one do I have to use?

Your earlier method LM393 output polling with PIC is very nice.The problem is I need your help how to calculate the 230V AC inputs to comparator.

Help me to calculate the inputs in that method.
 

Attachments

  • Power AN0.PNG
    Power AN0.PNG
    5.2 KB · Views: 259
Last edited:
Why are you using a PIC, a comparator with in-built referance will just just as much hardware, cost less and won't require any programming.

Hi Hero999.

As earlier eric suggested a comparator LM393.The thing is I don't know how to give input to the comparator from 230V AC.

If you have idea on that method please tell.
 
Let the PIC do all the work.

Hi. All you need is a 10K to 20K pot, a resistor from 2.2K to 4.7K and one ADC input on your PIC. The idea is to use the INPUT voltage to your 5V regulator to track the mains INDIRECTLY. That is, you can establish a relationship between the mains voltage and the DC volts at your regulator. As the mains go up and down then that DC voltage follows IF your AC adapter is unregulated and you need a 5V regulator to get the 5v for the PIC. The voltage at your regulator input has already been rectified and smoothed, so just go with it. If you're using a 9V AC adapter and you have 10.1V at the regulator's input when the mains are 230V (these things hardly EVER put out 9V), then it follows that that voltage will fall when the mains go lower and go higher as the mains voltage rise. A simple voltage divider using the pot and resistor will let you set an output voltage range that will include values from 220 to 240 volts, plus probably more either way. Just poll the ADC readings constantly and track the highest readings obtained and use known ADC values to compare against and you'll do just fine.

So, some questions:
1. Do you have an ADC input available? If you don't have one, we're done here.
2. What do you measure at the mains (DMM set for AC) and the regulator's input (DC)?
3. What value of pot and resistor can you come up with?

Get back to us with these answers and we'll see if we can't figure ADC values to monitor and supply a simple schematic. I can't help with the code, someone else will have to help you with that.

Later!
kenjj
 
Hi kenjj thanks for your valuable idea.

1.Yes I have ADC input.
2.After the bridge rectifier (input to the VREG) I set DC range in DMM.(230AC,12.1DC)
3.I cant come up with it because I have to concern about ADC input impedance also :)
4.No need software I can write it. The hardware is my main problem.

This is the circuit I'm having now.What changes do I have to do?

Note that input to the VREG voltage is smoothed the earlier guy told that there is a problem with that smoother cap.
 

Attachments

  • Power AN0.PNG
    Power AN0.PNG
    5.2 KB · Views: 206
Last edited:
We are assuming that you want the main 220/240 voltage to be insulated from your board , if not, you can skip the second transformer.
Thwe ADC impedance is too high to be a concern.
The schematic can be used only with an oversized bridge and transformer. If this is a school project don't use-it. This is not a proffesional way to do a measurement.
 
Last edited:
Hi kenjj thanks for your valuable idea.

1.Yes I have ADC input.
2.After the bridge rectifier (input to the VREG) I set DC range in DMM.(230AC,10.1DC)
3.I cant come up with it because I have to concern about ADC input impedance also :)
4.No need software I can write it. The hardware is my main problem.

This is the circuit I'm having now.What changes do I have to do?

Note that input to the VREG voltage is smoothed the earlier guy told that there is a problem with that smoother cap.

Morning Suraj,
The Vref is the internal Vdd =+5V.

Go over the calculations:

You want to to measure/detect a change of 10Vac on the mains input.

The transformer has a 9Vac secondary, so thats a step down of 25:1,
so the change of volts on the secondary for a 10V change on the primary is 10V/25 = 0.4Vac.

If you rectify and smooth the 9Vac you will get approx 1.4*9 = 12.6Vdc less the diode drop, say 12Vdc.

This 12Vdc is connected via a voltage divider to the PIC's adc input, say down to 4Vdc.
Thats a further division of 3:1, so for a 0.4Vac change is now 0.4/3 = 130mVolts. [referred as an ac signal].

My concern is is that if you use the same voltage source to power the PIC and LED's etc,
everytime the load of the PIC etc is changed the voltage to the divider to the adc is going to change.

There isnt a great enough voltage margin, in my opinion.

I suppose the way to prove this, is to build and test it.
If it dosnt work reliabily, then just get second low voltage transformer/rectifier and use that as the sampled voltage.


EDIT:
Suraj, saw this link while doing another thread, as you using the 12F, I thought it would be useful, one day.
12F675 tutorial 6: Driving a servo motor using a PIC Micro.
 
Last edited:
The input Leakage current for adc input is 1uA , If you use the noninsulated schematic:
For ADC divider
Assuming that you use 0.25W resistors
P = U^2/R so R >= U^2/P = 193,6Kohm
for R divider = 220 Kohm
I divider = 220v/220Kohm = 1mA
The error from the leakage current is 1mA/1uA = 1/1000
You can use R divider = 220K , pot = 2,2K
I don't understand why to use a rectifier and a smothener , this can be done in software as Eric did.
Insulated.JPG
notinsulated.JPG
 
I don't understand why to use a rectifier and a smothener , this can be done in software as Eric did.

Hi mdorian thanks for your diagrams.Thank you very much.

The reason I use a rectifier and a smothener is because I need an extra transformer.So no place to get sample voltages in my diagram thats the only place I have.

But in your 2nd transformer can I drive directly the resister divider without using another bridge rectifier to make it DC.?

Because this formula is getting confused there.1.414 X 9V = 12.726V
Without a bridge can I use the same formula for that?
 
Last edited:
NO!!
You sample the AC voltage until you find the peak value, this wil be ACvoltage*√2

Wait for ADCin >0
Take samples and keep the highest value until adc sample = 0
Compare max value with values for 220v and 240v and set LEDs
Repeat
Your program must do somethig else to?
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top