Atmega32 AVR controling high voltage ?

Thread Starter

Mathematics!

Joined Jul 21, 2008
1,036
My other avr question is I have a Passive Infrared Motion sensor that I connected to a pin on my avr. When something changes with in 20 or 30 ft of the sensor the avr chip turns on a small led on another pin.

What I want to do now is move away from using a small led and beable to turn on a house light. (120 volts high 15 amp circuit rating ..etc)

I know I can put a very strong 400volt 20 amp diode so that know current can enter the chip from the house circuit but I want to know what I can put after the diode to act as a switch. All the transistor's I see are rated at 60 volts or 70 volts. I am wondering if their is a simple electronic component I can pick up at radioshack so that I can send a small voltage/current from the chip to turn on/off a high voltage house circuit light.
 

hgmjr

Joined Jan 28, 2005
9,027
I assume you can get to the line that is activated by the PIR detecting movement.

You can feed that through a transistor perhaps and then into the AVR. Then you can use the AVR to activate a relay through another transistor.

hgmjr
 

mik3

Joined Feb 4, 2008
4,843
You can't control AC currents with a transistor, you need a TRIAC.

The best solution to control house lights is to control a relay with the uC and control the lights with the relay. Note, that you need to drive the relay with a transistor because a uC is not able to power it directly. Remember the protecting diode across the relays' coil.

The use of a relay is better than a TRIAC because it offers you isolation from the mains voltage.
 

Thread Starter

Mathematics!

Joined Jul 21, 2008
1,036
So far all I have is the PIR sensor plugged into a pin on the AVR the input pin listens for a voltage . If it see's a voltage the chip turns on a led connected to another pin on the avr chip.

The AVR program and the PIR are working correctly. (both use around 5 volts DC)
Now I just want to take the led out and put in it's place something that can control a light switch without burning my circuit up.

I am assuming I need to use a strong diode to block current going to the chip from the house circuit. But after the diode I don't know what to use. Also part of the AC current will still get into the Diode every half cycle of the current this is really bad so I need like something else?

The chip is outputing 5 volts or less on a pin so I need something that can operate on 5 or less volts to turn on a 120 volt , 15 amp house circuit.

If you have a diagram on how I should rig up the output pin for controling the house circuit it would help.

Also I am unsure what kind of relay to use what do I need just a high voltage diode and a relay?
 

mik3

Joined Feb 4, 2008
4,843
Forget about the diode, you will blow the AVR and you may get shocked.

What power sources you have available?

Only 5V?
 

hgmjr

Joined Jan 28, 2005
9,027
As mik3 and I recommended, you don't need a diode between the AVR and the relay. All you need to do is use a transistor to provide the drive to the relay. The relay will serve to isolate the low voltage world from the high voltage world. Don't forget to use a resistor in series with the transistors base to limit the current drawn from the AVR. You will need to use a diode across the coil to protect the transistor from potential destruction by the flyback voltage from the relay coil.

hgmjr
 

Thread Starter

Mathematics!

Joined Jul 21, 2008
1,036
Ok , what relay should I buy is their a rating I am looking for.
I never worked with relays so I don't know how to rig them up.

So the output pin of the avr has a resistor then followed in series with the base of the transistor then what do you connect the emitter/ collector legs to on the relay?

avr output pin ---resistor ---base of transistor --- relay?
 

Thread Starter

Mathematics!

Joined Jul 21, 2008
1,036
Ok , thanks for the diagram really helped.

For the NPN transistor can I use radioshack 276-1617 for it?
They give the max Vce = 30V , Ic = 800AmA , power dissipation = 1.8W , and Hfe = 200

But they don't specify what the max base voltage/current is suppose to be. So I don't know what size resistor to use?

For the rectifier diode can I use radioshack 276-1661 ?

And for the Relay can I just use any 5 volt relay I find or is their some characteristic I should be looking for like max rating ,...etc? Because all I am going to look for is 5 volt relay with switch ratings of 120 or 240 volts AC is this good enough or am I forgetting some rating
 
Last edited:

mik3

Joined Feb 4, 2008
4,843
You can use your transistors and your diodes. If you want you can use a 1N4001 diode because it is smaller.

For the base resistor use a 1K one.


For the relay it must have switching voltage rating of 120V or 240V AC and it has to be able to handle the current of the load.
 

Thread Starter

Mathematics!

Joined Jul 21, 2008
1,036
Ok, I am looking at pictures of relays and I am wondering about wire how to connect the black and white house wires to the relay?. Do I just put the relay by a wall switch and the magnet will swich the light switch on or off?

I just don't see from the pictures where the connection of white and black house wires would go. Also their are SPDT or DPDT ,,...etc I don't see any SPST.

If the relay is working on the principles of a magnetic field to turn on/off a switch then it seems all I would have to do is put the relay close to some metal part of the wall switch?
 

beenthere

Joined Apr 20, 2004
15,819
Standard house wiring makes a connection of the white (AC neutral) wire to the fixture. The switch (or relay) connects the black (AC hot) with the fixture.

My guess is that you are not at all familiar with AC wiring. This can be a very lethal occupation unless you know what you are doing and observe safe wiring practice. The relay and associated wiring must be mounted in a grounded box for safety. Failure to do so leaves a lethal shock hazard exposed. In needlessly endangers you and anyone else who comes in contact with the exposed wiring.

Check you local library for how-to guides on AC house wiring. Learn what you are dealing with and how to handle it safely before you become a crispy critter. It is utterly irresponsible not to have basic knowledge and understanding before fooling with wiring.
 

Thread Starter

Mathematics!

Joined Jul 21, 2008
1,036
I understand house wireing very well. But the problem is I don't know how relay's make the house open circuit into a closed circuit and vesa versa.

Do you somehow install these in place of the light switch.
In house's the light switch usually has white on one terminal (neutral ) , black on the other terminal ( hot) , and the green grounding screw gets tighted to the receptical box. For 3 way switches their are the traveler wires ,...etc.

Some times the 2 way switch has both black wires on the terminals and the white is wire nutted thru to the fixture ...etc . This is when the switch is before the fixture ...etc etc

Their are alot of different ways to rig a house. But my problem is not rigging a house I have rigged house circuits before. The problem is failure to understand how to rig the relay into the house circuit?

If I have a light switch that has a white wire on one terminal and a black on the other terminal. Then when I remove the switch where do I connect the white and black on the relay Or do I some how place the relay by the light switch metal or something?
 

gryskop

Joined Mar 1, 2008
26
I understand house wireing very well. But the problem is I don't know how relay's make the house open circuit into a closed circuit and vesa versa.
When I posted the circuit solution, I was under the impression you at least know what you are dealing with, but it’s quite apparent that you don’t.

Please be aware of what the previous posters said regarding the WARNINGS on HIGH VOLTAGE. I don’t want your wife to post a thread next week saying her husband killed himself playing around with high voltage AC. They might start looking for all the people who helped, and then suddenly I’m liable.

WARNING. WORKING WITH HIGH VOLTAGE (ANY VOLTAGE > 48V) CAN BE LETHAL. IF YOU ARE NOT QUALIFIED TO WORK ON THIS VOLTAGE, DON’T!!!!
 
Top