# How to Detect Exceed AC Voltage

Discussion in 'Microcontrollers' started by Suraj143, Oct 28, 2008.

1. ### kjennejohnNew Member

Joined:
Mar 19, 2006
Messages:
338
Likes:
8
Location:
Bay Area, California
You're welcome. Actually, it has to rise or fall TEN Volts from 230V to trigger. Then it has to get back to within FIVE Volts of 230V in order to turn the relay back on.
I hope this project works to your satisfaction into the future.

kenjj

Last edited: Nov 3, 2008
2. ### Suraj143Active Member

Joined:
Jan 11, 2007
Messages:
1,607
Likes:
2
Location:
South Mald Isld
Hi after adding hysteresis to the software the outputs works fine.

Now the only problem is the sense voltage (reference) changes.It's changing with a noticeable gap.

As per earlier calculations
230V ref = 2.5V
240V ref = 2.61

But some times its exceeding 2.61V when the AC is 230V.So the relay is getting off even in 230V.

I think must go for a 2nd transformer

Can you tell me for a 230VAC/6V transformer what are the values for resistor divider?

Last edited: Nov 3, 2008
3. ### Hero999Banned

Joined:
Apr 6, 2006
Messages:
14,902
Likes:
79
Location:
England
I still don't know why you want to do this, the voltage tollerance in most 230V countries is +10%-/6% so voltages as high at 253V are perfectly normal and shouldn't do any harm providing the project it designed properly.

Joined:
Jan 12, 1997
Messages:
-
Likes:
0

5. ### mdorianMember

Joined:
Oct 17, 2008
Messages:
64
Likes:
0
Location:
Romania

For Transformer 220Vac/6Vac + bridge +filter :

If old_Rdiv =8,2 and old_Pot = 5K then use Rdiv~3,5K , Pot = 5K

If using AC and the code written by Eric then multiply the values with 10 :
Rdiv~35K . Pot~50K

6. ### Suraj143Active Member

Joined:
Jan 11, 2007
Messages:
1,607
Likes:
2
Location:
South Mald Isld
Hi mdorian

I also add a 2nd transformer thing.But still I'm not satisfy its voltage behavior.

I have attached two diagrams.1st one isolated & 2nd is non isolated.

What are the modifications to do to get a smooth DC AD input?

Its ok if it is non isolated I need a good reference detect circuit.

Also note I'm sampling DC not AC.I need a DC input for AD input.(Because I'm not continuously sampling AD & finding the peak,I just sampling AD & checking if its greater or less than the reference so I need a DC input for AD)

#### Attached Files:

File size:
4.5 KB
Views:
203
• ###### NonIsolated.PNG
File size:
4.8 KB
Views:
184
Last edited: Nov 4, 2008
7. ### mdorianMember

Joined:
Oct 17, 2008
Messages:
64
Likes:
0
Location:
Romania
The second schematic isn't good , you will have to many errors because the bridge works at low voltage , use something like that instead:

To approximate the error given by the smoothener use this formula
ΔV ~= V*0,006/(R*C)
Where R is Rdiv+Pot,
V can be ADC-in, or the AC voltage
For example :
ΔV = 2volts (AC )
V = 220volts ( AC- same as ΔV)
R = Rdiv+Pot = 14,2K
Then C = V*0,006/(R*ΔV) = 46uF
ΔV>2volts ==> C>46uf

Check the VDD for PIC if it's stable enough , otherwise it will alter the internal reference.

8. ### Suraj143Active Member

Joined:
Jan 11, 2007
Messages:
1,607
Likes:
2
Location:
South Mald Isld
Hi mdorian thanks for your new diagram thats the one I was looking for.

I understood your formula.That means to maintain 2volts AC the smoothener must below 47uF.If smoothener > 47uF then the error will be more than 2volts AC.

Is that formula only for AC?

One more thing!

R is Rdiv+Pot that means 220K + 2.2K = 222.2K isn't it?

Last edited: Nov 5, 2008
9. ### mdorianMember

Joined:
Oct 17, 2008
Messages:
64
Likes:
0
Location:
Romania
No , if C > 47uF then the error ΔV is proportional less then 2V. The formula can applied to DC to. Is not a very accurate formula because i approximated the discharge of the capacitor as being linear which is not , ΔV can 3 or 4 times higher, just put a capacitor large enough for the worst case. The bad side of putting a too large capacitor is that when the AC voltage drops from 240 to 220 the the smoothed voltage does not drops as fast as the AC voltage , this means you will have on the ADC-in a delay proportional with the capacitor.
As I told before, another source of errors is the voltage dropping on the bridge , witch falls with 2mV for each celsius degree. This is significant only for low AC voltage.
And again , don't rely on the 7805 that will give the same voltage at any time , use a digital voltmeter to check with and without loads ( like LED relay , etc). The AD conversion is relative to Vdd , so will give different results for Vdd = 5 volts as for Vdd = 5,1 volts.

10. ### sahuMember

Joined:
Oct 18, 2009
Messages:
468
Likes:
3
now digital time. So pl advise liner .....

11. ### zeroskj1988New Member

Joined:
Jul 6, 2011
Messages:
6
Likes:
0
hello mdorian, i have problem in simular situation. can u help me?. i have measure 230v,50hz ac.i rectified ac with bridge,then use potential divider to dive to below 5v,(without using filter capacitor)then given to the 10bit adc pin of pic16f877a.i take sample on each 1ms(since for 50hz, period is 20ms,using timer 1) add then,average on 10 sample, multiply by form factor(1.1) then display.my problem is display value change between 208-230. i don't think it is because of supply variation

12. ### Gayan SoyzaActive Member

Joined:
Oct 23, 2006
Messages:
1,822
Likes:
19
Location:
Colombo
There is another way.Detect zero cross (waste another external interrupt pin).When ZX occurs turn on a timer for 5mS.At each mid of semi period you get the peak value.@ 5mS time sample AD & calculate RMS & show on display.

If still display varies then you need to over sample & make the average.

Last edited: Jul 6, 2011
13. ### mdorianMember

Joined:
Oct 17, 2008
Messages:
64
Likes:
0
Location:
Romania
The problem is that the samples are not synchronized with zero crossing, let's say you take a sample of 10V before zero crossing and one of 10v after the zero crossing , gives you an average voltage of 10v which obviously is not true. Worse, the samples position is changing in time relative to zero crossing and so your result . If your project requires this solution ( taking 10 samples/ semiperiod) then wait for zero crossing or use an interrupt to detect the zero crossing, start timer interrupts, take 9 samples ( because the first one is zero) stop timer interrupt and wait for zero crossing again. I wouldn't recommend taking only one sample per semiperiod like Soyza says because it's fitted only for perfect sinusoidal voltage, some loads widely used like SMPS are cutting the peak voltage modifying the result.

14. ### zeroskj1988New Member

Joined:
Jul 6, 2011
Messages:
6
Likes:
0
thanks for reply. i agree u said correct reason for drift. but i am using full wave rectifier, my freq is 50 hz, means 20ms period. since using fullwave rectification both negative and positive half cycles are same.so have to take only one. so take 1 sample for every 1ms .so 10*1ms=10ms(half period).then take average for ten. i beleive that i am taking consecutive 10 sample with 1ms interval. i don't have to worry about the zero crossing. sorrry for any mistakes

15. ### mdorianMember

Joined:
Oct 17, 2008
Messages:
64
Likes:
0
Location:
Romania
Hi , look at this pictures , the red points are the sampling points , I took only four samples per semiperiod but it applies to ten samples to. Using the samples in the second picture you will obtain a highest average than by using the samples in the first picture with the same signal. That's why you need sincronisation, of course in the rectified voltage there is no "zero cross" it's about the sincronisation with the zeroes in voltage.

#### Attached Files:

File size:
21.5 KB
Views:
87
• ###### Sample2.JPG
File size:
21.7 KB
Views:
84
Last edited: Jul 7, 2011
16. ### zeroskj1988New Member

Joined:
Jul 6, 2011
Messages:
6
Likes:
0
thanks for reply.but i am taking even number of samples at regular intervel like on this picture. average of 1,2,3,4 is equal to 3,4,5,6 .that is reason why i chose, not to care about zero crossing . sorry for any mistakes. keep replying

17. ### mdorianMember

Joined:
Oct 17, 2008
Messages:
64
Likes:
0
Location:
Romania
Do you use quadratic mean for average?

18. ### zeroskj1988New Member

Joined:
Jul 6, 2011
Messages:
6
Likes:
0
go for it,if problem persist

19. ### mdorianMember

Joined:
Oct 17, 2008
Messages:
64
Likes:
0
Location:
Romania
If you use aritmetic mean U = correction factor * (s1+s2+s3+s4)/4 then certainly your trouble comes from the position of sampling points. If you were sincronized with the zero you would have at least a proportional result with the average voltage.
If you're using quadratic mean U = Umax*√((s1^2+s2^2+s3^2+s4^2)/4), I think it doesn't matter the offset of the samples , for my example the the quadratic mean is the same in both examples U = Umax/√2 = 0.707Umax ,but the aritmetic mean is 0.603Umax and 0.653Umax for the first and the second picture. I hope you have enough resources to perform a quadratic mean in the interrupt.

Last edited: Jul 7, 2011