>> On Wed, 27 Jun 2007 13:36:09 -0700, Benjamin Sølberg
>>
[quoted text clipped - 55 lines]
>The uC (PIC12F508) has internal pullup but you must enable it first as
>i understood from the spec.
Even without that enabled, there is leakage. The spec for the part
will disclose that value, too. The programable pull-up (weak mosfet)
just adds to that.
>Ok so it looks like it is safe to just have the base to IO resistor.
I can't tell you professional practice. My knowledge is as a hobbyist
only. I have used pull-downs before, myself, just to make myself more
comfortable. And if I were sending this line to a connector, I'd
definitely use a pull-down. I want to KNOW where the input signal is
going to be at, in that case. The extra resistor gives me comfort, if
nothing else.
But I'm not a professional, so others will have to weigh in on that
score.
>Say I remove the IC from the socket (to program it) and accidentally
>powers on the circuit, nothing is now connected
>to the base except for a resistor with one pin floating. Will it be
>able to turn on in any way (without the pull down resistor) ?
If this is to an important relay, let's say, and you are likely to
have folks replacing microcontrollers while powered up, I'd add the
resistor. Yes, having a nice, low impedance to ground to hold the
base is a 'nice to have.' In hobby stuff, I do it sometimes when it
is convenient (I'm not wire-wrapping or point-to-point soldering it
all up, in other words.)
>Again, I am just trying to learn something from you guys :-)
Well, if you are just asking if tethering the base to ground via a
nice resistor will cover more unintended ground, then yes it will.
Jon
Benjamin Sølberg - 27 Jun 2007 23:39 GMT
> On Wed, 27 Jun 2007 14:28:31 -0700, Benjamin S?lberg
>
[quoted text clipped - 96 lines]
>
> - Vis tekst i anf?rselstegn -
I will add the pull down then from base to ground.
Thank you all for your help.
Regards
Benjamin
Jonathan Kirwan - 28 Jun 2007 01:28 GMT
>> Well, if you are just asking if tethering the base to ground via a
>> nice resistor will cover more unintended ground, then yes it will.
>
>I will add the pull down then from base to ground.
>
>Thank you all for your help.
That's the safer/surer side. Best of luck (though it seems you are
going to be fine without luck in this case.)
Since you are searching for various approaches here, you might also
consider inserting a zener in series with your protection diode across
the relay coil. The rate at which current declines is proportional to
the voltage across (from dI/dt = V/L) it and adding a zener lets a
somewhat larger voltage to develop which allows a faster dI/dt. That
has some benefits, at times. Use something reasonable (most any
common value.) If you don't have the diode or diode+zener, I believe
what happens is that your BJT has its own breakdown voltage and the
coil just dumps through the BJT after achieving its own breakdown
voltage. That may or may not be okay, which is part of why diodes,
zener+diodes, or RC snubbers are added.
I don't recall reading what the coil current needs to be, but there is
another consideration here in sizing your base drive resistor (not the
pull-down.) If you plan to use the BJT as a switch, where the voltage
between the emitter and collector is minimized and below say 0.3V or
so, you should imagine that the BJT is well into saturation and the
effective beta is then low. I usually figure about beta=20 for modern
general purpose transistors and beta=10 for the old ones I may find in
an old box of parts. That means you need to figure on about 1/20th or
1/10th of the collector current into the base. Your PIC can handle a
fair amount on its own (worst case is 25mA, I think, but that is an
absolute maximum if memory serves and not something to rely upon for
normal use.) And as yuo pull more current from the PIC, the voltage
drops at the PIC's I/O pin. I figure about 80-90 ohms driving low and
about 120 ohms driving high. Since you would be driving high, keep in
mind that there is some voltage drop going on inside the PIC. Use
that to help calculate your resistor.
For example, let's say that you wanted the collector to handle about
100mA for your relay and you are using a 2N3904. I'd say beta=20 and
figure that the base needs 100mA/20 or 5mA. If the PIC is running on
5V (I think you said as much), then the I/O pin will be at 5 - 5mA*120
or about 4.4V (rough guess.) I usually figure a base-to-emitter
voltage of about 0.7V when passing 100uA into the base. 5mA is about
50 times that much. With about 60mV per decade of current change,
this suggests about an additional 100mV or so (close to two decades
worth.) So make it 0.8V. With 5mA, small general purpose transistors
like this are getting a bit non-log-linear though after about 1mA of
base current. So add another .1V just to be safe. Call it 0.9V. Your
resistor is then (4.4V - 0.9V) / 5mA or 700 ohms. A 10k would
obviously be too weak in a case like that. On the other hand, if you
only need about 10mA for the collector current, that would drop the
base needs to 10mA/20 or about 500uA. We are talking now about a base
voltage of say 0.7V + 40mV or .74V. Your PIC will only drop about
60mV, so now we compute (4.94 - 0.74) / 500uA or 8400 ohms for the
base resistor. That's more like the 10k you are talking about,
earlier.
If you can accept a volt or more drop across the collector/emitter of
the BJT, then your gain is more like beta=100 to 200. And you don't
need as much base current to drive the collector current. But then
you lose some of the voltage applied to the coil, too. And you may
need to consider power dissipated in the transistor.
Jon