Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: h3ro on August 29, 2007, 05:50:32 AM

Title: Beginner question : Connecting relay
Post by: h3ro on August 29, 2007, 05:50:32 AM
I have a few questions about how to connect a relay:

Question 1:
Should the circuit with the low voltage be connected to the long side (8 and 5)?
(http://img154.imageshack.us/img154/1852/h18461op4.jpg)

Question 2:
A friend of mine said that in order to make my relay work correctly I have to connect a diode parallel to the relay. Is this correct? And if it is, is this the right way to do it (where should +/- go)?
(http://img267.imageshack.us/img267/5303/untitled1es6.jpg)

Sorry for all the stupid questions I have, but I really want to learn this. Im thinking of getting a book :)
Title: Re: Beginner question : Connecting relay
Post by: airman00 on August 29, 2007, 06:33:07 AM
Question #1: pins 8 and 5 are for the relay coil and the other pins are for the switch. The way a relay works is that a certain voltage given to the coil will trigger a reed switch. This means that you can have a low voltage control a high voltage without being connected to the high voltage. Pins 8 and 5 are NOT connected to pins 2 and 4 in any way. They are two separate entities. However, the coil can control the switch without touching it. ( tell me if im confusing, i tried to make it simple, i think   :P lol )
Question #2: A relay can be given + or - on either pin. You can have pin 8 be + and 5 be - or pin 5 be + and pin 8 be -. Those are the only two setups possible for a relay to work. The diode in parallel will prevent backlash from the electromagnetic coils (i think) and will protect the microcontroller.
A diode blocks positive voltage on the black side of it. This means that positive voltage cannot flowthrough the black part of it. However negative voltage can, so this makes your relay be triggered from only one setup and not the other. This can be useful in R/C.
Hope I helped...

,Eric
Title: Re: Beginner question : Connecting relay
Post by: HDL_CinC_Dragon on August 29, 2007, 06:58:45 AM
Hate to just randomly step in here but damn airman, that helped me too and I wasnt even looking for that info lol



We need a Kudos system on here heh
Title: Re: Beginner question : Connecting relay
Post by: h3ro on August 29, 2007, 09:05:55 AM
Thank you for you great help Airman00, but I still manged to do something wrong.

Here is my circuit:
(http://img460.imageshack.us/img460/9885/bilde01jc8.jpg)

The LED does work, and I have tried turning the Diode around. Still dont work.

Does someone have some good ways of solider the relay to the board? I am having big trouble with it, as the legs of the relay is to short to go fully through the holes in the board.
Title: Re: Beginner question : Connecting relay
Post by: Ro-Bot-X on August 29, 2007, 12:51:13 PM
Man, you're doing something wrong there...
Take a look at this pdf document, it explains pretty well how relays should be connected to any microcontroller.
http://www.kronosrobotics.com/Anotes/Relays.pdf (http://www.kronosrobotics.com/Anotes/Relays.pdf)
Title: Re: Beginner question : Connecting relay
Post by: h3ro on August 29, 2007, 01:56:08 PM
Thank you for the link.

I think the major problem I have is that the relay needs 5V to work, but my circuit only provides somewhere between 3 and 5V.
The relay has now been replaced with a simple transistor which works great.
Title: Re: Beginner question : Connecting relay
Post by: Ro-Bot-X on August 29, 2007, 02:00:01 PM
it should work if you don't put anything in series with the relay. just connect it between one microcontroller pin and ground. make sure you connect the diode in parralel with the relay, but with the cathode to the microcontroller's pin instead to the ground like you would have put it regularly.
Title: Re: Beginner question : Connecting relay
Post by: h3ro on August 29, 2007, 02:10:09 PM
So it should be:
    Micro controller --> relay --> diode
instead of:
    Micro controller --> relay
                               diode

Right?

I tried to do it without a diode at all, but it would still not work. Im probably doing something really stupid with the relay.

In order to make my small project work I need to have 4 switches, but when I got my parts I only got 3 relays(ordered 4) so I will be using the transistors for this project (Have a lot of them, and they are really cheap.) Or is it bad to use transistors as switches?
Title: Re: Beginner question : Connecting relay
Post by: Ro-Bot-X on August 29, 2007, 02:17:18 PM
it all depends on the power that goes through the transistor

but the relay schematic should be like this:

(micro)----+---(relay)---+----(ground)
                |                 |
                +----|<|-----+
                   diode
Title: Re: Beginner question : Connecting relay
Post by: h3ro on August 30, 2007, 10:07:45 AM
Ok, the problem was that my circuit does not deliver the 5V needed to trigger my relay. Needless to say, if feel kind of stupid now.

I connected an extra battery which get triggered by a transistor, not sure if its safe/smart. But it works.

Next step is to try to create the 50$ robot :)