Not quite sure what to ask... AC/DC Switch?

Go To Last Post
24 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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 =].

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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

Leon Heller G1HSM

Last Edited: Thu. Jan 3, 2008 - 07:55 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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.

A GIF is worth a thousend words   They are called Rosa, Sylvia, Tessa and Tina, You can find them https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks guys! And no worries, the reason I asked everyone here is so that I _don't_ end up zapping myself =].

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@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

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Allow me to ask the OP one Question....

What is your electrical/electronic background?

It would give us better insight in advising.

Jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How can I post image (jpg)???

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

jgmdesign wrote:
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 =].

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Bingo600 wrote:
@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

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!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

uidzer0 wrote:
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

you can attach it as a file to your post. you'll need to use the "new reply" button first, as attaching files is not an option from the "Quick Reply" box.

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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): 

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
(legal) hydroponic grow-room.

ROFL. Like I haven't heard that before... Honestly officer, it's only oregano! =)

Clancy _________________ Step 1: RTFM Step 2: RTFF (Forums) Step 3: RTFG (Google) Step 4: Post

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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.

Clancy _________________ Step 1: RTFM Step 2: RTFF (Forums) Step 3: RTFG (Google) Step 4: Post

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

jgmdesign wrote:
Allow me to ask the OP one Question....

What is your electrical/electronic background?

It would give us better insight in advising.

Quote:

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 =].

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

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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): 

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Johan
The OP says that he is not hardware savvy, software yes.

We do not want to scare him yet do we?

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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.