### Author Topic: Beginner question : Connecting relay  (Read 2552 times)

0 Members and 1 Guest are viewing this topic.

#### h3ro

• Full Member
• Posts: 110
##### Beginner question : Connecting relay
« 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)?

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)?

Sorry for all the stupid questions I have, but I really want to learn this. Im thinking of getting a book

#### airman00

• Contest Winner
• Supreme Robot
• Posts: 3,653
• narobo.com
##### Re: Beginner question : Connecting relay
« Reply #1 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    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
Check out the Roboduino, Arduino-compatible board!

www.Narobo.com

#### HDL_CinC_Dragon

• Supreme Robot
• Posts: 1,261
##### Re: Beginner question : Connecting relay
« Reply #2 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
United States Marine Corps
Infantry
Returns to society: 2014JAN11

#### h3ro

• Full Member
• Posts: 110
##### Re: Beginner question : Connecting relay
« Reply #3 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:

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.
« Last Edit: August 29, 2007, 10:53:05 AM by h3ro »

#### Ro-Bot-X

• Contest Winner
• Supreme Robot
• Posts: 1,431
• Store: RoBotXDesigns.ca
##### Re: Beginner question : Connecting relay
« Reply #4 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
Check out the uBotino robot controller!

#### h3ro

• Full Member
• Posts: 110
##### Re: Beginner question : Connecting relay
« Reply #5 on: August 29, 2007, 01:56:08 PM »

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.

#### Ro-Bot-X

• Contest Winner
• Supreme Robot
• Posts: 1,431
• Store: RoBotXDesigns.ca
##### Re: Beginner question : Connecting relay
« Reply #6 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.
Check out the uBotino robot controller!

#### h3ro

• Full Member
• Posts: 110
##### Re: Beginner question : Connecting relay
« Reply #7 on: August 29, 2007, 02:10:09 PM »
So it should be:
Micro controller --> relay --> diode
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?

#### Ro-Bot-X

• Contest Winner
• Supreme Robot
• Posts: 1,431
• Store: RoBotXDesigns.ca
##### Re: Beginner question : Connecting relay
« Reply #8 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
Check out the uBotino robot controller!

#### h3ro

• Full Member
• Posts: 110
##### Re: Beginner question : Connecting relay
« Reply #9 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
« Last Edit: August 30, 2007, 10:09:24 AM by h3ro »