Pages: [1] 2   Go Down
Author Topic: Controlling a relay  (Read 16414 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi everyone

Beware, I'm a newbie.

I can't find any tutorials on how to control a simple relay from the Arduino. I've got LED's blinking and input running, but getting control of my 9V relay seems difficult.

Thanks
Carl Emil
Logged

Daniel
Guest
 Bigger Bigger  Smaller Smaller  Reset Reset

as far as I know, ther is no complete tutorial yet, but here is the schematic, which is posted in the Playground:
http://www.arduino.cc/playground/uploads/Learning/relays.pdf

You can use the same code as you would use for driving an LED. Instead of connecting an LED and to the Arduino, you would connect the resistor and GND, as shown in the diagram.
 
« Last Edit: January 28, 2007, 11:24:13 pm by Daniel » Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 76
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi,


this diagram is great, thanks. i think it's shown me that i was trying to do this the wrong way. i was assuming that you could control the relay directly as if it were an LED or something, which seems to sort of work. can anyone tell me what the transistor and rectifier actually do?


Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Uph! I forgot to return to this thread. Thanks for the diagram, it's all I need =)
Carl Emil
Logged

Daniel
Guest
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
hi,


this diagram is great, thanks. i think it's shown me that i was trying to do this the wrong way. i was assuming that you could control the relay directly as if it were an LED or something, which seems to sort of work. can anyone tell me what the transistor and rectifier actually do?




the Arduino can source about 20 millimaps of current through a pin.. a relay typically takes 100-300ma. So the transistor is there to amplify the signal from the Arduino to the current level required by the relay. Try googling "transistor amplifier theory", or "NPN Switch"  if you want to know more.  

D
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 76
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks a lot. That's a huge help. I know it's not your job to explain electronics 101 to me, and I really appreciate it.
Logged

Daniel
Guest
 Bigger Bigger  Smaller Smaller  Reset Reset

hey

no sweat. Try getting a copy of the ARRL Handbook, it has terrific explanations of basic electronic theory.
D
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I wish there was a step-by-step picture walkthrough for retards. I can't seem to get this circuit to work... and i'm afraid i'm building it wrong. I've somehow managed to burn out three transistors now, and i can't tell what i'm doing wrong.

I feel retarded, if it's any consolation.
Logged

Bristol, UK
Offline Offline
Edison Member
*
Karma: 1
Posts: 1197
Exhibitor at UK Maker Faire
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Could you say a bit more about how you're building the circuit?  What transistor, what relay, what voltages?  I'm just trying to get to the bottom of why it's not working for you, 'cos I'd really like to hear that it's working!
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, I duplicated someone else's design exactly. I'm a programmer really and this particular project is way out of my territory.
]

This is my relay:
http://pewa.panasonic.com/pcsd/product/pwr/pdf/mech_eng_jtn.pdf

Right now I just want to see if it works in the first place. I think I might have a dead one. I connected the two close pin to ground and 5V. I set an old meter to ohms and it spikes over to 0 when you touch those two terminals, so they are definitely the coil. I small tick can be felt when you connect it to the 5V.

So I assume the circuit is closed on the other side no? Apparently, wrong. the same setting on that meter doesn't spike when touching the other two, ever. Basically, I can't get my relay to close a circuit period. I also tried plugging it up to 3 AA's... wish I had a 9V sitting around.

Grrr, I wish I was 200 miles away at my state college, because I could probably ask anyone there to explain it and have a 50/50 chance of them working it out for me smiley-razz

Tomorrow or whenever I find a camera i'll just take a picture of it, it's embarrassingly simple.. so it should work... But I think tomorrow i'll try a new relay too. I didn't think relays ever got stuck open


Logged

STOCKHOLM
Offline Offline
Newbie
*
Karma: 0
Posts: 31
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well,
This is a simple fault searching method, sorry if it is to basic.
1 Locate the article number on the relay - confirm that it ends with 5V DC

2 Locate the coil terminals on the relay
3 Measure the coil resistance - according to your data sheet shall it be 31ohms +/- 10%
4 connect the power supply to the realy and confirm that it clicks
5 if it does not click - reverse the power supply and try again.
6 Here would I normally give up and get another relay
If you are really serious can you measure the current through the coil. Another option is to increase the realy voltage.

It is very possible that the relay contacts can have been welded together if you got this as a surplus relay. Then should you also get a new one

Magnus
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 626
Posts: 34122
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If you want to know about how a transistor works try the first part of this article. After that it gets a bit heavy:-
http://www.thebox.myzen.co.uk/Hardware/Transistor_Tester.html

Then as an encore look at the relay at the end of this:-
http://www.thebox.myzen.co.uk/Tutorial/Power_Supplies.html
it is basically the same as the schematic linked before but there are some words of explanation with it.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I do have a 12v DC relay here that I know is good, but... no 5v. How would I switch it>? How CAN I switch it? I have not been able to get any of these relays to "click"
Logged

Bristol, UK
Offline Offline
Edison Member
*
Karma: 1
Posts: 1197
Exhibitor at UK Maker Faire
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I have not been able to get any of these relays to "click"

You've tried multiple relays?  And none of them will "click"?  Hmmm...  Makes me wonder if something else is wrong, like trouble with your power source.  Or even a dud piece of wire somewhere that's making all your tests fail!

You should be able to take a battery, some wires, and a relay, and get a small but audible "click" when you connect power to the coil.  You may see a small spark when you disconnect the battery, too.

Can you describe your setup for us, a little more clearly?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 17
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I made this Instructable probalby it solves your probelm:
http://www.instructables.com/id/Connecting_a_12V_Relay_to_Arduino/

greetz Daniel
Logged

Pages: [1] 2   Go Up
Jump to: