# 5v spdt relays with picaxe



## mystang (Aug 23, 2012)

Okay I have been messing with the picaxe (18m2) stuff for a couple weeks now when I can. Also have myself some Tenda (mdfly mp3 audio boards) that i finally got up and working last night. 
I have now moved onto relays... Now I have watched Steve's video using the darlington driver array to switch higher current devices and well as Pat from deadthings about switching relays, but the question I have is switching 5v spdt relays. One would think that the picaxe would be able to switch these without having to use a darlington driver since they are not 12v units.
The picaxe manual shows switching relays but shows it with 12v devices/relays and using a darlington driver to "interface" with the component. Also you are switching ground more or less from what i can determine with the darlington arrays but if I am to activate the coil on the 5v I would think I should be supplying the voltage with the picaxe to accomplish this so it would be different from the manual.
I guess my question is this a safe thing to do or would it cause to much current through the picaxe? Also second part to the question would be would I hook the kathode end of the diode to the output pin from the picaxe because the diagrams shows running kathode from 5v to "ground" side of the relay?


----------



## pshort (May 6, 2008)

mystang said:


> Okay I have been messing with the picaxe (18m2) stuff for a couple weeks now when I can. Also have myself some Tenda (mdfly mp3 audio boards) that i finally got up and working last night.
> I have now moved onto relays... Now I have watched Steve's video using the darlington driver array to switch higher current devices and well as Pat from deadthings about switching relays, but the question I have is switching 5v spdt relays. One would think that the picaxe would be able to switch these without having to use a darlington driver since they are not 12v units.
> The picaxe manual shows switching relays but shows it with 12v devices/relays and using a darlington driver to "interface" with the component. Also you are switching ground more or less from what i can determine with the darlington arrays but if I am to activate the coil on the 5v I would think I should be supplying the voltage with the picaxe to accomplish this so it would be different from the manual.
> I guess my question is this a safe thing to do or would it cause to much current through the picaxe? Also second part to the question would be would I hook the kathode end of the diode to the output pin from the picaxe because the diagrams shows running kathode from 5v to "ground" side of the relay?


Whether you need the darlington transistors depends on how much current is drawn by the relay coils, and whether the PICAXE is capable of providing that much current. Check the specifications for the relay under consideration. You'll need to add some sort of driver to the output of the PICAXE if the current draw is more than about 25mA, or if the total current draw of all of the relays exceeds 300 mA (I think that is the limit for the 18M parts). This can be either an array (such as the ULN2803) or discrete darlington transistors.

P.S. I think that you should plan on using the darlington array.

Further edit: Looking at the mouser website, it appears that some 5VDC relays can be driven from the PICAXE and others require too much current. As far as placing the catch diode goes, it is always placed across the coil, with the cathode on the 'positive' side of the coil. This means that in some cases the cathode goes to +5VDC, and in other cases the anode goes to ground (depending on whether you are switching ground or +5VDC, respectively).


----------



## mystang (Aug 23, 2012)

pshort said:


> Whether you need the darlington transistors depends on how much current is drawn by the relay coils, and whether the PICAXE is capable of providing that much current. Check the specifications for the relay under consideration. You'll need to add some sort of driver to the output of the PICAXE if the current draw is more than about 25mA, or if the total current draw of all of the relays exceeds 300 mA (I think that is the limit for the 18M parts). This can be either an array (such as the ULN2803) or discrete darlington transistors.
> 
> P.S. I think that you should plan on using the darlington array.
> 
> Further edit: Looking at the mouser website, it appears that some 5VDC relays can be driven from the PICAXE and others require too much current. As far as placing the catch diode goes, it is always placed across the coil, with the cathode on the 'positive' side of the coil. This means that in some cases the cathode goes to +5VDC, and in other cases the anode goes to ground (depending on whether you are switching ground or +5VDC, respectively).


Thanks for the response, I have a Darlington array so not a big deal. I shall head to my "lab" and see if I can't make the magic smoke stay inside the components.


----------



## fritz42_male (May 5, 2009)

I am lazy so I tend to buy relay boards with a transistor driver - it keeps everything 'modular' and easy to fault find.

I've used a good few of the ciseco ones 3-4mA in:
http://www.ebay.co.uk/itm/K006-rela...ther_Computing_Networking&hash=item337eb938db

but just found these as well - great price but 10mA:
http://www.ebay.co.uk/itm/New-5V-10...332?pt=LH_DefaultDomain_0&hash=item5aec4604ac


----------



## JeffHaas (Sep 7, 2010)

I have a few of these, they work well:

http://dx.com/p/arduino-5v-relay-module-blue-black-121354


----------



## Otaku (Dec 3, 2004)

I've used these:
http://www.ti.com/lit/ds/symlink/ds3658.pdf
to drive relays when I use BS2 controllers. You can control 4 relays per IC, or drive other devices up to 600mA. I sometimes need to have as many as 10-12 relays active at the same time with some of the test fixtures I design, and a BS2 can't handle that much current.


----------



## mystang (Aug 23, 2012)

Thanks for the replays, I also noticed that the relays I have are 5 pin so one leg is n/o an the other is n/c. These of course don't fit on any boards that are your normal square grid thru hole because the "supplied power" pin is offset like half a row if that makes since. I guess the question is are they all this way?


----------



## JeffHaas (Sep 7, 2010)

A lot of the small square relays are. When I first got one I drilled out the perfboard for the extra hole and soldered a piece of wire to make the connection. Then I discovered the pre-made boards had come out, so I just use those instead.


----------



## mystang (Aug 23, 2012)

JeffHaas said:


> A lot of the small square relays are. When I first got one I drilled out the perfboard for the extra hole and soldered a piece of wire to make the connection. Then I discovered the pre-made boards had come out, so I just use those instead.


Yes I will most likely do this in the future but I currently have 8 loose relays on hand.


----------



## JeffHaas (Sep 7, 2010)

It's not that hard to drill out the extra hole you need, just use a Dremel. Then solder a jumper wire as needed.


----------

