turning on relay from 5v signal - Page 2

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Re: turning on relay from 5v signal



Quoted text here. Click to load it

If it is what I suspect, then it will not supply any current. A
typical open collector is usefull only for sinking current.

Quoted text here. Click to load it


I am begining to think you have a lot more problems than you think,
and I beleive that the origonal circuit you have may not fit the
problem you describe.

I am assuming that the output of your micro is is an open collector
transistor that has its emitter internally tied to ground? If so, can
you read the datasheet and tell us how much current the output pin can
sink? Can you also tell us how much current the relay draws?




Quoted text here. Click to load it

If you have an open collector output that has the emitter internally
grounded then you are better of using a PNP transistor.

Quoted text here. Click to load it

I doubt that you will need a uln2003, unless you are driving
solenoids.

Re: turning on relay from 5v signal


Quoted text here. Click to load it

It has an internal pullup, although I could just as easily use a pin that
doesn't have the pullup.

Quoted text here. Click to load it

It looks like the CPU pins can sink 3.2mA. I measured the relay at 120mA.

Quoted text here. Click to load it

I tried that and it worked but there was a voltage drop of approx 3V and the
relay didn't give such a positive click at 9V.

Michael



Re: turning on relay from 5v signal



Quoted text here. Click to load it

plenty of current :)


Quoted text here. Click to load it

Lower the current limiting resistor at the base of the transistor.

Re: turning on relay from 5v signal


On Wed, 16 Nov 2005 19:50:56 +1000, The Real Andy

Quoted text here. Click to load it

Actually, dont do that just yet. Start using a PNP transistor first.
Se my other post.


Re: turning on relay from 5v signal



Quoted text here. Click to load it
This is getting far too complicated for such a simple problem.

You can use either the two transistor (and two resistor) per relay
method or try the ULN2003 (plus two resistors per relay driven).
Either solution will work, just depends on how much space you
have/what takes your fancy/etc.

Alan

--
++++++++++++++++++++++++++++++++++++++++++
Jenal Communications
We've slightly trimmed the long signature. Click to see the full one.
Re: turning on relay from 5v signal


Quoted text here. Click to load it

I think I've dropped the idea of uln2003 because the cost will be higher and
it still needs 6 resistors anyway. I gave it a try and it has about a 0.8v
drop where the transistors had a 0.2v drop. Unless the real andy can find
anything wrong I'll go with the transistors. Thanks for all your help, it is
much appreciated :-)

Michael



Re: turning on relay from 5v signal



Quoted text here. Click to load it
I se transistors or ULN2003/2803 depending on the number of circuits
(relays,etc) I need to drive.  

You have the additional unfortunate problem of not being able to
source drive current out of your micro.  No big deal - just needs a
few more components (another transistor and resistor) to get what you
want.

The pnp idea won't work in your case because the base of the
transistor (ie the micro output) can only go between 0v and (probably)
one diode volt drop above the micro power supply (I guess +5v) that is
assuming the micro has built-in I/O protection diodes.

I'd say stick with the two transistors and two resistors. It's easy,
cheap and doesn't really take up much room plus it works!

Alan

--
++++++++++++++++++++++++++++++++++++++++++
Jenal Communications
We've slightly trimmed the long signature. Click to see the full one.
Re: turning on relay from 5v signal



Quoted text here. Click to load it

You dont know what you are talking about. The micro will be barely
able to source any current. IT is designed to sink current.

Quoted text here. Click to load it

You dont know what you are talking about. The output does not go
anywhere. When the output is diven into its active state, the uC's
output transistor will conduct. Most micro's which supply an open
collector/drain have the emitter/source internally tied to ground.
This means that when the output is active (active low) then the
saturated output transister is essentially at ground potential plus
the small collector-emmiter voltage.

So if you decide to use a PNP then all you must do is put the relay
between the collector and ground, and connect the emitter to 12Volts.
The circuit is essentially reversed.


Quoted text here. Click to load it

2 transistors will only be needed if there is insufficient gain with
the transistor being used. You cannot design an good circuit without
some basic understanding of what is going on. I doubt very much that
modern transistor will have such little gain that a darlington is
required. This would only be required if the OP wants to switch a
large current.

Quoted text here. Click to load it


I just went searching for a good web page and found this.

http://www1.jaycar.com.au/images_uploaded/relaydrv.pdf

Use the PNP circuit, this is what fits you application. This is a very
brief description and is not entirely correct, but i should help the
OP to understand.


To drive the relay on, set the port pin to its active state, in your
case I am assuming that this will be '0'. Use the internal pullup,
whose sole purpose in life is to keep the output in a known state when
your output is not in its active state.

Re: turning on relay from 5v signal


On Wed, 16 Nov 2005 20:33:42 +1000, The Real Andy

Quoted text here. Click to load it

Very kind of you to point out that I don't know what I'm talking
about, I just didn't realise that - I guess I should bow to your
superiority complex.

Read what I said - quote - "You have the additional unfortunate
problem of NOT being able to source drive current out of your micro".
Quoted text here. Click to load it

You cannot do this because the base will not go up to +12v when the
micro output is "off" IF there are protection diodes on the I/O pin.
Quoted text here. Click to load it
The two transistors are not to give enough gain, they are to give a
double inversion and drive a relay - nowhere did I mention using two
transistors as a darlington - look at the description of how they
should be wired - coll 1 to base 2 - not emitter 1 to base 2.  The
only close mention of darlingtons were the ULN2003/2803 which where
discussed - however the OP would still need to use two sections of
these to reach his objective!

Quoted text here. Click to load it

You might actually read that pdf yourself and learn something.  It
states (4th para right hand side) that the circuit needs +12 to switch
the relay off and 0v to switch it on.  In actual fact it will need
only need a slightly lower than 12v signal to switch in on but we
won't discuss that here it might get too confusing for some.

I think before you anything else you should reread the whole of this
thread to see what the OPs problems were/are and what has been
suggested.

Meanwhile I'll just go back to designing things I know nothing
about...
Alan


--
++++++++++++++++++++++++++++++++++++++++++
Jenal Communications
We've slightly trimmed the long signature. Click to see the full one.
Re: turning on relay from 5v signal



Quoted text here. Click to load it

And this is a problem how?

Quoted text here. Click to load it

Double inversion ey?

Quoted text here. Click to load it

An there I am thinking that by controlling the base current through
bipolar transistors would control the collector current. Oh how silly
of me. I guess all my physics books are wrong, not to mention all
those application notes that I have for my old CMOS and TTL logic.

Quoted text here. Click to load it

I have read the posts.


Quoted text here. Click to load it

Good idea.

Re: turning on relay from 5v signal


Quoted text here. Click to load it

what causes that? I'd have expected the opposite.

Quoted text here. Click to load it


He measured ~0.7V on the ouput driving that 2k2 and the transistoor base
in serries.

it seems that his outputs are essentially  open collector.






Quoted text here. Click to load it


--

Bye.
   Jasen

Re: turning on relay from 5v signal


On Wed, 16 Nov 2005 05:51:23 -0000, Jasen Betts

Quoted text here. Click to load it

Inrush current is common with inductive loads. As the relays coil is
energises, it draws a large amount of current until it becomes
saturated with magnetic flux. When you pull the power, the magnetic
flux collapses and induces a current in the coil, called back EMF. The
reason the OP has a diode in the circuit is to suppress this back EMF.


Quoted text here. Click to load it

More to the point, it seems that the output transistor is internally
tied to ground, so the OP should really use a PNP transistor to drive
the circuit. An NPN will be fine if it has enough gain, as all the
current is being sourced from the internal pullup resistor. The
internal pullups are normally quite a high value, so only a very small
amount of current can be sourced through them.

If you were to use a large external pullup to souce more current, you
would have to be carefull that when you turn on the uC's transistor,
that it does not sink to much current through the external pullup.

Understanding that there is not enough current via the internal
resistor, the OP is experiencing a problem where the transistor is not
being driven into saturation. More gain will fix this, however it is
better to implement a proper design in the first place rather than
making a flawed design work.

Re: turning on relay from 5v signal


Quoted text here. Click to load it



cpus also work with extremely low currents.

if you want low current compared to the CPU (ie. high resistance)
you need to use a MOSFET...

--

Bye.
   Jasen

Re: turning on relay from 5v signal


Quoted text here. Click to load it


the above circuit is for where the microcontroller
can actually drive the pin positive sourcing atleast 2.5ma. if you've
only got the internal pullup it's unlikely to work.

what's the processor you're using? I used a very similar circuit with an
Atmel AVR 2313 (except I used 1K resistors), it worked fine.

with the AVR you need to put the pin in output mode (by setting the
apropriate data-direction register bit) AIUI other microcontrollers
behave  similarly.  The pull-up is intended for when you use the pin
as an input.

Alternately you could try this:

          o-----------o----o----- +12V
          |           |    |
          |          ---  ---
          |           ^   | |
          \  1N4001  / \  | | Relay coil
          /          ---  ---
      1K5 \           |    |
          /           -----o
          \                |
          |               /
      IN  |             |/
       ---o--\/\/\/-----|
             860R       |\   Misc. NPN
                         _V|
                           |
                           |
                         --o-- GND

Which should work where the output can sink about 10Ma ant the 12V is really 12V

Bye.
   Jasen

Re: turning on relay from 5v signal


Quoted text here. Click to load it

I used an external pullup as Alan suggested and it worked quite well.
Basically I did pretty much what you suggested in your diagram except
connected the pullup to 5v instead of 12.

Quoted text here. Click to load it

It's an 8051, specifically the phillips p89c668hba but I'll probably use the
atmel AT89C2051 when I get a board made for it.

Quoted text here. Click to load it

I've only got 2 options, I can set the pin at either 0 or 1 and it can be
used as an input or output. Some pins have internal pullups and some don't
but the one I'm using does. How a pin could only have 2 states and be used
for both input and output had me confused literally for weeks when I first
started using the 8051 a few years ago. :-)

Michael



Re: turning on relay from 5v signal


Quoted text here. Click to load it

I'm sure the atmel 89C series is different to the atmel 90S series
but did I hear that you have it working using two transistors?

Quoted text here. Click to load it


:) as i understand it a similar trick is done with PC parallel ports to use
the data pins as inputs.

Bye.
   Jasen

Site Timeline