Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: singalls on April 21, 2009, 12:48:59 PM

Title: Newbie Relay question
Post by: singalls on April 21, 2009, 12:48:59 PM
I have a stamp board.  Regulated 5V can source 20mA.  My question is this.  I have a reed relay that is 12V.  The coil resistance is 1050.  That would pass a current of about 12mA.  If that relay is using an external 12V supply do I need a resistor to run this relay?

Thanks
Title: Re: Newbie Relay question
Post by: GearMotion on April 21, 2009, 02:39:31 PM
You should run the relay with a driver chip or a transistor.

Read this page:
http://www.usbmicro.com/odn/documents/82DC3CF22AC515D2B6FB34CCEC885E0C64426E8F.html (http://www.usbmicro.com/odn/documents/82DC3CF22AC515D2B6FB34CCEC885E0C64426E8F.html)

There are other things on that page that don't relate to what you want to do, but the first schematic shows using a ULN2803 to drive a relay. The 0V and 5V output of your stamp controls the ULN2803, which then can drive the relay (which can be powered from 12V).

I hope that helps you.
Title: Re: Newbie Relay question
Post by: Soeren on April 21, 2009, 03:05:23 PM
Hi,

[...] I have a reed relay that is 12V.  The coil resistance is 1050.  That would pass a current of about 12mA.  If that relay is using an external 12V supply do I need a resistor to run this relay?
No, but you need a transistor in between the Stamp and the relay and you should use a resistor (~5..10kOhm) between the I/O-pin of the Stamp and the base (gate, if using a MOSFET) of the NPN-transistor.
The relay goes between the collector and +12V and should have a diode in anti-parallel (an 1N4148, 1N914 or equivalent would be your best choice).
Title: Re: Newbie Relay question
Post by: Razor Concepts on April 21, 2009, 03:32:09 PM
This image helped me:
(http://www.rentron.com/PicBasic/relay-circuit.gif)
Title: Re: Newbie Relay question
Post by: singalls on April 21, 2009, 03:35:22 PM
Thank you for all the information.  Is the reason that I need a transistor is because the stamp cant generate the 12v for the relay even though the relay is connected to an external 12V battery?

Thanks
Title: Re: Newbie Relay question
Post by: Soeren on April 21, 2009, 04:06:29 PM
Hi,

Is the reason that I need a transistor is because the stamp cant generate the 12v for the relay even though the relay is connected to an external 12V battery?
No, it is because you would fry your Stamp if you connected it directly.
Generating 12V isn't needed (the 12V supply is allready there), the transistor merely acts as a switch, completing the circuit through the relay when the transistor gets the needed base current (by the stamp delivering +5V through the resistor to the base).
Title: Re: Newbie Relay question
Post by: SmAsH on April 21, 2009, 04:33:55 PM
its just so your mcu doesn't have to source as much current risking frying the pin. so instead of the pin having to turn on a big relay it gives a transistor the command and lets it do all the work.
Title: Re: Newbie Relay question
Post by: singalls on April 21, 2009, 07:39:51 PM
So it doesnt matter that the stamp only needs to source 12mA to the relay?

Thanks
Title: Re: Newbie Relay question
Post by: Soeren on April 22, 2009, 04:08:11 PM
Hi,

It's all about voltage here, the current is too low to matter at all
Title: Re: Newbie Relay question
Post by: singalls on April 22, 2009, 04:34:43 PM
I apologize if i do not understand.  Can you please explain how the voltage would effect the board.  I am just trying to learn this.  I thought if I only have to supply the relay with the 11mA (at 5V) and the relay is connected to an external 12V that it should not affect the stamp.

Thanks
Title: Re: Newbie Relay question
Post by: SmAsH on April 22, 2009, 05:48:26 PM
you are correct, where'd you hear that from?
Title: Re: Newbie Relay question
Post by: singalls on April 22, 2009, 05:58:09 PM
I did not hear it anywhere.  I read the following link and applied that to the stamp.

http://www.kpsec.freeuk.com/components/relay.htm (http://www.kpsec.freeuk.com/components/relay.htm)

Thanks.
Title: Re: Newbie Relay question
Post by: SmAsH on April 22, 2009, 06:02:35 PM
nope, that wouldnt really have any effect on your stamp. maybe a little noise but still nothing.
Title: Re: Newbie Relay question
Post by: singalls on April 22, 2009, 06:09:06 PM
So, in a nutshell, i could hook the relay up with an external 12v supply, add a resistor to a pin, set the pin to high and i should not have any problem with it frying the stamp?

Steve
Title: Re: Newbie Relay question
Post by: SmAsH on April 22, 2009, 06:21:09 PM
eeee, you may want a diode in between the pin and relay as the relay when it turns on can send some power back at you. do it like the schematic you posted earlier.
Title: Re: Newbie Relay question
Post by: GearMotion on April 22, 2009, 07:20:52 PM
So, in a nutshell, i could hook the relay up with an external 12v supply, add a resistor to a pin, set the pin to high and i should not have any problem with it frying the stamp?

I would not recommend this at all. Use a resistor and transistor to control the relay, just like in the diagram.
Title: Re: Newbie Relay question
Post by: singalls on April 22, 2009, 07:24:56 PM
Again, thanks for the replys.  As I said, I am new to this and reading up on it.  GearMotion, why would you recommend against this?

Steve
Title: Re: Newbie Relay question
Post by: GearMotion on April 22, 2009, 07:35:26 PM
Look at it this way:

You have a relay that wants 12V across it to be activated. If you just connected it to a 12V battery, it would have 12V across it and be activated.

If you have 12V on one side of the relay, and 5V on the other, what do you have across the relay? 7V? (Assuming that the ground for 5V and 12V are at the same potential.) Would it be activated? When the stamp pin is at 0V then the relay has 12V across it.

Now add some sort of series resistor that you apparently want in this circuit. There will be some of that 7V across the resistor, some across the relay. So less than 7V across the relay. How much? It depends on the resistor value.

---

The picture/schematic recommended above will work.
Title: Re: Newbie Relay question
Post by: SmAsH on April 22, 2009, 07:41:51 PM
now with a transistor its a basic switch, apply power to base and it lets stuff flow through Emitter and collector...i think. so instead of having your microcontroller using 5V which wont be enough, let the transistor turn on the 12V.
Title: Re: Newbie Relay question
Post by: singalls on April 22, 2009, 07:52:34 PM
GearMotion,

Thanks for the reply.  I know that the diagram that you referred to would work.  I guess I am just trying to understand why/when you would need a transistor.  Isn't it true that the relay at 12V and the stamp at 5V are seperate.  I have a stamp that is on a seperate power supply than the relay.  So at 5V regulated the stamp can put out 20mA.  So, knowing that, WHY would I need a transistor when the relay only needs ~11mA across the coil?  Again 5V/1050= ~11mA.

Steve
Title: Re: Newbie Relay question
Post by: GearMotion on April 22, 2009, 07:56:12 PM
Singalls:

I doctored the image with orange text since people have mentioned the terms BASE, EMITTER, and COLLECTOR. Image posted below.

Think of the path from the collector to emitter as being a switch controlled by the base. 0V from the stamp on the base and the switch is off. 5V from the stamp at the base and the switch is on.

(There is a voltage between collector and emitter, so it isn't close to 0 ohm like a switch, but for this purpose you can think of it as such.)
Title: Re: Newbie Relay question
Post by: singalls on April 22, 2009, 08:02:44 PM
GearMotion,

Again thanks for the reply.  I do know how a transistor works.  My base question is with the info that I gave about the relay, 12V, 1050 resistance coil, WHY would I need a transistor?

Steve
Title: Re: Newbie Relay question
Post by: GearMotion on April 22, 2009, 08:04:50 PM
GearMotion,

Thanks for the reply.  I know that the diagram that you referred to would work.  I guess I am just trying to understand why/when you would need a transistor.  Isn't it true that the relay at 12V and the stamp at 5V are seperate.  I have a stamp that is on a seperate power supply than the relay.  So at 5V regulated the stamp can put out 20mA.  So, knowing that, WHY would I need a transistor when the relay only needs ~11mA across the coil?  Again 5V/1050= ~11mA.

It is the nature of voltage and current. You are not "putting current into" something. The something decides how much current it will draw. You also can't put 12V to one end of the relay from one power supply and 5V from your stamp if the supplies are separate - no common ground.

You say the relay is 12V and 1050 ohms. 11 mA of current flows through the relay when activated. With 5V on one end, 12V on the other (assuming common grounds) 7V across the relay results in 6 mA. This may or may not be enough to activate the relay.


You ask when a transistor should be used? When you need to deal with voltage levels harmful to the stamp is one time to use a transistor.
Title: Re: Newbie Relay question
Post by: Pratheek on April 23, 2009, 08:51:46 AM
My base question is with the info that I gave about the relay, 12V, 1050 resistance coil, WHY would I need a transistor?
Steve, the stamp works at 5V, so when the output of its pin is high, it will provide 5V. But since the relay you are using is rated at 12V, it will not work at 5V.
So you will need a transistor, which will act as a switch, to operate the relay. The transistor accepts the input , which is at 5V and switches the relay  on or off based on the input. The transistor provides the high voltage(12V) that your relay needs but it is controlled by the smaller voltage(5V).

Title: Re: Newbie Relay question
Post by: Soeren on April 23, 2009, 10:00:55 AM
Hi,

Well, to cut a long story (somewhat) short...

I mentioned that the current in this case is too low to be worried over, but the voltage is a problem.
You say you don't believe me because you have read otherwise, but both the site you linked to and several posts here gives you a wrong impression.
I'll state it again... You WILL render your controller dead and useless if you hook an I/O-line to +12V through a relay and that's what you seemingly intend to do.

I'll give you the correct technical explanation then. I fear you won't really understand it anyway, but I'm sort of running out of magic trickery to get you to understand it ;)

Consider your controllers I/O-pin a Thévenin source of 5V with an internal resistance of around 250 Ohm (probably a bit higher, but this will do for an explanation) and consider the supply another Thévenin source of 12V with an internal resistance of ~1 kOhm (mainly the relay).
Now connect the two and calculate what happens to the 5V source.
The roughly 6.5V will be more than your controller can handle and that's before it has even tried to trigger the relay.

You have two options:
1 - Trust me and save your Stamp.
2 - Go your own way, then buy a new Stamp and return to follow point 1.

Electronics is an engineering discipline and we use mathematical "tools" for most of the work. Statements like "a transistor is a switch" is a great proof that the one answering you haven't even got the basics down on the simplest active component in existence, so you might not wanna take everything from that direction as Gospel...
My "religion" is exact knowledge and what follows from that, but you decide which "religion" you will follow of course.


Btw. If you need my background for evaluating my posts: I'm not a 12 year old kid who thinks building 2-wheeled mini-'bots of others design gives me street cred, but a seasoned electronics engineer who actually designs 'bots (and other stuff).
Title: Re: Newbie Relay question
Post by: GearMotion on April 23, 2009, 10:14:57 AM
Electronics is an engineering discipline and we use mathematical "tools" for most of the work. Statements like "a transistor is a switch" is a great proof that the one answering you haven't even got the basics down on the simplest active component in existence, so you might not wanna take everything from that direction as Gospel...
My "religion" is exact knowledge and what follows from that, but you decide which "religion" you will follow of course.


Btw. If you need my background for evaluating my posts: I'm not a 12 year old kid who thinks building 2-wheeled mini-'bots of others design gives me street cred, but a seasoned electronics engineer who actually designs 'bots (and other stuff).


This board has a _lot_ of beginners on it. People that are hoping for a little kind help. You are a seasoned engineer that talks down to people that are hoping for a little guidance . That is too bad. I myself hope to help and if my help doesn't involve being condescending to others then I feel OK with the help I give. Directly insulting a 12 year old ISN'T engineering, ISN'T helpful - it is just being mean.
Title: Re: Newbie Relay question
Post by: singalls on April 23, 2009, 11:15:32 AM
Soeren,

Thank you for the information.  Don't fear that I won't understand it.  I did.  I actually got that information the other day.  Also, I am not a 12 year old kid.  i am a programmer that wanted to venture into other areas.  So, again, thanks for your help.

GearMotion,

I certainly want to thank you also.  I also agree with your statement.  I would say it is not mean, but it is definitely rude.


Steve
Title: Re: Newbie Relay question
Post by: Soeren on April 23, 2009, 03:19:59 PM
Hi,

Thank you for the information.  Don't fear that I won't understand it.  I did.  I actually got that information the other day.  Also, I am not a 12 year old kid.  i am a programmer that wanted to venture into other areas.  So, again, thanks for your help.
Glad you got it.
I never thought that _you_ was 12 years old, but a lot of people here _is_, which doesn't prevent some of them from sometime presenting pure nonsense as it was the sacred truth (which in my opinion is a cardinal sin, since it has a tendency to spread - the Memory Myth [which pops up around the net and sadly even among a few old hand engineers] is a very good example on that). I see this a bit to often to just ignore it.

One day, some guy is building or repairing a crucial component/board in a plane that you, I or a lot of other people are aboard (or a lift, a high speed train or whatever).
Would you rather that he was filled with bogus but clinging nonsense throughout his forming years or that those filling him got the whip every now and then?
You can't make an omelet without sacrificing a few eggs.


GearMotion <- I wrote you an answer the other day (in another thread) but it was removed the next day, just like the "snip"-signs in the post you got ticked off about was removed (still, your post was a few up from that so I don't get it, unless you're new to writing on the net?).
I'm a Dane and as such, strongly opposed to censorship, so please don't blame me for that, blame the censurer, not the censored.