2 relays from one output pin?

kando

Senior Member
Can someone tell me if it is feasible to run two relays from one picaxe output pin?

I want to turn two relays ON when the picaxe output pin is made high and use a separate power from the picaxe 5V source but the same 12V source on the relays.

Thank you:)
 

JimPerry

Senior Member
Subject to the 20mA Picaxe limit no problem - use a transistor if more current needed and wire relays in parallel :rolleyes:
 

darb1972

Senior Member
Hi Kando

If you mean that the relay coils are 12V, then you will need to employ the use of a transistor/FET to drive the coils. The PICAXE can drive the base of the transistor. A transistor would probably be a better choice over a FET as most FETs tend to need a gate voltage higher than that of a PICAXE output.

I am on a tablet at the moment so I can't supply a sample circuit, but if needed I can knock one up tomorrow should you need it. All I need is confirmation of the coil voltage and the coil resistance. If the relays aren't identical you should give me both coil resistances. Let me know if you need a sample circuit.
 

kando

Senior Member
Hi, Darb1972,
No, the relays I would like to use are 4.5Vcoils so can be powered by the picaxe power as in the diagram and can handle 48VDC on the switched end. So with that in mind is it ok what I have drawn in the diagram?:)

relay Details:
OKO 4.5Vdc/135Ω 47W/5H
 

geoff07

Senior Member
Best practice would have a base resistor for each transistor rather than sharing one, though it might work with one. With one, the base-emitter junction voltages would be locked together, even though if independent they might be naturally slightly different. This would lead to different collector currents and thus different dissipations. Whether that mattered would depend on the circumstances.
 

kando

Senior Member
Thank you Geoff07 for the information. I think I understand that. I just need the relays to switch on from one pin. So I think that in this case it wouldn't matter ut something to bear in mind for later (especially if it doesn't work).

Darb1972.
re-"All I need is confirmation of the coil voltage and the coil resistance."
Yes I would love to have the sample circuit for the picaxe to use a 12VDC relay coil using a transistor as you said.
the 12VDC relays I would use (as I have some) are:

GoodSky CAR-SH-112DE
30A/12VDC coil 12VDC
Contact resistance 100mΩ max.
 

kando

Senior Member
Just a thought....

Instead of two transistors and two resistors,

one ULN2003?

e
I'm not sure how that would look with a circuit and relay. The manual 3 shows it with what looks like a motor. Where would the relay fit? :0
 

Dartmoor

Member
Just a thought....

Instead of two transistors and two resistors,

one ULN2003?

e
Yes, ULN2003/2803 seems sensible & cost effective (about 50p?)
You can drive several relays off one 2003 output if you wish (as you could if you use the transistor solution - saving a transistor, diode resistor etc?).
. . . or you could use one DPCO relay?

Am doing similar, but opted for bigger picaxe with more i/o as the easy option.
 

Dartmoor

Member
I'm not sure how that would look with a circuit and relay. The manual 3 shows it with what looks like a motor. Where would the relay fit? :0
The data sheet for the CHI030 project board gives good details?
Relay connects between the o/p pin on the ULN2803 and +ve.
Remember that you should still use the reverse diode to prevent interference.
Hope that helps?
 

kando

Senior Member
The data sheet for the CHI030 project board gives good details?
Relay connects between the o/p pin on the ULN2803 and +ve.
Remember that you should still use the reverse diode to prevent interference.
Hope that helps?
Thanks Dartmoor
I have looked at the CHI030 board. Didn't realise what it did until now!
So do you say the circuit might be like this for the one picaxe output pin? and relays with coils 4.5VDC?
ULN2803A 2 relays one pin.jpg

It seems more like this one.
ULN2803A 2 relays one pin 1.jpg
 
Last edited:

AllyCat

Senior Member
Hi,

Why make it so complicated? Just connect the relay coils in parallel and drive from one low-cost transistor (e.g. BC548 or BC337) with one base resistor (~1k to the PICaxe pin) and one catching diode across the coils.

Cheers, Alan.
 

kando

Senior Member
Hi,

Why make it so complicated? Just connect the relay coils in parallel and drive from one low-cost transistor (e.g. BC548 or BC337) with one base resistor (~1k to the PICaxe pin) and one catching diode across the coils.

Cheers, Alan.
So a bit like the first diagram (page1) but with perhaps using 2N3904 transistors (I have more than few of these). But not as a darlington configuration?
 

Dartmoor

Member
As AllyCat says in post #13 (and I tried to say in post #10), you only need one transistor circuit (whichever type). Both relays are driven from that.
Ref your post #12 - yes the latter circuit but again with only one transistor circuit (whichever type).
Ref your post #14 - yes a bit like the first diagram (page1) but again with only one transistor circuit (whichever type).
 

kando

Senior Member
Thank you Dartmoor.
I sometimes might come across as being pedantic, hair splitting and try my best to understand. I'm sorry if I have not understood something at the first time of asking. I think the forum here is a brilliant forum for beginners in Picaxe chips and sometimes if one hasn't got used to how things all fit together. I can now try out my ideas with the help I have gained from the knowledgeable people here which clearly includes yourself without too much fear of wrecking them.
Thank you again for your help and everyone else here as well.
 

AllyCat

Senior Member
Hi,

But not as a darlington configuration?
No, probably not justified with the 5v, 60mA of your load. A darlington intrinsically has a higher voltage drop (equivalent to a diode in series with the collector, say an extra 600 mv) which may be significant with only a 5v rail.

A PICaxe can deliver at least 10 mA from each pin so there shouldn't be any problem getting sufficient drive to saturate even a "small signal" transistor. The data sheet for a 2N3704 shows a saturation of <200 mv at 50mA (with 5 mA base current) which is adequately close to your requirement.

But if you did decide to use individual drive to the relays, then you must duplicate the transistor, the base resistor AND the catching diode.

Cheers, Alan.
 

westaust55

Moderator
Also for that 60 mA of load current on the transistor you need a minimum base current of 6mA to out the transistor into saturation.

With the PICAXE output high it may be as low as 4.7 V with a 5 V supply but will usually be far closer to 5 V.
The transistor base needs to be at 0.6 V for switching on.
So now you can calculate the max value for the base resistor between PICAXE and transistor base.
R = (4.7 - 0.6) / 0.006 = 683 ohms
So use a 560 ohm resistor.

A note here as I see "transistor" being used as the alternative to "FET"
A BC548 etc is a BJT type transistor (bipolar Junction Transistor)
A FET is another type of transistor. FET = Field Effect Transistor.
 

Colinpc

New Member
Please ignore, misread original requirement.



As I understand it, the Picaxe output can be either high or low. Therefore one or the other relay will be on at all times (assuming one relay is switched by high and other by low). This amounts to one relay with the load on to one or other of the relay contacts (assuming C/O contacts). If isolation is required, use multiple contact sets.

Certainly simpler than messing around with 2 relays. Also if the relay off state is used for the most used purpose, the power is reduced.

Fred Dagg
 
Last edited:

darb1972

Senior Member
Hello Kando

Sorry for the delay in responding. My day didn’t go as planned so I didn’t manage to put together some examples until now.

Firstly, there have been a number of good suggestions and valid ways of driving your relays. I believe in keeping it as simple as possible, so, considering you are only wanting to drive two relays off the one PICAXE output, I would recommend a simple circuit consisting of one transistor, one resistor and a diode (or diodes, explained below).

You mentioned (initially) that you intended on using 5V Coil relays. That’s fine, but you still can’t drive these direct from a PICAXE pin based on the data provided. See attached. The first example is based on your 5V relays. I decided to put a 1N4004 (D1) in series with the relays as you mentioned that they are rated at 4.5V. The diode will drop around 0.6V to 0.7V and this will bring the relay coils closer to their rated voltage. I am not sure what repetitive long term 5V use might do to the coils so it’s best not to risk it. The other diode (D2) is to protect your transistor.

I also used your transistor selection of a 2N3904. I found a spec sheet on this transistor and it would be fine for the task when driving the 5V relays. When we look at the transistor data, the hFE (DC Gain) is roughly around 50 for an Ic (collector current) of around 60mA. To be precise, the total collector current would be 65mA. If you divide this by 50 you get a base current of around 1.3mA. I like to then times this by a factor of 3 to ensure transistor base saturation (as you will get variations in hFE). This equals a base current of 3.9mA.

Based on a PICAXE output of 5V and a B-E voltage drop of 0.7V, we can calculate the base resistor to be 1099 Ohms, or to use the nearest preferred value, use a 1k Ohm resistor.
I hope that makes sense?

OK, now onto your second suggestion of using 12V relays. It’s the same principal as above, however you are now going to need two voltage rails. 5V for the PICAXE (assuming you are using a 5V PICAXE and/or have chosen to use that voltage level and not a lower level) and a 12V rail for the relays.

The next issue is that the specs you listed do not list the coil resistance. Instead, you have listed the contact resistance. Never mind, a search of Google revealed a number of data sheets written in what I think might have been German and I haven’t a clue how to read them. A further search managed to dig up one with some English. This sheet didn’t list the coil resistance but did list the power consumption, being 1.59W. So, based on a 12V coil, this would mean that our coil resistance is 132.5 Ohms, and, if we manage to drive the 2N3904 into complete saturation and have a very low C-E voltage drop (typically around 0.3V for this higher current application) we can calculate that the Ic (collector current) is 177mA. By the way, these are an automotive relay and are (by nature) a bit heavy on the juice and draw more than a typical PCB mounted relay (from memory, many typical 12V PCB relays have a higher coil resistance of around 200 Ohms to 250 Ohms). Anyway, we will work with these and crunch the numbers.

The 2N3904 can handle 200mA so it will just make it in terms of driving two of these relays. From the datasheet, it is a little unclear as to the hFE at currents higher than 100mA, so I will have to make the assumption that the hFE at 100mA (being a fairly low 30) is correct. This will result in a base current of 6mA. Again, to ensure saturation, I like to times this by a factor of 3. That then results in a base current of 18mA which is getting to the upper limit of what a PICAXE will handle (but it is doable). This results in a base resistor of 238 Ohms. I am inclined to suggest that you DON’T take this to the nearest preferred value of 220 Ohms as you might overload the PICAXE. Instead, I would suggest putting two resistors in series (two 120 Ohm).

Because of the higher current with the 12V version, we should also consider device wattage to ensure we don’t “fry” anything. The base resistor will dissipate 77mW (in total) so standard quarter watt resistors will be fine and the 2N3904 will (based on full saturation) dissipate 53mW, so again, well within specs (can dissipate 625mW).

There are other ways of doing this (as has been explained) and as mentioned, the 12V automotive relays are heavy consumers of current and are probably not the best choice (although I am not sure of your exact application?). If you were to stick with the automotive relays then maybe a transistor with a higher gain might be in order.

I hope this makes sense and helps. It’s very late so hopefully I haven’t made any drifty mistakes. Let me (and the forum) know if you have any more questions.
 

Attachments

AllyCat

Senior Member
Hi,

At post #1:

I want to turn two relays ON when the picaxe output pin is made high and use a separate power from the picaxe 5V source but the same 12V source on the relays.
But it wasn't until #5 that you told us that they are 4.5 v relays! So just connect them in series (with one driver transistor and a catching diode, etc.). Purists may say that you should also use a series resistor of, say, 100 ohms. Similarly, minimum gains of 10 and 30 have been quoted above, so assume the normally accepted value of 20. For 30 mA (relays in series) that's less than 2 mA base current so use a 2k2 resistor, but anything from 220 ohms up to 10k will probably work. :)

However, in general, don't try to use weedy transistors like 2N3704 above about 100 mA, they may be rated higher, but their current gain will be pathetic.

Cheers, Alan.
 

kando

Senior Member
I decided to put a 1N4004 (D1).
I also used your transistor selection of a 2N3904. I found a spec sheet on this transistor and it would be fine for the task when driving the 5V relays.
Based on a PICAXE output of 5V and a B-E voltage drop of 0.7V, we can calculate the base resistor to be 1099 Ohms, or to use the nearest preferred value, use a 1k Ohm resistor. I hope that makes sense?
OK, now onto your second suggestion of using 12V relays. It’s the same principal as above, however you are now going to need two voltage rails. 5V for the PICAXE (assuming you are using a 5V PICAXE and/or have chosen to use that voltage level and not a lower level) and a 12V rail for the relays.
This sheet didn’t list the coil resistance but did list the power consumption, being 1.59W. So, based on a 12V coil, this would mean that our coil resistance is 132.5 Ohms,
Because of the higher current with the 12V version, we should also consider device wattage to ensure we don’t “fry” anything. The base resistor will dissipate 77mW (in total) so standard quarter watt resistors will be fine and the 2N3904 will (based on full saturation) dissipate 53mW, so again, well within specs (can dissipate 625mW).
There are other ways of doing this (as has been explained) and as mentioned, the 12V automotive relays are heavy consumers of current and are probably not the best choice (although I am not sure of your exact application?). If you were to stick with the automotive relays then maybe a transistor with a higher gain might be in order.
Hi, thank you very much, all of you for the information supplied. Thank you darb1972 for the really full explanation. It really has helped me get my head around the electronics part. I have a couple of questions though…

Is it absolutely necessary for 1N4004 or can I use 1N4001 I’m assuming that the only difference between the two types of diode is the maximum voltage that each can deal with? (I believe the 1N4001 deals with voltage up to 50V and the 4004 up to 400V).

Thank you for the info on the 2N3904s. I couldn’t find info for the car relays in English either. I have a few of the relays and this is the reason I would use them. So again thank you for the info.

PICAXE output of 5V and a Base-Emitter voltage drop of 0.7V, we can calculate the base resistor to be 1099 Ohms. It makes perfect sense to me after learning/reading about that. Thank you for pointing me in the direction to do so.

For the 12volt method, I’m assuming that I need to connect the picaxe 0 volt to the 12v supply 0v as well. Am I correct?

Thank you for the power consumption considerations. It’s low because it uses the transistor as a switch I believe?

The project I have in mind will be for automotive stuff and I see that you say that a different transistor would be better if it had a higher gain. Have you got a transistor in mind?

Thank you all for the help.
 

Paix

Senior Member
Is it absolutely necessary for 1N4004 or can I use 1N4001 I&#8217;m assuming that the only difference between the two types of diode is the maximum voltage that each can deal with? (I believe the 1N4001 deals with voltage up to 50V and the 4004 up to 400V).
Use what you have. 1N4001 should be OK. Buying logic: You can buy at a radio rally or similar a bandolier of 50 or 100. What do you buy. IN4001 or 1N4002? You buy 1N4002 because while it's overkill for a lot of what you will use it for, it will be beefy enough when the 1N4001 runs out of steam. Cost is likely to be the same and you don't want to buy a bandolier of both because that's two that you are going to lose for when you want them . . . :)

Thank you for the info on the 2N3904s. I couldn&#8217;t find info for the car relays in English either. I have a few of the relays and this is the reason I would use them.
Personally I would tend to use 2N2222A. Car relays generally have a 12V coil and as Darb has said are current hungry. Relays today are a lot cheaper than they used to be, so how about something like this..

For the 12volt method, I&#8217;m assuming that I need to connect the picaxe 0 volt to the 12v supply 0v as well. Am I correct?
You are correct. Without a common 0V rail, you will go batty and pull your hair out trying to figure out why things don't work. Watch out for bread boards with a split/gap in the 0V rail which can be easily overlooked and deny you the common rail that you worked so hard to provide . . . :(

Thank you for the power consumption considerations. It&#8217;s low because it uses the transistor as a switch I believe?
I'll leave this one for someone that knows what he's talking about!
The project I have in mind will be for automotive stuff and I see that you say that a different transistor would be better if it had a higher gain. Have you got a transistor in mind?

Thank you all for the help.[/QUOTE]
 

kando

Senior Member
Use what you have.
I try to that's why I was asking. so thanks for that.

Personally I would tend to use 2N2222A. Car relays generally have a 12V coil and as Darb has said are current hungry. Relays today are a lot cheaper than they used to be, so how about something like this..
Superb looking relay board. will have to try one out. I guess the in1-in8 are the input from pixaxe pins or do you have to go through the transistor as well on this?

You are correct. Without a common 0V rail, you will go batty and pull your hair out trying to figure out why things don't work. Watch out for bread boards with a split/gap in the 0V rail which can be easily overlooked and deny you the common rail that you worked so hard to provide . . . :(
Ok thank you.
 
Top