Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

help me to sense 220vac with optocoupler...

Status
Not open for further replies.

aq_mishu

Full Member level 4
Joined
Jul 16, 2007
Messages
212
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Activity points
3,402
schematic monitoring 220vac to adc

guys,
please help me in this regard...

I want to use mega8/32/128 (any one). Programming will be done through bascom compiler. And all most all of the ADCs will be used for some other job thus no way to use those ADC. Now what i have to do is, I have to sense the live 220AC and on the presense of that, i have to drive a relay, say for the presense of 220AC, the relay will be off. Relay is a power relay driven by say 12vdc. So my planning is to use optocoupler for safety of the mcu and i need to know first the wirings and also a code snippet for the sensing say at A.0, 220 presense means optocoupler gives signal high means A.0 is getting high and it will sense it and then will set A.1 to low (and vice versa) so optocoupler at A.1 will be low and the relay will be open. Please help me...

Mishu~
 

pranam77

Advanced Member level 5
Joined
Apr 22, 2008
Messages
2,786
Helped
552
Reputation
1,102
Reaction score
371
Trophy points
1,363
Location
INDIA
Activity points
16,414
use optocoupler to monitor ac voltage

You may use MCT2E with a diode in series to the Anode and 33K 2watt resistor to the Cathode. The other side having the colletor and the emitter may be used in the way you need. Wether Hi or Low as output. Good luck
 

aq_mishu

Full Member level 4
Joined
Jul 16, 2007
Messages
212
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Activity points
3,402
220v sense

can u give me a detail with example code snippet for basccom and also a little sample schematic type thing??? please....
 

Ave_Rapina

Full Member level 2
Joined
Jan 6, 2004
Messages
122
Helped
18
Reputation
36
Reaction score
4
Trophy points
1,298
Location
Po
Activity points
683
www.all avr for output 220vac

Hello,

Do you only need to sense there is 220v or you want to quantify the intire voltage with your adc??

If you just want to sense the live main you can use one optoacupler and sense the main and the zero cross too. I use this ina a project to make an controled dimmer with microprocessor.

If you want to quantify all the 220v you can use this sensor http://web4.lem.com/hq/en/component/option,com_catalog/task,displaymodel/id,90.27.19.000.0/
but is expensive.
You can also rectify the main and sense with this http://www.linear.com/pc/productDetail.jsp?navId=H0,C1,C1154,C1009,C1077,P60190
with some little changes.
Or use an rms to dc converter.

If you specify more, we can be more objective.

Regards
 

aq_mishu

Full Member level 4
Joined
Jul 16, 2007
Messages
212
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Activity points
3,402
220v ac avr

Well, let me tell you a bit more,...
I'm planning to make a IPS (Instant power supply) (a backup power). It will be AVR based. The say mega32 will first observe the 220vac mains. meanwhile, the ADC will take reading (2 ADC in that case for differential V) for charge current. The charger is not 3 stage but 2 stage. Upto a certain Current flow, it will be one charge voltage, means one pin is high to swtich on a pot in the voltage regulator. and when that current is lower than preset point, the pin will low, truning the pot off but turning an inverter gate on so another pot on, means float charge.

meanwhile, since a pin is constantly just monitoring the 220vac presence, once 220 goes off, it will get say at PD.0 low (it was supposed to get it high). This means no 220 available and thus it will turn on the inverter (by setting one pin, e.g. PD.1 to high). Meanwhile, another set of ADC (2 adc again) will constantly monitor the output current for detecting critical load and over load and it will print them on lcd, while also it will turn off the inverter, warning bells, etc etc.

Basically that's what i need. And for the safety of the mcu, i'm planning to use opto-couplers where ever needed.

Note: In my country Bangladesh, many components are not available thus i have to use common components for allmost any where...
Mishu~
 

pranam77

Advanced Member level 5
Joined
Apr 22, 2008
Messages
2,786
Helped
552
Reputation
1,102
Reaction score
371
Trophy points
1,363
Location
INDIA
Activity points
16,414
inverter and relay

If you get AVR's you'll get MCT2E which is generally used and popular opto. Good luck
 

betwixt

Super Moderator
Staff member
Joined
Jul 4, 2009
Messages
14,710
Helped
4,807
Reputation
9,631
Reaction score
4,590
Trophy points
1,393
Location
Aberdyfi, West Wales, UK
Activity points
125,299
monitoring 220v ac schematic

This sounds like a home made explosive!

DO NOT connect the inverter output directly to your 220V output unless you fully understand the danger.

Problem 1.
If you are monitoring to see if the 220V is coming from the usual source and you are feeding in parallel with that source, your sensor will detect your own voltage as well as the incoming one.

Problem 2.
If it starts up you will be feeding the whole neighborhood.

Problem 3.
Consider what happens when the main AC is restored. If you are producing 220V AC, your peak voltage will be about 1.4 times the RMS = approximately 310V. Without the incoming power you have no phase reference to lock to so your inverter could be 180 degrees phase shifted and producing 310V in the opposite polarity. You are connecting them directly together! By all means try it but let me know so I can be a long way away!

Your should look at one of two solutions:

Convert your normal AC to a lower DC voltage and use it to charge a battery. Then use the battery to convert back up to 220V. If the charging stops because of a power blackout, the stored energy takes over. You can use the output while the incoming AC is present and the battery is float charging.

or

Use a 2-pole, 2-way relay, power the coil from the incoming 220V and use one set of contacts to switch your output from the incoming 220V to the output of your inverter. This will ensure it is impossible to link the two power sources together. Use the other contacts to enable your inverter. A relay will switch within a few milliseconds so the power glitch will hardly be noticeable. This method is safest and draws almost no power (only the relay coil) when normal 220V is present.

Brian.
 

aq_mishu

Full Member level 4
Joined
Jul 16, 2007
Messages
212
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Activity points
3,402
relays to switch 220v ac

betwixt said:
Use a 2-pole, 2-way relay, power the coil from the incoming 220V and use one set of contacts to switch your output from the incoming 220V to the output of your inverter. This will ensure it is impossible to link the two power sources together. Use the other contacts to enable your inverter. A relay will switch within a few milliseconds so the power glitch will hardly be noticeable. This method is safest and draws almost no power (only the relay coil) when normal 220V is present.

Brian.
already in that plan. the rectifier will charge the batt. and on failure of 220, the avr will sense and start working on various things... and dafinitely a 3-way switch will take over otherwise i will power the entire area... i already have the block diagram and some schematics for this job. now to make it a more better thing, i am planning it to be digitally controlled. that's all...
 

aq_mishu

Full Member level 4
Joined
Jul 16, 2007
Messages
212
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Activity points
3,402
220vac mains sensor

guys, I am planning to sense the voltage between a resistor (current) and the voltage of the battery terminal. I'm giving the code here... all i want is to view the values upto 2 decimal point. say 4.87655449 will be 4.88. can you help??

Code:
' ***************************************************************************
' *
' * Title : ADC M8.bas
' * Version : 1.0
' * Last Updated : 08.04.2006
' * Target : AT Mega8
' * Author : [url]www.avrprojects.net[/url]
' * Program code : BASCOM AVR
' * Hardware req. :
' * Description : how to use the ADC convertor, show the result on a LCD
' * display with percentage and bargraph
' ***************************************************************************
$regfile = "M8def.dat"                                      ' use the Mega8
$crystal = 10000000
$sim

Config Lcdpin = Pin , Db4 = Portd.3 , Db5 = Portd.2 , Db6 = Portd.1 , Db7 = Portd.0 , E = Portd.6 , Rs = Portd.7
Config Lcd = 20 * 4
Config Adc = Single , Prescaler = Auto , Reference = Avcc   'config ADC
Start Adc
Dim Ih As Word , Il As Word , Vi As Word
Dim Ihigh As Single , Ilow As Single , Iin As Single , P As Single , Vin As Single

Cls
Config Portb = Output

 Portb.0 = 1
 Portb.1 = 0

Do
 Ih = Getadc(0)
 Il = Getadc(1)
 Vi = Getadc(2)

 Ihigh = Ih * 4.8875855
 Ihigh = Ihigh / 100
 Ihigh = Ihigh * 4
 Ilow = Il * 4.8875855
 Ilow = Ilow / 100
 Ilow = Ilow * 4
 Vin = Vi * 4.8875855
 Vin = Vin / 1000
 Vin = Vin * 4
 Iin = Ihigh - Ilow


 If Ihigh => Ilow Then

  If Iin > .5 Then
   Portb.0 = 1
   Portb.1 = 0

   P = 14.6 * Iin

   Cls
   Locate 1 , 1
   Lcd "Boost Charge"
   Locate 2 , 1
   Lcd "Power: " ; Round(p) ; "W"
   Locate 3 , 1
   Lcd "Current: " ; Iin ; "A"
   Locate 4 , 1
   Lcd "Batt Term V: " ; Vin ; "V"

  Elseif Iin =< .5 Then
   Portb.0 = 0
   Portb.1 = 1

   P = 13.8 * Iin
   Cls
   Locate 1 , 1
   Lcd "Float Charge"
   Locate 2 , 1
   Lcd "Power: " ; Round(p) ; "W"
   Locate 3 , 1
   Lcd "Current: " ; Iin ; "A"
   Locate 4 , 1
   Lcd "Batt Term V: " ; Vin ; "V"

  End If
 Else
  Cls
  Locate 1 , 1
  Lcd "Error!! Code 0x2F"
  Waitms 3000
 End If
 Waitms 100
Loop
End
 

aq_mishu

Full Member level 4
Joined
Jul 16, 2007
Messages
212
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Activity points
3,402
using optocoupler open relay

guys, finally i have finished the part of charger...

thanks you all a lot....

i'll update on the final project...
 

basrikul

Newbie level 1
Joined
Jul 25, 2009
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
TURKEY
Activity points
1,286
Re: schematic monitoring 220vac to adc

Hi;
many opto couplers not lineer. You cannot measure AC voltage with standart opto like 4N25, 6N36...etc. You can use lineer opto+full bridge+small cap. Lineer opto contain one led and one opto diode not opto transistor.
I am using IL300 to measure AC voltage in range 100-250VAC with %1 resulation.

Basri KUL
 

master_bsu

Newbie level 1
Joined
Apr 23, 2011
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,285
please help me in this ...
I want to control output voltage regulator inverter it using microcontroller,so i need code to do PWM , can u give me a detail with example code and schematic ?please..
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top