pic output port

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

Translate This Thread From English to

Threaded View
hi all,

i want to turn on an npn switching transistor from an output port of a pic
16F84. my question is do i need a resistor between the npns' base and the
port of the pic or can i turn it on directly?

thanks in advance for help

tony



Re: pic output port


Quoted text here. Click to load it

You need a resistor to limit the current into the base.

Leon


Re: pic output port

Quoted text here. Click to load it

And you ought also to have one between its base and ground to make sure it
turns off cleanly.

Ian


Re: pic output port

"Ian Bell" wrote in message
Quoted text here. Click to load it
sure it

I don't think this should be necessary with a PIC.  When an output pin
is driven low, it's really low. ;-)


Re: pic output port
Quoted text here. Click to load it

Unless it is not yet initialized as output.

Rene
--
Ing.Buero R.Tschaggelar - http://www.ibrtses.com
& commercial newsgroups - http://www.talkto.net


Re: pic output port
Quoted text here. Click to load it

Not when it is in Hi-Z state. Like during a "reset" and any other
time when your program isn't fully initialized.




Re: pic output port
Hi, you need a base resistor, 470R will do.

Re: pic output port
On Sun, 30 Nov 2003 15:32:42 +0100, "Meindert Sprang"

Quoted text here. Click to load it

Rather than use rule-of-thumb values, why not do the engineering
calculations and pick a really appropriate value?  If the Hfe of the
NPN transistor is 20 (a reasonably conservative value, but look it up
for your particular NPN to be sure) then the collector current is
about 20 times the base current.  If you need to sink 20 ma. to turn
on an LED with this NPN, then you will need about 1 ma. of base
current.  If the PIC output at 1 ma. is about 4 volts, and if the base
voltage is about .7 volts, then the voltage drop across the base
resistor is 3.3 volts.  3.3 volts / 1 ma. = 3.3 kOhm.  It all depends
on the ultimate load current.


Quoted text here. Click to load it

That is a neat trick, but only if the load current is small enough so
that the weak pullup current times the hFE of the transistor is more
than that load current.


-Robert Scott
 Ypsilanti, Michigan
(Reply through newsgroups, not by direct e-mail, as automatic reply address is
fake.)


Re: pic output port

Quoted text here. Click to load it

I guess that depends on the beta of the transistor and the
resistance/impedance of the load, no? I would think that a transistor with a
beta of fifty, for example, couldn't drive much of a load with a 22k
resistor.

How does one calculate the base current required to saturate an NPN
transistor, such as in the subject circuit?

Quoted text here. Click to load it

Before or after?

Mike



Re: pic output port
On Mon, 1 Dec 2003 10:08:31 -0800, "Mike Turco"

Quoted text here. Click to load it

     The datasheet will usually have graphs of emitter current versus
base current for various voltages.  You can then size the resistor to
get the base current appropriate for the capability of the driver or
the amount of current you want to run through the device.
     I have found mosfets to be better for most applications
controlled by a microcontroller.  The cost difference is less than it
used to be.  The switching current is less and the holding current is
almost nil.  However, I still use bipolars in applications where I
want to block current in both directions or linmit the maximum current
in the controlled circuit.


Re: pic output port
Quoted text here. Click to load it
output

When he put 1k in parallel with the 4k7, it didn't work anymore. The
transistor was a BC547B, driving a low power relay. After removing the 1k,
it worked perfectly.

Meindert



Re: pic output port
Hi Tony,

Quoted text here. Click to load it

In addition to what the other posters said, you _can_ omit the base
resistor if (and only if) you configure the port as having
"weak pullups" and switch the port with the TRIS bit.

TRIS bit set means input = pullup to Vcc = NPN will be on
TRIS bit clear AND PORT bit clear means "output low", NPN will be off.

But take care you always have a 0 in the corresponding PORT output latch!

HTH
Wolfgang


Re: pic output port
Quoted text here. Click to load it


But doesn't a port pin's weak pullup get disconnected whenever that pin
is made OUTput?  Seems to me I read it in the spec. sheet.  Not positive
though.  If true, the pin ... and the xstr's base ... will float.

Re: pic output port

Quoted text here. Click to load it
pic
the
latch!
Quoted text here. Click to load it

Output pins never float! It will only float if you make it an INput without
a pullup. One warning about using this trick is that the pullup may be too
weak to switch fast. But if you're not worried about the speed then this
will save you a resistor.

Peter



Re: pic output port
On Wed, 3 Dec 2003 16:57:53 -0000, the renowned "moocowmoo"

Quoted text here. Click to load it

There isn't much current from the weak pullups (50uA minimum, but not
even 100% tested). If you're using a forced beta of 10-20, that means
1mA drive at most. Also, if the output gets changed to high (by
electrical noise, for example) there will be a lot of current flowing
out of the output pin into the base. I'd put the $0.001 resistor and
get ~5% control over base current rather than 10:1..

Best regards,
Spehro Pefhany
--
"it's the network..."                          "The Journey is the reward"
snipped-for-privacy@interlog.com             Info for manufacturers: http://www.trexon.com
We've slightly trimmed the long signature. Click to see the full one.
Re: pic output port
Quoted text here. Click to load it


You are correct, of course, that an output does not float.  The point I
was trying to make is that setting a pin OUTput disables weak pullup on
that pin, and that the pin would float the next time it is made INput.

I use the 16F84A and 16F628 to talk to DalSemi 1-wire devices, and the
uC pins constantly switch between INput and OUTput.  I therefore don't
depend on weak pullups for other INput pins on the same port; I connect
a real 4K7 resistors (usually) to those pins.

Re: pic output port
Hi, nothing floats if it's connected to a transistor base.

Re: pic output port

Quoted text here. Click to load it

Tony, if you place the load between the emitter and ground you may be able
to eliminate the current limiting resistor between the output pin on the pic
and the emitter on the transistor. -- Mike




Site Timeline