turning on relay from 5v signal

M

Michael C

Guest
I asked how can I turn on a 12V relay from a ttl signal before and I got the
circuit below as a response. I tested it and it works fine but unfortunately
I tested it by supplying 12V into the 2.2k resistor. Now when I've connected
it to my little cpu it doesn't work. When I switch on the appropriate pin it
can only muster .67 of a volt. The pin has an internal pullup and does
switch from 0 to 5V without the transistor connected. Did I get the wrong
transisitor or something? It's a BC338 from jaycar. I dunno what these
figures mean but in the catalog it says "Diss @25C 500mW, Vcb 30V, Ic 800mA
Hfe 100, Hfe Bias 100mA"

Many thanks yet again
Michael



o----o----- +12V
| |
--- ---
^ | |
1N4001 / \ | | Relay coil
--- ---
| |
-----o
|
/
IN |/
----\/\/\/-----|
2K2 |\ Misc. NPN
-V|
|
|
--o-- GND
 
On Sat, 12 Nov 2005 13:36:50 +1100, "Michael C" <nospam@nospam.com>
wrote:

I asked how can I turn on a 12V relay from a ttl signal before and I got the
circuit below as a response. I tested it and it works fine but unfortunately
I tested it by supplying 12V into the 2.2k resistor. Now when I've connected
it to my little cpu it doesn't work. When I switch on the appropriate pin it
can only muster .67 of a volt. The pin has an internal pullup and does
switch from 0 to 5V without the transistor connected. Did I get the wrong
transisitor or something? It's a BC338 from jaycar. I dunno what these
figures mean but in the catalog it says "Diss @25C 500mW, Vcb 30V, Ic 800mA
Hfe 100, Hfe Bias 100mA"

Many thanks yet again
Michael



o----o----- +12V
| |
--- ---
^ | |
1N4001 / \ | | Relay coil
--- ---
| |
-----o
|
/
IN |/
----\/\/\/-----|
2K2 |\ Misc. NPN
-V|
|
|
--o-- GND

Change you cpu output to push-pull instead of open collector(drain)
and it should work ok

Alan

--
++++++++++++++++++++++++++++++++++++++++++
Jenal Communications
Manufacturers and Suppliers of HF Selcall
P O Box 1108, Morley, Western Australia
Tel: +61 8 9370 5533 Fax +61 8 9467 6146
Web Site: http://www.jenal.com
Contact: http://www.jenal.com/?p=1
++++++++++++++++++++++++++++++++++++++++++
 
"Alan" <me@somewhere.com.au.invalid> wrote in message
news:c8man1hjv5vvm8bgbtv2vf76fc14c4onvq@4ax.com...
Change you cpu output to push-pull instead of open collector(drain)
and it should work ok
Do you mean pull it up to 5v with an external resistor?

Michael
 
On Sat, 12 Nov 2005 14:07:58 +1100, "Michael C" <nospam@nospam.com>
wrote:

"Alan" <me@somewhere.com.au.invalid> wrote in message
news:c8man1hjv5vvm8bgbtv2vf76fc14c4onvq@4ax.com...
Change you cpu output to push-pull instead of open collector(drain)
and it should work ok

Do you mean pull it up to 5v with an external resistor?

Michael

You could do - use another 2k2 or 1k0 to +5v from the output of the
cpu.

But you should be able to programme the cpu (normally) for push-pull
output. ie it will either sink (low output) or supply (high output)
current. If you cannot change the programming of the cpu then the
additionla resistor is probably the easiest (only) option for you.

Alan

--
++++++++++++++++++++++++++++++++++++++++++
Jenal Communications
Manufacturers and Suppliers of HF Selcall
P O Box 1108, Morley, Western Australia
Tel: +61 8 9370 5533 Fax +61 8 9467 6146
Web Site: http://www.jenal.com
Contact: http://www.jenal.com/?p=1
++++++++++++++++++++++++++++++++++++++++++
 
"Alan" <me@somewhere.com.au.invalid> wrote in message
news:a8oan1lv662ilo23qtv2ap1vfmgorlipod@4ax.com...
But you should be able to programme the cpu (normally) for push-pull
output. ie it will either sink (low output) or supply (high output)
current. If you cannot change the programming of the cpu then the
additionla resistor is probably the easiest (only) option for you.
Thanks for the reply. As far as I can tell the pins cannot be changed. It's
an 8051 and some pins are either open drain or have pull ups. All you can do
is set the pins to either a 1 or a 0 i think. What you suggested did work,
using a 2k resistor (because I didn't have a 1k here). I was under the
impression that the transistor would use an extrememly low current but I
guess that's not the case? Even with a 2k pullup + the internal pullup it
still only managed 3volts. I have one problem now that all the relays switch
on during the reset stage at startup, is there any way to avoid that?

Cheers,
Michael
 
On Sat, 12 Nov 2005 16:06:13 +1100, "Michael C" <nospam@nospam.com>
wrote:

"Alan" <me@somewhere.com.au.invalid> wrote in message
news:a8oan1lv662ilo23qtv2ap1vfmgorlipod@4ax.com...
But you should be able to programme the cpu (normally) for push-pull
output. ie it will either sink (low output) or supply (high output)
current. If you cannot change the programming of the cpu then the
additionla resistor is probably the easiest (only) option for you.

Thanks for the reply. As far as I can tell the pins cannot be changed. It's
an 8051 and some pins are either open drain or have pull ups. All you can do
is set the pins to either a 1 or a 0 i think. What you suggested did work,
using a 2k resistor (because I didn't have a 1k here). I was under the
impression that the transistor would use an extrememly low current but I
guess that's not the case? Even with a 2k pullup + the internal pullup it
still only managed 3volts. I have one problem now that all the relays switch
on during the reset stage at startup, is there any way to avoid that?

Cheers,
Michael

Hi Michael

The 3v (measured at the micro pin) is OK. Basically you have approx
0.7v on the base of the transistor when it is turned on. That leaves
4.3 to be split accross the two 2k2 resistors. So the output pin of
the micro should be about 3v.

There will be no way (easily) to stop the relays switching on as the
micro will set it's outputs to hi/tri-state/open when it resets.

You can try two things to overcome this in your case.
1) a capacitor from the base of the transistor down to ground. This
will slightly delay the turn on and turn off of the relay. Experiment
with values to overcome the pwoer up turn on.
2) put another transistor inverter between the micro output and the
relay driver you have now and invert your output signal in the micro.
That way you need to output a low from the micro to turn the relay on.

HTH
Alan

--
++++++++++++++++++++++++++++++++++++++++++
Jenal Communications
Manufacturers and Suppliers of HF Selcall
P O Box 1108, Morley, Western Australia
Tel: +61 8 9370 5533 Fax +61 8 9467 6146
Web Site: http://www.jenal.com
Contact: http://www.jenal.com/?p=1
++++++++++++++++++++++++++++++++++++++++++
 
On Sat, 12 Nov 2005 16:06:13 +1100, "Michael C" <nospam@nospam.com> wrote:

"Alan" <me@somewhere.com.au.invalid> wrote in message
news:a8oan1lv662ilo23qtv2ap1vfmgorlipod@4ax.com...
But you should be able to programme the cpu (normally) for push-pull
output. ie it will either sink (low output) or supply (high output)
current. If you cannot change the programming of the cpu then the
additionla resistor is probably the easiest (only) option for you.

Thanks for the reply. As far as I can tell the pins cannot be changed. It's
an 8051 and some pins are either open drain or have pull ups. All you can do
is set the pins to either a 1 or a 0 i think. What you suggested did work,
using a 2k resistor (because I didn't have a 1k here). I was under the
impression that the transistor would use an extrememly low current but I
guess that's not the case? Even with a 2k pullup + the internal pullup it
still only managed 3volts. I have one problem now that all the relays switch
on during the reset stage at startup, is there any way to avoid that?

Cheers,
Michael
They turn on because the base of the transistor is being pulled high by the pullup
resistor before the micro has a chance to set the pin outputs low. Use a PNP
transistor in place of the BC338. Connect the emitter of the PNP to the diode
anode-relay junction, and the collector to ground. The base can be connected to the
pullup resistor. This method ensures that when the micro is in reset, the relays
are off, because the pullup turns the transistor off. To turn the transistor on,
set the output pin of the micro to low, to turn it off, set the output pin high.
 
"Alan" <me@somewhere.com.au.invalid> wrote in message
news:9gkdn1p2n99o580stuparb95rvcsvejmsi@4ax.com...
Did you try another inverter stage before the relay driver as I
suggested?
Initially I tried the pnp transisitor because it appeared to be much easier.
I just tried using the 2 npns and it worked perfectly, powering it all up I
don't get a peep out of the relay. I think I'll have a look at your other
suggestion as it looks like a neater solution. As these will be put together
by hand it's much easier to solder in a 16 pin chip instead of 6
transistors, 9 resistors and 3 diodes. Jaycar sells the ULN2003 so I'll try
to pick one up tomorrow. I was a bit confused about the datasheet though, do
I just connect the port pin to the input of the uln2003? The datasheet shows
some fairly complicated circuits on the input which would defeat the purpose
of using the chip. (page 11 of
http://rocky.digikey.com/WebLib/Texas%20Instruments/Web%20data/ULN2001A-4A,ULQ2003A-4A.pdf).

Thanks for all your help,
Michael
 
On Wed, 16 Nov 2005 20:33:42 +1000, The Real Andy
<will_get_back_to_you_on_This@> wrote:

On Wed, 16 Nov 2005 14:17:25 +0800, Alan <me@somewhere.com.au.invalid
wrote:

On Wed, 16 Nov 2005 16:22:00 +1100, "Michael C" <nospam@nospam.com
wrote:

"Alan" <me@somewhere.com.au.invalid> wrote in message
news:t9aln19457e8drdlnhrd29e6d4cmpvb342@4ax.com...
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.

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

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.

You dont know what you are talking about. The micro will be barely
able to source any current. IT is designed to sink current.
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".
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.

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.
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.
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!

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.


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!

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.
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
Manufacturers and Suppliers of HF Selcall
P O Box 1108, Morley, Western Australia
Tel: +61 8 9370 5533 Fax +61 8 9467 6146
Web Site: http://www.jenal.com
Contact: http://www.jenal.com/?p=1
++++++++++++++++++++++++++++++++++++++++++
 
On 2005-11-12, Michael C <nospam@nospam.com> wrote:
I asked how can I turn on a 12V relay from a ttl signal before and I got the
circuit below as a response. I tested it and it works fine but unfortunately
I tested it by supplying 12V into the 2.2k resistor. Now when I've connected
it to my little cpu it doesn't work. When I switch on the appropriate pin it
can only muster .67 of a volt. The pin has an internal pullup and does
switch from 0 to 5V without the transistor connected. Did I get the wrong
transisitor or something? It's a BC338 from jaycar. I dunno what these
figures mean but in the catalog it says "Diss @25C 500mW, Vcb 30V, Ic 800mA
Hfe 100, Hfe Bias 100mA"


o----o----- +12V
| |
--- ---
^ | |
1N4001 / \ | | Relay coil
--- ---
| |
-----o
|
/
IN |/
----\/\/\/-----|
2K2 |\ Misc. NPN
-V|
|
|
--o-- GND
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
 
On 2005-11-12, Michael C <nospam@nospam.com> wrote:
"Alan" <me@somewhere.com.au.invalid> wrote in message
news:a8oan1lv662ilo23qtv2ap1vfmgorlipod@4ax.com...
But you should be able to programme the cpu (normally) for push-pull
output. ie it will either sink (low output) or supply (high output)
current. If you cannot change the programming of the cpu then the
additionla resistor is probably the easiest (only) option for you.

Thanks for the reply. As far as I can tell the pins cannot be changed. It's
an 8051 and some pins are either open drain or have pull ups. All you can do
is set the pins to either a 1 or a 0 i think. What you suggested did work,
using a 2k resistor (because I didn't have a 1k here). I was under the
impression that the transistor would use an extrememly low current but I
guess that's not the case? Even with a 2k pullup + the internal pullup it
still only managed 3volts. I have one problem now that all the relays switch
on during the reset stage at startup, is there any way to avoid that?
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
 
"dmm" <dmmilne_REMOVE_@ozemail.com.au> wrote in message
news:nuuan1ppiu7cjjkv27dkmhpf6lgpmid7lu@4ax.com...
They turn on because the base of the transistor is being pulled high by
the pullup
resistor before the micro has a chance to set the pin outputs low. Use a
PNP
transistor in place of the BC338. Connect the emitter of the PNP to the
diode
anode-relay junction, and the collector to ground. The base can be
connected to the
pullup resistor. This method ensures that when the micro is in reset, the
relays
are off, because the pullup turns the transistor off. To turn the
transistor on,
set the output pin of the micro to low, to turn it off, set the output pin
high.
I tried this but for some reason there is 3v drop across the transistor so
the relay only gets 9v. It switches but it sounds like it is only just
switching. I'm not sure it will work anyway because the uC will set it's
outputs to 0 after reset I think

Michael
>
 
On Sun, 13 Nov 2005 16:27:27 +1100, "Michael C" <nospam@nospam.com>
wrote:

"dmm" <dmmilne_REMOVE_@ozemail.com.au> wrote in message
news:nuuan1ppiu7cjjkv27dkmhpf6lgpmid7lu@4ax.com...
They turn on because the base of the transistor is being pulled high by
the pullup
resistor before the micro has a chance to set the pin outputs low. Use a
PNP
transistor in place of the BC338. Connect the emitter of the PNP to the
diode
anode-relay junction, and the collector to ground. The base can be
connected to the
pullup resistor. This method ensures that when the micro is in reset, the
relays
are off, because the pullup turns the transistor off. To turn the
transistor on,
set the output pin of the micro to low, to turn it off, set the output pin
high.

I tried this but for some reason there is 3v drop across the transistor so
the relay only gets 9v. It switches but it sounds like it is only just
switching. I'm not sure it will work anyway because the uC will set it's
outputs to 0 after reset I think

Michael


Did you try another inverter stage before the relay driver as I
suggested?

Alan

--
++++++++++++++++++++++++++++++++++++++++++
Jenal Communications
Manufacturers and Suppliers of HF Selcall
P O Box 1108, Morley, Western Australia
Tel: +61 8 9370 5533 Fax +61 8 9467 6146
Web Site: http://www.jenal.com
Contact: http://www.jenal.com/?p=1
++++++++++++++++++++++++++++++++++++++++++
 
"Alan" <me@somewhere.com.au.invalid> wrote in message
news:0ruan1ltn6ldnjcqdc4q5vifoj7ji416ni@4ax.com...
2) put another transistor inverter between the micro output and the
relay driver you have now and invert your output signal in the micro.
That way you need to output a low from the micro to turn the relay on.
That sounds good, I'll give it a try. Although, is there some sort of chip
that would do all this? I've got 3 relays.

Michael
 
On Sun, 13 Nov 2005 16:42:27 +1100, "Michael C" <nospam@nospam.com>
wrote:

"Alan" <me@somewhere.com.au.invalid> wrote in message
news:0ruan1ltn6ldnjcqdc4q5vifoj7ji416ni@4ax.com...
2) put another transistor inverter between the micro output and the
relay driver you have now and invert your output signal in the micro.
That way you need to output a low from the micro to turn the relay on.

That sounds good, I'll give it a try. Although, is there some sort of chip
that would do all this? I've got 3 relays.

Michael

You could use a ULN2003 or ULN2803 relay driver chip. However you
still need to be able to drive them with input voltage/current so you
would still need inverters before them.

You could even try using a 74LS04 hex inverter chip for the inverter
and then a ULN chip as the driver.

Lots of different ways to go!

Alan

--
++++++++++++++++++++++++++++++++++++++++++
Jenal Communications
Manufacturers and Suppliers of HF Selcall
P O Box 1108, Morley, Western Australia
Tel: +61 8 9370 5533 Fax +61 8 9467 6146
Web Site: http://www.jenal.com
Contact: http://www.jenal.com/?p=1
++++++++++++++++++++++++++++++++++++++++++
 
On Sun, 13 Nov 2005 16:42:27 +1100, "Michael C" <nospam@nospam.com>
wrote:

"Alan" <me@somewhere.com.au.invalid> wrote in message
news:0ruan1ltn6ldnjcqdc4q5vifoj7ji416ni@4ax.com...
2) put another transistor inverter between the micro output and the
relay driver you have now and invert your output signal in the micro.
That way you need to output a low from the micro to turn the relay on.

That sounds good, I'll give it a try. Although, is there some sort of chip
that would do all this? I've got 3 relays.

Michael

As a follow up - you could probably even use a ULN2003 as both the
inverter and the driver. It has 7 (ULN2803 has 8) drivers in the one
package. Wire the output of one driver into the input of the second
driver and put the relay between the output of the second driver and
+12v.

Both inputs should then be pulled to +5 with say a 2k2 and the input
of the first driver connected to the output pin of the micro.

The ULN2003/2803 even has built in clamp diodes for your relays.

Alan

--
++++++++++++++++++++++++++++++++++++++++++
Jenal Communications
Manufacturers and Suppliers of HF Selcall
P O Box 1108, Morley, Western Australia
Tel: +61 8 9370 5533 Fax +61 8 9467 6146
Web Site: http://www.jenal.com
Contact: http://www.jenal.com/?p=1
++++++++++++++++++++++++++++++++++++++++++
 
On Mon, 14 Nov 2005 00:23:07 +1100, "Michael C" <nospam@nospam.com>
wrote:

"Alan" <me@somewhere.com.au.invalid> wrote in message
news:9gkdn1p2n99o580stuparb95rvcsvejmsi@4ax.com...
Did you try another inverter stage before the relay driver as I
suggested?

Initially I tried the pnp transisitor because it appeared to be much easier.
I just tried using the 2 npns and it worked perfectly, powering it all up I
don't get a peep out of the relay. I think I'll have a look at your other
suggestion as it looks like a neater solution. As these will be put together
by hand it's much easier to solder in a 16 pin chip instead of 6
transistors, 9 resistors and 3 diodes. Jaycar sells the ULN2003 so I'll try
to pick one up tomorrow. I was a bit confused about the datasheet though, do
I just connect the port pin to the input of the uln2003? The datasheet shows
some fairly complicated circuits on the input which would defeat the purpose
of using the chip. (page 11 of
http://rocky.digikey.com/WebLib/Texas%20Instruments/Web%20data/ULN2001A-4A,ULQ2003A-4A.pdf).

Thanks for all your help,
Michael

The complicated circuit on the input is acutally part of a TTL gate
output circuit! It's shown for reference only.

Using a ULN2003 all you need to do is:
1) connect micro output to (say) pin 1 and pull up to +5v with say a
2k2 resistor
2) connect pin 16 to (say) pin 2 and pull up to +5v with say a 2k2
resistor.
3) connect pin 15 to one side of your relay
4) connect other side of relay to +12v (or whatever)
5) connect pin 8 to ground
6) connect pin 9 to relay power supply +12v (or whatever)

You have to use the pull up resistors because all the inputs are
basically open collector/drain.

Using pin 9 of the ULN2003 connects the internal back EMF diodes as
per fig 19 of the datasheet and therefor you don't need external
protection diodes.

HTH

Have fun!

Alan

--
++++++++++++++++++++++++++++++++++++++++++
Jenal Communications
Manufacturers and Suppliers of HF Selcall
P O Box 1108, Morley, Western Australia
Tel: +61 8 9370 5533 Fax +61 8 9467 6146
Web Site: http://www.jenal.com
Contact: http://www.jenal.com/?p=1
++++++++++++++++++++++++++++++++++++++++++
 
"Alan" <me@somewhere.com.au.invalid> wrote in message
news:un8gn1hs9gavds6puthafm3b72tuvv222e@4ax.com...
The complicated circuit on the input is acutally part of a TTL gate
output circuit! It's shown for reference only.
hmmm, I thought most of that circuit shown probably wasn't needed but didn't
know why. Usually datasheets are quite clear and easy for a hobbiest like
myself to understand.

Using a ULN2003 all you need to do is:
1) connect micro output to (say) pin 1 and pull up to +5v with say a
2k2 resistor
2) connect pin 16 to (say) pin 2 and pull up to +5v with say a 2k2
resistor.
3) connect pin 15 to one side of your relay
4) connect other side of relay to +12v (or whatever)
5) connect pin 8 to ground
6) connect pin 9 to relay power supply +12v (or whatever)

You have to use the pull up resistors because all the inputs are
basically open collector/drain.
I'll see if I can get away with the pullup that's inside the cpu so I'll
only need the one pullup, although I might just go with the transistors.

Using pin 9 of the ULN2003 connects the internal back EMF diodes as
per fig 19 of the datasheet and therefor you don't need external
protection diodes.
That makes sense, I was a bit confused as to whether this was the power for
the chip or not and whether that voltage was going to appear on the outputs
or not.

It certainly has, many thanks.

Michael
 
On Mon, 14 Nov 2005 17:22:50 +1100, "Michael C" <me@nospam.com> wrote:

"Alan" <me@somewhere.com.au.invalid> wrote in message
news:un8gn1hs9gavds6puthafm3b72tuvv222e@4ax.com...
The complicated circuit on the input is acutally part of a TTL gate
output circuit! It's shown for reference only.

hmmm, I thought most of that circuit shown probably wasn't needed but didn't
know why. Usually datasheets are quite clear and easy for a hobbiest like
myself to understand.

Using a ULN2003 all you need to do is:
1) connect micro output to (say) pin 1 and pull up to +5v with say a
2k2 resistor
2) connect pin 16 to (say) pin 2 and pull up to +5v with say a 2k2
resistor.
3) connect pin 15 to one side of your relay
4) connect other side of relay to +12v (or whatever)
5) connect pin 8 to ground
6) connect pin 9 to relay power supply +12v (or whatever)

You have to use the pull up resistors because all the inputs are
basically open collector/drain.

I'll see if I can get away with the pullup that's inside the cpu so I'll
only need the one pullup, although I might just go with the transistors.

Using pin 9 of the ULN2003 connects the internal back EMF diodes as
per fig 19 of the datasheet and therefor you don't need external
protection diodes.

That makes sense, I was a bit confused as to whether this was the power for
the chip or not and whether that voltage was going to appear on the outputs
or not.

HTH

It certainly has, many thanks.

Michael

If you use transistors you only need two resistors and two transistor
(plus a diode for the relay).

1) connect o/p of micro to base of transistor A and pull up to +5 with
say 2k2
2) connect collector of transistor A to base of transistor B and pull
up to +5 (or +12) with say a 2k2
3) connect collector or transistor B to one side of relay
4) connect other side of relay to +12
5) don't forget to connect both emitters to ground and put diode
across the relay (the right way round!)

Alan

--
++++++++++++++++++++++++++++++++++++++++++
Jenal Communications
Manufacturers and Suppliers of HF Selcall
P O Box 1108, Morley, Western Australia
Tel: +61 8 9370 5533 Fax +61 8 9467 6146
Web Site: http://www.jenal.com
Contact: http://www.jenal.com/?p=1
++++++++++++++++++++++++++++++++++++++++++
 
"Jasen Betts" <jasen@clunker.homenet> wrote in message
news:slrndnd755.7t6.jasen@clunker.homenet...
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.
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.

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.
It's an 8051, specifically the phillips p89c668hba but I'll probably use the
atmel AT89C2051 when I get a board made for it.

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.
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
 

Welcome to EDABoard.com

Sponsor

Back
Top