How to switch multiple amp-loads with an Atmega - Page 1
Forum section: electronics / beginners

author: bryce1
author_rank: Regular Contributor
timestamp: October 28, 2013, 07:38:47 am
content: Hi,I want to switch a couple of heating elements (24V/3A), pumps (12V/2A) and LEDs (24V/2A) for a green house project using an Atmega.Since the project will be (hopefully) used by many others, I want to make it safe but not too expensive. My worries are that my lack of experience leads to unsafe or stupid design :-D- Are smartswitches likethesethe way to go?- Do I switch high or low side?- How do I make sure that the Atmega gets "clean" power while switching such high loads (using the same power supply)?Thanks so much!

author: Psi
author_rank: Super Contributor
timestamp: October 28, 2013, 08:14:05 am
content: I would use relays and a separate supply.Solid state relays would make driving them from an atmega simpler, and they would be sealed from moisture which is likely to exist in a greenhouse. More expensive though.

author: Simon
author_rank: Unknown
timestamp: October 28, 2013, 08:58:58 am
content: a properly driven mosfet can be used. For low amp loads something like a logic level IRL540N could be driven directly with the atmega on 5V or use a mosfet driver.As for power supply suitable bypass capacitors should sort it for you, there will be a 5V reg between your supply and the MCU with a decent capacitor on the output. If you are really paranoid put a diode in series with the voltage regulator and it's input filter capacitor, that way you know your input filter cap is only supplying the reg and any drops in the line will not really affect it (positive peaks will however).

author: Whuffo
author_rank: Regular Contributor
timestamp: October 30, 2013, 06:30:57 pm
content: Solid state relays are what you want. Simple to drive with logic level signals, available in versions that will support all of your requirements, and very easy and safe to use. Check Ebay and other second hand dealers to find bargains; they're kind of expensive if you buy them new. Most are water resistant and would be happy in a greenhouse; remember to install them in a metal box rated for electrical service; they'll heatsink to the surface they're mounted to.

author: Simon
author_rank: Unknown
timestamp: October 31, 2013, 10:27:01 am
content: why not a nice cheap mosfet? I have just completed a circuit that pulses a 12V 8A pump at 20 KHz with an IRL540N with small heat sink connected straight to an MCU on 3.3V (I'd have preferred 5V but the circuit was not my design). The pump uses about 2A in reality and this is pulsed, if you are just turning off and on very little heat issues.

author: Psi
author_rank: Super Contributor
timestamp: October 31, 2013, 12:35:04 pm
content: There's nothing wrong with using a mosfet but he would need to consider the disadvantages over a solid state relay.- A mosfet is slightly more complex to drive than a SSR which is just an LED, something everyone knows how to connect to a mcu.- Moisture/water may get into the package, a typical TO220 isn't really waterproof. It will work for a while, maybe years, but moisture will slowly get inside.- The gate is high Z, if the mcu is in reset or off state but there's still power on the driver side of things then the mosfet may switch on due to moisture causing current to flow through the gate. The SSR is an LED so requires actual current to switch on.- A dead mosfet may destroy the mcu if it shorts Drain to Gate, its not isolated like a SSROf course the SSR has the disadvantage of being more expensive.There are also a few types and some are not suitable for DC, others don't have any isolation.So some knowledge is needed to pick the right one. (I would probably pick an optical mosfet type but im not SSR expert)Actually i would probably use mosfet as simon says, because i'm cheap.but for someone still getting into electronics a relay is easier to work with.

author: Simon
author_rank: Unknown
timestamp: October 31, 2013, 12:37:39 pm
content: I was thinking cost and as the circuit needs isolating from moisture anyway the whole thing needs to go in a water resistant box so having certain parts waterproof is not a lot of gain.Either method seems to be equal to me, I just thought I'd make the mosfet case as no one seemed to be.

author: pspgeek
author_rank: Contributor
timestamp: November 01, 2013, 01:47:10 am
content: QuoteAre all of these voltages DC?Quote- use a logic level n-channel mosfet- make it waterproof with some kind of "heat resistant glue"?- that's why people use a pull-down resistor- use a doide or a optocoupler

author: Psi
author_rank: Super Contributor
timestamp: November 01, 2013, 02:14:38 am
content: Quote from: pspgeek on November 01, 2013, 01:47:10 amYep, i agree. But its more complicated than one SSR and one resistor

author: rastro
author_rank: Frequent Contributor
timestamp: November 01, 2013, 02:36:52 pm
content: For about $8 US delivered control 8 channels. Can be driven directly from arduino. Specked to handle 10A.My only caveat is the jumper on some versions could accidentally take coil drive voltage to ground. I would remove this pin-selector and solder a link that can't be accidentally moved. Also I'd probably fuse the power inputs.New 5V 8 Channel Relay Module Board for Arduino PIC AVR MCU DSP ARM Electronichttp://www.ebay.com/itm/New-5V-8-Channel-Relay-Module-Board-for-Arduino-PIC-AVR-MCU-DSP-ARM-Electronic-/180822479761?pt=LH_DefaultDomain_0&hash=item2a19dc1391

author: bryce1
author_rank: Regular Contributor
timestamp: November 21, 2013, 11:16:26 am
content: Quote from: pspgeek on November 01, 2013, 01:47:10 amYes, all of these are DC.

author: Maturola
author_rank: Contributor
timestamp: November 21, 2013, 08:58:34 pm
content: Is very simple to do this with a couple of Old fashion mech Relays, a couple of transistors and a Driver form the ATMEGA.Check out these relays, I had use them before, they are about $1 each.http://www.te.com/catalog/feat/en/c/16656?BML=10576,16453To power the ATMega, all you need is to rectify the 24v AC (if that is the one you want to use as power), a tank input Capacitor and a DC to DC Buck Converter. (I personally like the TPS40170 for 24VAC applications, but there are many options out there).EDIT: I missed the last part where you said they were all DC rails. - Just ignore the rectification part, and go directly with a DC to DC buckBy the way, this is pretty much what Thermostats do, so if you get your hands on a thermostat schematics you will be able to see the supply and the Relay Driver circuits they use.Edit 2: I also forgot, if you really don't want (or don;t feel confortable) building the drivers, you can get small chips to do that, I used these before as well, they are about $1.5 each.http://www.infineon.com/dgdl/IFX52001EJ-pb.pdf?folderId=db3a304318f3fe290118f5a433570040&fileId=db3a30433072cd8f0130d63126f414f1

author: Simon
author_rank: Unknown
timestamp: November 21, 2013, 09:01:25 pm
content: If you use a mosfet to drive the relay and use one with a decently low Vgs threshold you won't even need a mosfet driver as relay coils take about 50mA, or use a BJT, you can even get 5V relays if you want to avoid too many power supply voltages or use your pumps 12/24V supply

author: Paul Moir
author_rank: Frequent Contributor
timestamp: November 22, 2013, 04:51:38 am
content: QuoteI think it's more accurate to say that the vast majority are not suitable. And DC inductive load through a mechanical relay isn't straight-forward at all either because of the quench time. A DC SSR is simple though and gives you isolation, which is to say if something really bad happens at the load, it won't blow your microcontroller to bits. The caveat is that they tend to fail on, which may be somewhat disastrous depending on the mechanical system.If you do use mechanical relays let us know so we can talk about contact arc suppression.

author: bryce1
author_rank: Regular Contributor
timestamp: February 13, 2014, 04:35:39 pm
content: Yes please. How can I make sure the same output can PWM a LED and still switch a mechanical relay safely?

author: Simon
author_rank: Unknown
timestamp: February 13, 2014, 05:08:29 pm
content: why do you want to PWM an LED from the same output ? you could do it by having a diode in seried with the gate followed by a capacitor with a resistor in parallel, that way your gate sees a steady voltage but you can use your PWM to drive an LED, but it's a very convoluted way of doing it.