Relays for two sources?

Thread Starter

Macabra

Joined May 31, 2008
49
I'm wondering if it is possible for a relay to switch between two different sources. As an example, to switch from a power source 12V to 9V battery source when needed. If so, what relay should I use and how should I connect it? The signals that will be sent to do the relay switch are from a microcontroller..will this be enough for the coil in the relay to become a magnet to perform the switch?

Much thanks everyone.
 

mik3

Joined Feb 4, 2008
4,843
I'm wondering if it is possible for a relay to switch between two different sources. As an example, to switch from a power source 12V to 9V battery source when needed. If so, what relay should I use and how should I connect it? The signals that will be sent to do the relay switch are from a microcontroller..will this be enough for the coil in the relay to become a magnet to perform the switch?

Much thanks everyone.
Yes you can by using just a simple SPDT relay. Connect your circuit to the common pin (COM), the most used power source to the normally closed pin (NC) and the less used source to the normally open pin (NO). You can connect your sources to either NC pin or NO pin but by connecting them as i suggest you will have the relay unpowered the most of the time, thus saving energy. This is important if you use batteries to power your control circuit.
If the microcontroller is capable of driving the relay directly depends on how many milli amps it can source/sink and on the type of the relay (check the datasheets). Maybe you can connect it directly to microcontroller but i wont suggest it because the when you will turn off the relay it will generate a back EMF to maintain its coil current and thus this back EMF will destroy your microcontroller. Of course you will use a clamping diode to absorb this back EMF but diodes dont respond instantly so it is still dangerous. It is better to use a transistor to drive the relay from the output of the microcontroller and even better an optocoupler, but a transistor is good.
 

Papabravo

Joined Feb 24, 2006
21,227
You can do this, but I think it is a sub-optimal idea. You can select the relay coil voltage to be anything you like including +5VDC. The contacts on the other hand are likely to be break before make contacts which means there will be a short period where there is no power at all to your circuit.

By any objective definition an electronic switching scheme offers numerous advantages.
 

SgtWookie

Joined Jul 17, 2007
22,230
See the attached for one possible approach.
The uC is represented by the buffer.
A driver is needed to power the relay's coil. The diode takes care of the reverse-EMF spike when the relay is de-energized. The capacitor keeps power flowing during the time the relay contacts are "in flight"; ie: between connections. The power to energize the relay coil comes from the external 12v source.

One omission is a Schottky diode from the + side of the battery to the relay contact. This would prevent the capacitor from trying to charge the battery when transitioning from 12v external supply mode to internal 9v battery supply mode.
 

Attachments

Thread Starter

Macabra

Joined May 31, 2008
49
wow you guys are amazing! Yes, I thought about using a low pass filter..with a huge capacitor to keep some voltage while the transition between swtiching takes place. I've also considered using diode for protecting the coil of the relay and the microcontroller.
 

bloguetronica

Joined Apr 27, 2007
1,541
using 2 power diodes to isolate the two power sources should work also.
Indeed. I would go for the two diodes as well. I've used this configuration on a RAM chip, since I had a memory backup battery. Basically, when the 12V are supplied, the battery doesn't supply current since its diode is under reverse voltage.
 

deplora

Joined Jun 11, 2008
10
I have the same problem, and upon configuring my circuit as suggested from the image above, it didn't work for me :confused:. I'm using NTE R57-5D.25-12 SPDT relay and have set up exactly how Sgt suggested including the diode in between the battery contact and the relay contact.
I have pin one being the output, pin 2 I have the diode where the cathode is connected to pin2 and in this case to the 12V, then pin 6 is the anode and the collector of 1N2222, pin 8 I've got the 12V being the most common source (or primary source), and pin 14 I have it to cathode of diode and anode of diode to 9V, being the secondary source. So, when it is off, the relay's switch would be connected to the 9V and when on it should flip to the 12V.

As far as the transistor goes, it is the same.
What am I doing wrong?

Much thanks
 

bloguetronica

Joined Apr 27, 2007
1,541
I think your relay has break-before-make contacts, and that might be enough to erase a RAM chip. A make-before-break kind of relay wouldn't be the best solution either, since during a small instant, the 12V source will be charging the 9V battery, which is very dangerous. I advise you to opt for the two diodes, or opt by adding a small electrolytic capacitor between the Vcc and GND near the RAM, if you wish to keep the break-before-make relay.
 

deplora

Joined Jun 11, 2008
10
Where would it be best to put these two diodes you speak of. I do not understand well their purpose, could you please explain? Also, i'm not trying to use this to keep the RAM of a microcontroller though it's actual purpose it to eventually when I get the voltage output working right with this circuit is to use some sort of a comparator or something that will differentiate when it is using battery and when it is using primary power (12V) and feed it to microcontroller and so it tells the user through software which source it is using.

thanks
 

bloguetronica

Joined Apr 27, 2007
1,541
The diodes isolate one voltage source from another. So you would put one diode between the power supply and the RAM Vcc pin and another diode from the battery positive terminal to the same RAM pin. You should use a small polyester capacitor (10nF) near the RAM, between Vcc and GND terminals.
 

deplora

Joined Jun 11, 2008
10
I'm sorry, I just don't understand what you are telling me here. What RAM??:confused: My problem is the same as what the first post stated. I need to have the output of microcontroller to flip the relay to a backup battery when necessary. SgtWookie attached a great image of what I need, however, I can't make that to work for some reason :(. You said before that this could also be done without relay but by using two diodes? I'm still very curious as to how this can happen :)..is the transistor needed for this? I really don't know how you would set it up either. I'm very much confused.
 

SgtWookie

Joined Jul 17, 2007
22,230
I don't know why you couldn't get the last diagram to work, except perhaps you connected something wrong, or your capacitor is no good, or it's electrolytic and you connected it backwards.

OK, here's how it could be set up using a couple of diodes. See the attached schematic.

BA2 simply represents an external power source; it could be a battery, a wall-wart type supply, or just about anything you could imagine - as long as it puts out a DC voltage that's sufficient, but not too high, for the device to be powered. The plug and jack make it easy to remove when you're going portable.

The two diodes are Schottky diodes. They have a lower voltage drop than standard rectifier diodes. There's no reason you couldn't use a common rectifier diode like an 1N4001 through 1N4007, or a 1N4148 - but a Schottky like a 1N5817 has a much lower forward voltage at low current than the standard rectifiers. This means you'll get more life out of your batteries.

C1 is really only necessary if the wires are long.

You will need a 0.1uF bypass capacitor across your Vcc/Vdd and ground/VSS/VEE pins on your microcontroller. Ceramic, tantalum, and poly are good types to use.

I don't know how familiar with electrical/electronic symbols you are. The three lines that together resemble a triangle represent ground, or a common attachment point. They're all electrically connected together. "Ground" in electricity and electronics represents a potential of zero volts; most everything is measured or referenced in relation to ground.
 

Attachments

Last edited:
Top