Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

220 AC input to microcontroller

Status
Not open for further replies.

qpasatio

Newbie level 5
Joined
Nov 8, 2003
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
97
hello
Does anyone know a good and cheap solution to sense the 220V AC from a pic microcontroller?
An Optocoupler would be a good solution, but it is very expensive. I´ve read a appnote from microchip and they sense the line direct with a 20M resistance. Do you think is a good idea?
Thanks
 

flatulent

Advanced Member level 5
Joined
Jul 19, 2002
Messages
4,629
Helped
489
Reputation
980
Reaction score
150
Trophy points
1,343
Location
Middle Earth
Activity points
46,689
You need to comply with safety regulations. I would use a transformer or the opto isolator method. Avoid all direct connections to the mains. You also have to guard against lightning strikes to the mains conductors getting into your circuit.
 

davorin

Advanced Member level 3
Joined
Jun 7, 2003
Messages
901
Helped
11
Reputation
22
Reaction score
4
Trophy points
1,298
Location
Switzerland
Activity points
7,349
How do you power your PIC? Directly from AC line or through powersupply with transformer?

If it´s direct AC line then you can go with a 10/20M resistor and add external protection diodes to VCC/GND to input pin. There must be some app-notes for dimmer applications here at edaboard...

If your powering from transfor supply why don´t you feed AC signal from there?

If none of them is true then go with optocoupler...and please #define EXPENSIVE (o; When it comes to safety nothing is expensive...
 

Moof

Full Member level 2
Joined
Nov 21, 2003
Messages
149
Helped
7
Reputation
14
Reaction score
1
Trophy points
1,298
Location
Argentina
Activity points
1,230
I build an controller with a 12f675. In my aplication i use 40M to the zero cross detectorf of the 220v (Argentina). It is safe cos Pic has two diode to protect the input, so Voltage never is going to be grater than 5V a less than 0V (-0.7). The 40M resistor prevents thath this diodes melt down. :D

Apart from that im not using transformer. I use two capacitors, two diodes, a zenner and a resistor.

To avoid the hight voltages i use a varistor at 450 volts peak.
 

cozturk

Advanced Member level 4
Joined
Apr 2, 2002
Messages
105
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Activity points
904
Trust me: this is only 3Mohm resistor to pic input. No 20Meg. and no diodes neded. because they are built in PIC.
I used this method to zero sensing in phase control circuit. (thermal regulated heater project)
 

qpasatio

Newbie level 5
Joined
Nov 8, 2003
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
97
Thank you for your replies
But.... I need 1 or 0. The resistante is a good method if you activate an interrupt to detect the zero cross. In order to detect Fase oder Neutral, I think that it is necessary to add diodes... condensators... and so on.
 

davorin

Advanced Member level 3
Joined
Jun 7, 2003
Messages
901
Helped
11
Reputation
22
Reaction score
4
Trophy points
1,298
Location
Switzerland
Activity points
7,349
What you mean by "detect phase or neutral" ????

Do you wanna detect only polarity?
It already does it (o;
 

qpasatio

Newbie level 5
Joined
Nov 8, 2003
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
97
Sorry, Possibly I didn't use the correct terms. I feed a sensor with 220vac (relay inside). The relay returns 220 oder N.
 

davorin

Advanced Member level 3
Joined
Jun 7, 2003
Messages
901
Helped
11
Reputation
22
Reaction score
4
Trophy points
1,298
Location
Switzerland
Activity points
7,349
Sorry...now I don´t really see what you want to achieve with this (o;

Always output same polarity regardless of input?
 

qpasatio

Newbie level 5
Joined
Nov 8, 2003
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
97
Sorry, Possibly I didn't use the correct terms. I feed a sensor with 220vac (relay inside). The relay returns 220 oder N.
 

qpasatio

Newbie level 5
Joined
Nov 8, 2003
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
97
Usually engineers make difficult the most easy thing. :)
It´s very easy. I have a presence sensor with 3 terminals. These terminals are the tree connections of relay.
I use this connection:
NC (normally closed) -> N
NO (normally open) -> F
C (common) - > to the microcontroller Input (signal)
If the sensor detects presence, the signal is 220, otherwise, N.
I don´t know if my english is precise, if you don´t understand me I can send you one scheme.
 

davorin

Advanced Member level 3
Joined
Jun 7, 2003
Messages
901
Helped
11
Reputation
22
Reaction score
4
Trophy points
1,298
Location
Switzerland
Activity points
7,349
Let´s say your english is "understandable" and a schematic would have been much better from the beginning (o;

qpasatio said:
It´s very easy. I have a presence sensor with 3 terminals. These terminals are the tree connections of relay.
I use this connection:
NC (normally closed) -> N
NO (normally open) -> F
C (common) - > to the microcontroller Input (signal)

I think you mean with "F" phase?

If the sensor detects presence, the signal is 220, otherwise, N.
I don´t know if my english is precise, if you don´t understand me I can send you one scheme.

Now you´re talking more strange...what "presence"? What "sensor"?

The sensor should switch the relay between "N" and "P" when 220V is present and feed it to the PIC?


Please draw a block diagram (o;
 

cozturk

Advanced Member level 4
Joined
Apr 2, 2002
Messages
105
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Activity points
904
qpasatio said:
Thank you for your replies
But.... I need 1 or 0. The resistante is a good method if you activate an interrupt to detect the zero cross. In order to detect Fase oder Neutral, I think that it is necessary to add diodes... condensators... and so on.

for pbp. to sync. to mains:

if pin= 1 then
while pin=1: wend
else
while pin=0: wend
endif
...
pause 1ms
trig. triac etc
 

qpasatio

Newbie level 5
Joined
Nov 8, 2003
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
97
Let´s try it now.
The opto is very expensive and I had some problems, maybe a good selected capacitor with the 680K resistance could improve the circuit.
thanks
 

cngroup

Newbie level 3
Joined
Mar 30, 2004
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
36
I'm also curious about this too. How about coupling with some capacitance?
 

Fragrance

Advanced Member level 4
Joined
Jul 26, 2002
Messages
1,191
Helped
248
Reputation
496
Reaction score
200
Trophy points
1,343
Location
East Of Earth
Activity points
8,917
qpasatio said:
Let´s try it now.
The opto is very expensive and I had some problems, maybe a good selected capacitor with the 680K resistance could improve the circuit.
thanks

insteed of simple opto why not you used MOC3020 or MOC3040 the 3040
come with built in zero cross and suitable for interfacing and controlling 220vac direct from Uc i have built temp controller by using moc 3040

if you need more help i will guide you more
 

tryagain

Newbie level 1
Joined
Jun 14, 2002
Messages
0
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,282
Activity points
797
ref some cheap battery charger circuit
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top