Searching \ for 'Help! Switching problem with PIC16F84 driving a tr' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/power/priswitch.htm?key=switching
Search entire site for: 'Help! Switching problem with PIC16F84 driving a tr'.

Truncated match.
PICList Thread
'Help! Switching problem with PIC16F84 driving a tr'
1998\04\29@214429 by Rawle Watson

flavicon
face
Hello everyone,

       In a design using the PIC16F84 to turn on a switching transistor for
8 seconds and turn it off afterwards, I encounter the following problem.

a) the transistor switches on at the appropriate time as determined by the
program, but afterwards does not switch off even though the timing period
has ended.

The DC power supply for the circuit consists of a 16 volt ac adapter with
full-wave bridge rectifier, an LM317 adjustable regulator to give 14 volts
to recharge a battery, and a 5 volt regulator to power the pic.

I am using an RC oscillator and the clock frequency is approx. 2.8 MHz.

The RB4 pin is used to drive the base of a PN2222 transistor through a 2.2k
ohm resistor. The emitter is grounded and the collector is connected through
a 220 ohm resistor. Output is taken from the collector.

This transistor is used to turn off the LM317 regulator for 8 seconds so as
to load the battery to test its voltage across a voltage divider network.
This voltage is then input to the pic for sensing.


Both the PIC and the transistor switch operate as they should , when
connected independently.

However, the following is observed when a logic probe is connected in circuit.
The transistor remains on all the time once it is switched on by the pic
even though you can hear a pulse at the end of the timing period on RB4.

I have tried using a shunting capacitor on RB4 but to no avail.

Has anyone got any suggestions to help me solve this problem.

Thanks for your usual cooperation.



                                                       Rawle

1998\04\29@215059 by David VanHorn

flavicon
face
>The RB4 pin is used to drive the base of a PN2222 transistor through a 2.2k
>ohm resistor. The emitter is grounded and the collector is connected
through
>a 220 ohm resistor. Output is taken from the collector.


Check the output pin spec, you'll find that the maximum low voltage is high
enough to keep the base of an NPN active. Add an additional resistor from
the base to ground, probably 2.2k or 4.7k, and the problem will dissapear.

This has to be about the most common uC mistake. :)  Low isn't Zero!
That transistor only needs a couple microamps through the base to stay on.
Also, once they heat up from being on, their own leakage and gain goes up!

1998\04\29@233942 by ape

flavicon
face
David VanHorn wrote:

> >The RB4 pin is used to drive the base of a PN2222 transistor through a 2.2k
> >ohm resistor. The emitter is grounded and the collector is connected
> through
> >a 220 ohm resistor. Output is taken from the collector.
>
> Check the output pin spec, you'll find that the maximum low voltage is high
> enough to keep the base of an NPN active. Add an additional resistor from
> the base to ground, probably 2.2k or 4.7k, and the problem will dissapear.
>
> This has to be about the most common uC mistake. :)  Low isn't Zero!
> That transistor only needs a couple microamps through the base to stay on.
> Also, once they heat up from being on, their own leakage and gain goes up!

 Not just a problem for uC's.  This is a common problem ESPECIALLY
if one puts a cap from base to ground thinking that it will help reduce noise
from tripping the transistor (but you didn't say you were useing a cap).

Another thing you can do (depending on your application) is to put a diode
from the emitter to ground.  It raises the .7V trip point of the base up to
1.4V.  However, the collector will now only go down to .7V (the voltage
drop of the emitter to ground diode)

I also will use a 2N7000 (a common FET) that trips somewhere around
2 volts at times.

1998\04\29@233953 by Mike Keitz

picon face
On Wed, 29 Apr 1998 20:47:22 -0500 David VanHorn <spam_OUTdvanhornTakeThisOuTspamCEDAR.NET>
writes:

>Check the output pin spec, you'll find that the maximum low voltage is
>high
>enough to keep the base of an NPN active. Add an additional resistor
>from
>the base to ground, probably 2.2k or 4.7k, and the problem will
>dissapear.

It is indeed a common practice to place a resistor of about 1-10K from a
transistor base to emitter to shunt away any leakage currents.  With the
PIC pin pulling the base low through a 2.2K resistor the additional
resistor shouldn't be necessary, but it won't hurt either.

>This has to be about the most common uC mistake. :)  Low isn't Zero!
>That transistor only needs a couple microamps through the base to stay
>on.

I'm not fully buying this.  Generally PIC pins, being connected to large
FETs inside, drive very close to Vss with no load.  But, the PIC's Vss
pin ("ground") is not necessarily the same voltage as the transistor's
emitter ("ground") if the ground system isn't proper.  Also if a heavy
current is flowing into other "low" output pins, it can pull the internal
Vss up so that "low" pins don't output zero.

The obvious test is to measure the pin voltage after a timing cycle has
ended and the transistor is supposed to be off.  It may be a good idea to
freeze the PIC clock during the measurement in case the PIC is actually
turning it on and off rapidly.  If it is close to but not quite zero, try
a resistor from the transistor's base to emitter.  But likely you will
find it a full 5V, indicating the PIC is actively trying to turn the
transistor on.  Are you sure that something doesn't cause the PIC to
immediately restart a timing cycle when the transistor turns off?  In
other words, the transistor turns off, but then something related to the
317 and the battery restarts the PIC timer.  This could be either a
glitch in the 5V power supply causing a reset, or a bug in the PIC
software.

In circuits that handle high currents, it's a good idea to establish
seperate "logic" and "power" ground networks.  Connect them together at
one point only.  The ground pin of the 5V regulator is a good place.


_____________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]

1998\04\29@234951 by Dennis Plunkett

flavicon
face
At 09:39 PM 29/04/98 -0400, you wrote:
{Quote hidden}

You give no indication as to if the line is actualy going low at the end of
the period (I assume that low is off). So is this happening? Note that the
PIC does have some internal pull ups that can be enabled on this port (For
inputs only).
If you dissconnect the transistor (Remove the 2k2) does the port pin go high
and low as expected?
Exactly how is the transistor used to switch off the regulator? (Just for
interest only!)

Dennis

1998\04\30@044606 by Michael Ghormley

flavicon
face
Rawle Watson wrote:

<SNIP>

> Both the PIC and the transistor switch operate as they should , when
> connected independently.

> However, the following is observed when a logic probe is connected in circuit.
> The transistor remains on all the time once it is switched on by the pic
> even though you can hear a pulse at the end of the timing period on RB4.

It sounds to me like it might be thermal runaway.  Try putting a small resistor
(even as low as an ohm) between the emitter and ground.

Michael

REMOVE THE .NS (NO SPAM) FROM MY ADDRESS TO REPLY
*****************************************
The strong do what they have to do and
the weak accept what they have to accept.
                            --Thucydides

1998\04\30@045712 by Gordon Couger

flavicon
face
From: Mark Devin Newland <.....apeKILLspamspam@spam@eskimo.com>
>
>I also will use a 2N7000 (a common FET) that trips somewhere around
>2 volts at times.
A IRFD 123 FET works nice for switching up to 1 amp at 60 volts. It
goes in the low side and work like a charm no resistors. I generally
put a bypass cap on the gate to stop any chance of oscillation.

Gordon

Gordon Couger gcougerspamKILLspamrfdata.net
624 Cheyenne
Stillwater, OK 74075
405 624-2855   GMT -6:00

1998\04\30@111216 by David VanHorn

flavicon
face
>I'm not fully buying this.  Generally PIC pins, being connected to large
>FETs inside, drive very close to Vss with no load.  But, the PIC's Vss
>pin ("ground") is not necessarily the same voltage as the transistor's
>emitter ("ground") if the ground system isn't proper.  Also if a heavy
>current is flowing into other "low" output pins, it can pull the internal
>Vss up so that "low" pins don't output zero.


Read the spec, esp output voltage at logic zero max voltage.
Then have a close look at what it really takes to turn on a transistor.
Very close to zero isn't zero, and transistors often have quite a bit more
gain than their spec, especially at low currents.


{Quote hidden}

Adding the emitter resistor puts the transistor in class A operation. It was
in class C
Are you SURE this is a good idea?
Don't overcomplicate it. Transistors are not logic level devices. If adding
the needed resistor
bothers you too much, switch to low threshold FETs, which will begin turning
on at about 2V.


>In circuits that handle high currents, it's a good idea to establish
>seperate "logic" and "power" ground networks.  Connect them together at
>one point only.  The ground pin of the 5V regulator is a good place.


This I agree with 100%

1998\04\30@144519 by William Chops Westfield

face picon face
   Read the spec, esp output voltage at logic zero max voltage.
   Then have a close look at what it really takes to turn on a transistor.
   Very close to zero isn't zero, and transistors often have quite a bit
   more gain than their spec, especially at low currents.

Vol on a PIC is 0.6V max (I = ~8ma).  Vbe of a silicon transistor is about
.6V min, right?  With a base resistor, there ought to be negigable base
current, and the transistor should stay off, right?

BillW

1998\04\30@151217 by David VanHorn
flavicon
face
>Vol on a PIC is 0.6V max (I = ~8ma).  Vbe of a silicon transistor is about
>.6V min, right?  With a base resistor, there ought to be negigable base
>current, and the transistor should stay off, right?
>
>BillW

There dosen't have to be much current at all here, and the Vbe spec is
probably a max, rather than a min (At xxuA base current)
Trust me, been there, done that, you need some sort of divider mechanism to
insure that an NPN will turn off from a logic output.
Look at the schematics of gates with bipolar inputs.

In Horowitz and Hill, Pg 586, there is an example showing this, with an HC
gate driving an NPN. There is a second example showing an additional NPN
being used as an emitter follower to drive an NPN, but of course we've
doubled the vbe, plus some.

It's also shown in the "Bad idea" circuits on page 670

1998\04\30@181557 by Calvin

flavicon
face
You can also use a "digital transistor". These already have the neccesary
resistors integrated.

Calvin

{Original Message removed}

1998\04\30@200716 by vgr

flavicon
face
how about puting a diode in series with the base resistor. It'll make the vbe in
crease to
app.1,4 V. The resistor value mast be recalculated for the current necesary to s
with the transistor.

javier

1998\04\30@202810 by David VanHorn

flavicon
face
>how about puting a diode in series with the base resistor. It'll make the
vbe increase to
>app.1,4 V. The resistor value mast be recalculated for the current necesary
to swith the transistor.


That works, but just adding one resistor is the least expensive option. It's
what we use in production.

1998\04\30@225215 by ape

flavicon
face
David VanHorn wrote:

> >how about puting a diode in series with the base resistor. It'll make the
> vbe increase to
> >app.1,4 V. The resistor value mast be recalculated for the current necesary
> to swith the transistor.
>
> That works, but just adding one resistor is the least expensive option. It's
> what we use in production.

 Unless you have a noisy environment.  Sometimes the filtering is more than
the diode.


'Help! Switching problem with PIC16F84 driving a tr'
1998\05\01@011701 by Mike Keitz
picon face
On Thu, 30 Apr 1998 19:35:01 -0700 Mark Devin Newland <.....apeKILLspamspam.....eskimo.com>
writes:
>David VanHorn wrote:
>
>> >how about puting a diode in series with the base resistor. It'll
>make the
>> vbe increase to
>> >app.1,4 V. The resistor value mast be recalculated for the current
>necesary
>> to swith the transistor.
>>
>> That works, but just adding one resistor is the least expensive
>option. It's
>> what we use in production.
>
>  Unless you have a noisy environment.  Sometimes the filtering is
>more than
>the diode.

A series diode (alone) seems like a bad idea.  Any collector-base leakage
current would reverse bias the diode and have nowhere to go except
through the base-emitter junction, where it would be amplified and cause
more undesired collector current.  The diode could also rectify RF fields
that are present (to a greater extent than just the transistor would) and
cause false turn-on.  A resistor from base to emitter (ground) is
conventionally used and effective at keeping the base voltage low enough
that transistor action does not occur from leakage currents.  With this
resistor in place, the series diode could then also be used to increase
the voltage from the logic circuit that is required to turn the
transistor on.  The two resistors also form a voltage divider so more
voltage is required to reach the conduction threshold of the transistor.

I've had no problem leaving both out because low PIC outputs are
accurately modeled as small resistances to Vss.  Unless the internal Vss
bus is raised by large currents through other outputs, a single series
resistor from the PIC to the transistor will also serve to drain leakage
currents away from the transistor when it is supposed to be off.  If the
circuit has to operate at extreme high temperatures or it is important
that the transistor stay off while the PIC is in reset (all pins become
inputs then), the resistor to ground should be used.
As someone else noted, "digital transistors" which integrate this
resistor and the series limiting resistor are available.  The ULN2003
type transistor array devices also have integrated resistors.  Being
Darlington transistors, they also require 2 Vbe voltage to turn on, so
direct drive from "not quite zero" TTL outputs is effective.


_____________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]

1998\05\02@164807 by Marc Heuler

flavicon
face
Hi David (David VanHorn), in <009001bd73d9$ec1d90e0$EraseME85f135cespam_OUTspamTakeThisOuTxenu.iquest.net> on
Apr 29 you wrote:

> Check the output pin spec, you'll find that the maximum low voltage is high
> enough to keep the base of an NPN active. Add an additional resistor from
> the base to ground, probably 2.2k or 4.7k, and the problem will dissapear.

Better yet is a diode (1N4148 or other) in series with the pin, that raises
the switching voltage by about 0.7V - enough for usual uC output pin specs.
It consumes no extra power, works with pullup outputs, and makes no
assumptions about the port pin (theoretically a low output could _source_
lots of current at 0.4V for example and still stay in-spec).

1998\05\02@211559 by Marc Heuler

flavicon
face
Hi David (David VanHorn), in <028301bd7469$f0824820$e8f135cespamspam_OUTxenu.iquest.net> on
Apr 30 you wrote:

> It's also shown in the "Bad idea" circuits on page 670

Now that you say it..  Unfortunately they don't tell why a circuit is a bad
circuit.  For me the learning effect of these pages is zero.  Therefore I
just ignore the bad circuit pages.

Does an addendum with explanations exist?

1998\05\03@002335 by David VanHorn

flavicon
face
>Hi David (David VanHorn), in
<028301bd7469$f0824820$@spam@e8f135ceKILLspamspamxenu.iquest.net> on Apr 30 you wrote:
>
>> It's also shown in the "Bad idea" circuits on page 670
>
>Now that you say it..  Unfortunately they don't tell why a circuit is a bad
>circuit.  For me the learning effect of these pages is zero.  Therefore I
>just ignore the bad circuit pages.
>
>Does an addendum with explanations exist?

Barnes and Noble has a "student's guide" or some such.  For me that was the
most fun part of the book.
Basically, at the end of each section, you should be able to look at the bad
idea circuits and tell why. Some
are easy, and some are suttle.  It's kind of like defusing a bomb :)

More... (looser matching)
- Last day of these posts
- In 1998 , 1999 only
- Today
- New search...