Not only am I new to AVRs but also electronics in general. I'd like to build a switch controlled by an AVR that would turn on an AC circuit (a power strip for example). Can anyone point me in the right direction? I'm not even sure what to look up. Google only gives me references to some rock band =].
Not quite sure what to ask... AC/DC Switch?
Try a simple avr connected to either an NPN transistor or MOSFET. The transistor is then connected to a relay that can switch the hot side of the AC
Easy as hell to build.
Now, all you need is a program to make the AVR to turn on the lights.
Jim
Thanks, I understand the AVR/DC part I'm just a little confused when it comes to mixing AC and DC. Is there a technical term for it so I can look it up?
Thanks!
No
Let me put it to you this way. If you are just starting out. DON't play with 110vac yet
Start small and get the relay to activate. Use low voltage DC. Burning the house down or zapping yourself sucks big time.
Jim
Look for a 'solid state relay'. They have optically-coupled inputs and can be switched on and off by an MCU output pin. They are fairly expensive but save a lot of trouble, and you are unlikely to kill yourself, unless you do something very silly. 8-)
Something like this should do:
http://uk.rs-online.com/web/search/searchBrowseAction.html?method=getProduct&R=0394535
Leon
It's more a matter of safety: your goal is switching f.i. a powerstrip. The use of a relay is then the safest, easiest and best solution.
And yes, there is a term for mixing AC and DC: it's called "super-imposing" or "mixing" but these terms will not help you in finding a solution for your question "How to switch AC with an AVR"
Nard
edit: Leon's suggestion if fine too, but only if you are aware of the limitations of solid state switchers. Not all of them are good with inductive loads f.i. For switching light bulbs (resistive loads in general) they are fine.
Thanks guys! And no worries, the reason I asked everyone here is so that I _don't_ end up zapping myself =].
@OP
If all you want is to control a strip of mains connectors.
Buy one of those USB controlled main strips , cut the USB plug off.
And connect the wires to an AVR Pin , via a transistor or mosfet.
That way you won't get in contact with the mains , and the device is already made to interface with 5v.
/Bingo
Allow me to ask the OP one Question....
What is your electrical/electronic background?
It would give us better insight in advising.
Jim
How can I post image (jpg)???
Allow me to ask the OP one Question....What is your electrical/electronic background?
It would give us better insight in advising.
Jim
My electronics background is basically limited to what I've read and learned on my own. I'm not an EE or anything - actually a software engineer =].
How can I post image (jpg)???
Not sure if there is a "standard" way to do it here. I generally just upload the images to a webserver and then link them here via the \[img] tags
@OPIf all you want is to control a strip of mains connectors.
Buy one of those USB controlled main strips , cut the USB plug off.
And connect the wires to an AVR Pin , via a transistor or mosfet.That way you won't get in contact with the mains , and the device is already made to interface with 5v.
/Bingo
This isn't a bad idea, thanks =]. Not exactly sure what I am going to do yet. I was going to use this in conjunction with a 5VDC ultra-sonic range meter and a 120VAC water pump to determine/replenish the water level in my (legal) hydroponic grow-room. However, I think I may have a DC water pump I can use to avoid this all together. Either way, I've always wondered how to do this so I'll be trying it out soon enough. My boss here at work is a PhD. EE but he's not around right now - I'll run what I finally decide to do by him first just to make sure I'm not going to hurt myself!
icarus1 wrote:How can I post image (jpg)???Not sure if there is a "standard" way to do it here. I generally just upload the images to a webserver and then link them here via the \[img] tags
AVR output: The selected uC output.
1: you have AC power
0: you don’t have AC power
Note: Don’t connect one of the 2 open drain outputs (look at the I2C - 2 wire interface)
4K7: resistanse for protecting the npn base
47K: resistanse for setting the npn inactive when the pin is floating.
Relay coil: the relay’s coil. Remember that the higher the V+ the lower the relay coil consumption. Also the V+ is not the Vcc and can be higher than Vcc (lets say 12V or 24V)
Ll4148: Silicon diode. For protecting the npn collector from high relay coil voltages.
C: the relay common contact. Connect here the AC power.
NC: the relay normaly closed contact. The contact connects the C and NC when the npn is inactive. Connect nothing here.
NO: the relay normaly opened contact. The contact connects the C with NO when the relay is active. Connect a 230V AC lamp here.
Good Luck.
Michael
Attachment(s):
(legal) hydroponic grow-room.
ROFL. Like I haven't heard that before... Honestly officer, it's only oregano! =)
If you're using a relay, you should find one that will handle 120V load and whatever current you need, but have a coil voltage of 5V. That way you don't need any higher than VCC to drive it. Something like:
http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail?name=PB893-ND
Will do nicely for $1.50 if your pump needs < 5A @ 120V. Keep in mind that it also takes 40mA to drive the coil, so you'll need to hook it up to a transistor like Michael's picture shows, as the AVR can't deliver that much.
If you need more current for the pump or want a lower coil voltage (40mA might be high if this is battery powered) then just search digikey or the like for another one, as there's hundreds of em for 5V drive.
jgmdesign wrote:
Allow me to ask the OP one Question....
What is your electrical/electronic background?
It would give us better insight in advising.
JimMy electronics background is basically limited to what I've read and learned on my own. I'm not an EE or anything - actually a software engineer =].
Ok now at least we have something to go with.
First, great to see you wanna play with high voltage. DON'T DO IT RIGHT NOW
Take the advice and just get the relay to trip. AS I asked before, what are the parameters to get it (the avr) to do something?
Keep us up to date... you are the only fresh meat we have had to play with. :lol:
Jim
How to switch 120/220 VAC (or whatever) is a rather interesting question for many hobbyists I suppose. A conventional relay (or solid state) is straight forward, but even if evertything is done correctly, there is still the question about local laws and regulations. At least here in Norway you're not allowed to do much yourself when it comes to 220VAC. In case of a fire, I don't think a mysterious DIY plastic box with a 220VAC cable sticking out of it would be a favourite among the insurance companies.
For this reason I would prefer a readily made, sealed and approved device to take care of the mains switching. A device such as suggested by Bingo sounds good. Another alternative could be an automatic light switch (or light relay or whatever they're called; basicly a device that automatically switches on a light at night). Use a LED to illuminate the device's light sensor, and make sure the sensor is left dark when the LED is off. LED on => mains switched off; LED off => mains switched on. Just be sure to observe the device's maximum power rating and whether inductive loads are permitted.
This past summer I put together an automatic dehumidifier circuit together to pump the water out of the tank when it hit a certain level. I based the device on the Tiny13. I had two probes in teh tank for min/max and a small 120vac submersible pump. When the upper limit probe tripped the avr activated a relay and deactivated when the lower limit probe tripped. I added a 5 minute timer to shut down the pump in case the probes malfunctioned so it would not run dry.
If that is what you are looking for I will be more than happy to post teh source code
Jim
MAins plugs controlled by radio radio frequencies from a small remote is getting more or less dirt cheap. Use the warts without tinkering with them. Hack into the remote, interface it to the AVR and you're off!
The ones I have are rated up to 1500 Watts. Is that enough for you? (If you are dealing with effects over 1.5 kW then you should be very careful...)
Over here you get three plugs and a remote for what would be approx USD 180. If you thrash the remote while hacking it then you can hopefully get a spare remote separately (USD 15?).
Pros: No tampering with mains voltage. No insurance company problems if the worst happends. Nice clean solution - no control wires to the mains outlet.
This is what I'm talking about (I'm sure there are plugs that fit your countrys wall plug standard):
Attachment(s):
Johan
The OP says that he is not hardware savvy, software yes.
We do not want to scare him yet do we?
I just dismantled my remote, and it looks quite simple. The buttons are those rubber thingies that have some carbon-based contact surface beneath them. I'm thinking: Rip the shell off, and attach wires to those surfaces. Attatch them to the AVR and and let the AVR make the remote think that someone presses the buttons.
This is not scary at all. "Au contraire, mon ami!" What other solution would require less hardware knowledge?
Yes there are some tech issues to deal with: Eg.
- Remote runs on one CR2032 lithium coin cell but if the AVR also runs on 3 volts thats taken care of, otherwise you need to fix some dual voltage supply.
- The PCB in the remote looks like it will be possible to just drill through the plate at the places for the carbon surfaces to somehow attach a wire securely. Can one solder something to that carbon surfaces?
etc
But still we are totally isolated from any security issues regarding mains voltages, and I doubt that you can design anything that will do this job cheaper (if we are talking a small series or a "one off") and easier.
And I still like the radio-based thingie. You can have the AVR control unit where it's handy. No need to have it in close vincinity to the mains that is being controlled. The AVR part should lend itself to be battery powered with ease. I se a lot of sleep mode and stuff here, if all we need to do is switch mains on and off.
My remote has a slider on the back for four different "channels", each able to control three mains plugs (there are three times on + off button on the front of the remote you see ablove). The mains plugs have a rotary selector with twelve positions (four channels times three "sub-addresses within channel selected"). You can of-course have several plugs set to the same channel+sub-address and they will all go on with a push of one button on the remote). If one hacks into the channel selector on the remote one AVR can control 24 individual mains plugs "groups".
Only draw-back I can think of so far: You live close to someone else that has a similar remote, and when the neighbour gets up in the middle of the night to take a leak, your stereo starts...
Yup, radio controlled wall plugs are interesting. Seems hackable, but still no messing with the mains voltage. Had a look today, and found a three-pack for the equivalent of some USD 35-40; supposed to switch up to 220VAC/16 amp. The remoted was suppoed to operate on a 12V battery though, I would prefer an AVR compatible voltage to simplify things.