• 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.

Zero Crossing Detector for 220V 50Hz

Status
Not open for further replies.

zahiy

New Member
Hello,

anybody can help me find a good circuit for zero crossing detector for 200V/50Hz signal? I prefer a circuit without transformer. I am going to use its output to be an input signal for PIC16f877 microcontroller. it is a light dimmer project.

I tried to google around but all I could find is an analog light dimmers!

Thanks,
 

Ubergeek63

Well-Known Member
what is your power source? if it is a generic transformer bypass the and clamp one of the output leads from the transformer to a PIC input pin
 

be80be

Well-Known Member
I tried to google around but all I could find is an analog light dimmers!
You no how a dimmer works it phase shifts. That why when you Google you got dimmers.
A dimmer fires the trac at a off set of the
Zero Crossing
pic microchip has and appnote telling all about how to make a dimmer with a pic 12f508 you hook one lag of the mains with a 20 Mohm resistor to RA 4 and the pic can read it when it zero crosses so you could use that part to read your zero crossing. I have tried it with a 18f1220 and it worked. I'll post the appnote when I find it.
 

zahiy

New Member
Thank you guys for the quick and useful respones,

Ubergeek63, if I understood you well, my power source is independed regulated +5V,


be80be, this microchips note is has been designed specifically for PIC12C508, in my case, I am using PIC16F877, I don't think it has the same feature! anyway I think I am going to continue your work and find something similar but using the 16F877 in microchips notes..
 

zahiy

New Member
By the way, I found out the the PIC16F877 has two comparator, I can compare the AC signal with 0V and find the change point, now the problem is, how can I compare 220V!! it two much voltage to handle!
 

Ubergeek63

Well-Known Member
Thank you guys for the quick and useful respones,

Ubergeek63, if I understood you well, my power source is independed regulated +5V
Then you do not have access to the actual power supply.

To sense the zero crossing you need access to the power rail and it is much safer if you do not have to actually touch it.

BTW if you just put a FET inside a bridge rectifier you can PWM a regular lamp without access to the zero crossing...
 

be80be

Well-Known Member
From the data sheet for a 16f877 all potrA
I/O pins have protection diodes to VDD and VSS.
It will read it to. The code is for 12f508 but the theory is for most any pic. The way it works is the pin reads high till the zero crossing then it will go low.And the pic can catch that.
R9 is connected to the "hot" lead of the AC power line
and to pin GP4. The ESD protection diodes of the
input structure of the GPIO allows this connection
without damage (see Figure 1). When the voltage on
the AC power line is positive, the protection diode from
the input to VDD is forward biased, and the input buffer
will see approximately VDD+0.7 volts and the software
will read the pin as high. When the voltage on the line
is negative, the protection diode from VSS to the input
pin is forward biased, and the input buffer sees
approximately VSS-0.7 volts and the software will read
the pin as low. By polling GP4 for a change in state,
the software can detect a zero crossing.
Since there is no transformer for power-line
 

be80be

Well-Known Member
RA3:RA0 AND RA5 PINS Is what the datasheet said. Just don't use ra4 like with 12f508
 
Last edited:

zahiy

New Member
Well, after lots of tests as you guys adviced me. I have connected 1M resistor on the hot main and another 1M on the Zero main as the example on the AVR PDF. it worked PERFECTLY!

with the code bellow it shows me HIGH on PORTB when the AC is positive and LOW when the AC voltage is negative:

void main() {

ADCON1 = 7;

TRISA = 255;
PORTA = 0;
TRISB = 0;
PORTB = 0;


do {

if (PORTA == 1) PORTB = 255;
if (PORTA == 0) PORTB = 0;


} while (1);
}
I can detect zero when there is a change from positive to negative or negative to positive, I also want to HIGH PORTB 1ms when the crossing is been detected this is what I did:

void main() {

int stat=0;

ADCON1 = 7;

TRISA = 255;
PORTA = 0;
TRISB = 0;
PORTB = 0;

do {

if ((PORTA == 1) && (stat == 0))
{
stat = 1;
PORTB = 255;
delay_ms(1);
PORTB = 0;
}

if (PORTA == 0)
{
stat = 0;
}


} while (1);
}

The oscilloscope gives me a wonderfull pulses marking the zero cross' result but it last for a few seconds the all what I get is zero on the oscilloscope !!!

have anybody faced this problem before?

I am using 16F877A 8MHz PORTA.0 220V

Thanks.
 

VicBSEE

New Member
MOSFET inside Bridge?

Then you do not have access to the actual power supply.

To sense the zero crossing you need access to the power rail and it is much safer if you do not have to actually touch it.

BTW if you just put a FET inside a bridge rectifier you can PWM a regular lamp without access to the zero crossing...

Could you please give more information on this? Across what two pins is the MOSFET connected inside the bridge? Interested in learning more about this

Thank you
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading

 
Top