Relay driver circuit

I need help from you hardware guys out there.

I’m developing a sprinkler controller for my home based on the Panda II and Tinkerer.

I need to drive 8 relays, one at a time, using digital I/O pins on the Panda.

I would like to use this darlington driver: [url]http://www.sparkfun.com/products/312[/url]

with this relay: [url]http://www.sparkfun.com/products/10509[/url]

in this circuit: see image and link below

Based on the relay datasheet, I think I can drive it with 6.5 or 7 volts?
What value resistors should I use for R1 and R2?
Any other tips / recommendations?

Thanks.

[url]Interfacing Relay to Microcontroller

R1 is not needed as the uC on the Panda has built in pull up resistors. The only function of R2 is to limit the recirculation current when the relay is turned off and the diode shunts the voltage spike produced when the magnetic field collapses. Use a 1A or so diode and forget about using R2.

the reason you may use a fixed pullup resistor R1 is when oyu want to ensure that a code issue or a uC issue (or even just a uC reboot) doesn’t put the sprinkler into an on state when you don’t want it to.

Edit: R2 seems to be just a current limiting resistor for the LED, so pick how bright you want the LED to light up and pick R2 appropriately.

Agreed. R2 isn’t necessary. R1 is for the Led so about 470 ohm should be fine.

The ULN chip has an internal flyback diode so it is a great choice for this type of circuit.

I didn’t check the spec for the relay. They are usually 12V but should switch down to 7V. Use the Panda’s 9V supply.

The sprinkler solenoids usually want 24v AC from a seperate transformer. Check the specs.

@ realiser, I think you got your R1 & R2 reversed.

I didn’t realize that the schematic was showing a LED, guess I looked at it too quickly. The ULN2803 has an active high input and open collector output as I recall so the pull up resistor R1, would keep in the input ON until you pulled it low with the uC. This way not be the behavior you expect.

Thanks everyone. There are a few things I hadn’t thought of:

[ol]
The relay should be OFF by default.
The relay should be OFF during power up and reboot.
The relay should remain OFF until a logic HIGH is output on the DIO pin.[/ol]

I’m using 6 of the darlington transistors, so there are two left over for other purposes (i.e., some sort of master enable/disable that could enable the relays by program control only).

Another alternative is to use an opto-coupler, such as this: [url]http://www.sparkfun.com/products/784[/url]

Would that help with some of these issues?

You can use a TRIACs to switch valves.

Oops - I got R1 and R2 wrong.

To ensure the relay stays off, use a pulldown resistor R1 to ground. 10k should do it. I’d put in 1k between the logic pin and the chip to protect the Panda. Resistor arrays work great for this.

A simple alternative is a logic level MOSFET. Very easy to use and made to switch loads like this.

I stripped a sprinkler system a while back and what is in there is a controller, MOSFETS and lots of protection. Transorbs and all kinds of stuff. The problem is you are dealing with wires in wet areas exposed to the elements so things get rather harsh out there.

HI guys,
i’m also interested in building a relay for the Ac load something rated at 30A…

@ Architect: How could one use a triac for such thing any part numbers and diagram…

@ realiser: what kind of a MOSFET can be used at @ 30A 220VC a part number and simple diagram would be great…

PS: trying to do this for the Spider which i would like to figure out and build soon…
the idea is to build one and the challenge to build a board with Four, 8 and 16 …

hopefully and i get it done before GHI releases their version otherwise i know I’ll be cheating LOL

Thank you guys,

Hi Jay Jay (and others),

MOSFET is not the right technology for switching 220V. A Triac is - but 30A would be over anything I’d ever worked with. That’s a lot of current - we’re talking a 6.6KW device here (like a BIG pump or something)… Maybe a water boiler?

What I’ve seen people use for this kind of load is a Contactor. Basically a very large AC relay. You use a small relay to switch the contactor on and then use the contactor to switch the load. This is lethal stuff - don’t play around with it if you’re not an electrician. This is outside my line of experience so maybe someone else can help.

Just as a general guideline, I generally use the following (with limited experience I might add):

  • For DC loads below 500 mA, I use a ULN2803 directly or a transistor.
  • For DC loads above 1A and 220V up to 5A (or so), I use a relay.
  • For DC loads between 5A - 20A like a motor I use a MOSFET. Above that gets dangerous, so I rely on commercial products.
  • For 220V AC loads up about 1000W I use triacs (with an opto-coupler). I scare easily with mains power, so I rather use relays if I don’t have to control the power.
  • For 220V over 1000W I’ll use a contactor with a small switching relay. Just the safest in my opinion.

Please don’t go and hurt yourselves with this stuff. Rather get professional switch equipment and interface into that.

Contactors are a special type of relay that are constructed such that each pole (switch) is mechanically independent. This is a safety feature that prevents one stuck contact from keeping both poles closed and thus the device it is controlling in the ‘stuck on’ position.

They come in both AC and DC flavors. Make sure you buy a contactor that is rated for your load range and voltage type (AC or DC). They are not interchangeable.