Resistor required for PN2222A transistor base? Diode also?

Hi,

I'm very new to this, so please bear with me.

I have an Arduino Uno driving a Futaba S3003 servo. To avoid servo "twitch" I've added a PN2222A NPN transistor so that I can set the servo position before powering up the servo. This seems to work fine.

However, I've been told that I should add a resistor on the base connection. How do I work out what value of resistor to add?

Also, again told to add a diode to protect the circuit from the servo. If so, which kind? I thought this sort of spike problem was present with larger motors rather than small servos. Is that correct?

Thanks for you help

Darren.

tenjin:
I've added a PN2222A NPN transistor

However, I've been told that I should add a resistor on the base connection. How do I work out what value of resistor to add?

No fancy calculations are necessary, it's only there to stop too many amps coming out of the Arduino pin. Something in the 220 to 330 Ohms range is good.

I am intrigued to find out how this.....

To avoid servo "twitch" I've added a PN2222A NPN transistor so that I can set the servo position before powering up the servo.

.... works. Can someone enlighten me please?

Hi,

I followed the notes here:

  • and changed it up for my needs.

Essentially you attach the servo, set the position, then set the transistor base high.

Darren.

Before starting the Arduino or with the transistor turned off, you turn the servo by hand to where you want it to start.
When you turn the transistor on, as long as the pin isn't "attach"ed, the servo remains in the position you left it, until it starts receiving pulses.

tenjin:
Hi,

I followed the notes here:

How to properly detach/turn off a servo with arduino. | Modsbyus.com

  • and changed it up for my needs.

Essentially you attach the servo, set the position, then set the transistor base high.

Darren.

Ah yes, another poor circuit. I'd just ignore that site. That circuit will have about
1V lost across the transistor when its on, whereas a high-side switch will have perhaps 0.1V
dropped across it. Their circuit will actually sort of work, but the transistor may get hot.
The lack of base resistor in their design is deliberate. The circuit they use is called an
emitter-follower.

To control the power to a servo whilst keeping the grounds connected you
need a high-side switch - which means you use a PNP transistor, not an NPN
transistor. With a PNP in high-side switch configuration you would connect thus:

PNP emitter to +ve supply for servo
PNP collector to servo's power
GNDs common between Arduino and servo and servo supply
Arduino pin via 180 ohm resistor to base.

You'll have to ensure the Servo supply is in the range 4.8 to 5.5V though,
to ensure the PNP is fully off when the Arduino pin is HIGH = 5.0V.

Pulling the arduino pin LOW will turn on the PNP transistor. The PNP transistor
should have a good max current rating, at least 1A.

[ Oh yes, the diode - not sure about this, but if its needed then across the servo's
power, cathode to +ve, anode to ground. I don't know if your servo has enough
decoupling to snub transients to reasonable levels (within the capabilities of the
switching transistor) ]

I'm having a bit of an issue with the statement:

only there to stop too many amps coming out of the Arduino pin

That is not the only reason that you need to place a resistor at the base of a transistor when using it as a driver. Please try and control your urge to oversimplify your advice. This is how bad Instructables pages get started.

I have no issue with the statement that the value of the resistor is not critical, as long as it is between say 680 ohms and 4.7K ohms. I consider those to be extremes and as you might see in many many examples... a 1K resistor is just about right as a "generic" value.

pwillard:
I’m having a bit of an issue with the statement:

only there to stop too many amps coming out of the Arduino pin

That is not the only reason that you need to place a resistor at the base of a transistor when using it as a driver. Please try and control your urge to oversimplify your advice. This is how bad Instructables pages get started.

If only instructables would follow even simplified advice…

pwillard:
I have no issue with the statement that the value of the resistor is not critical, as long as it is between say 680 ohms and 4.7K ohms. I consider those to be extremes and as you might see in many many examples… a 1K resistor is just about right as a “generic” value.

?? 1k can’t garantee saturation on most transistors, let alone 4.7k ohms.

eg. Here’s the graph for a 2N2222, a 1k resistor won’t go anywhere near the 800mA it’s capable of.

Below that, the BC327. It’s a similar story, the gain rapidly drops below 100 as you go towards higher currents. 1k isn’t enough (unless you don’t care about voltage drop/heat).

The only harm is choosing a value that’s “too low” is a bit more power consumption but that’s hardly applicable here.

BC327.png

You guys are killing me with asking this poor little 2N2222 to work it's little heart out. We all agreed a while back a good rule of thumb for a servo is 1A. Let's just use a p-channel logic level MOSFET and be done with it? The parts are $1 each. As MarkT already stated, a high-side switch is called for here.

http://www.ebay.com/itm/Siliconix-Temic-SMD10P05L-P-Channel-Logic-Level-MOSFET-50V-10A-DPAK-5pcs-/400668429577?pt=LH_DefaultDomain_0&hash=item5d49b30d09

if you have a few 2n2222's you could get creative and wire 4 or 5 up to give you a nice distributed 1amp of power...

I never understand why we must make the 2N2222A supply anywhere near it;s MAX ratings of 800mA... seems to be a sticking point for some. With 5mA at the base of a 2N2222A it's turned on enough to drive an LED, a small motor or a standard PCB relay with no issues and come nowhere near hurting a GPIO pin.

To each his own I guess.

if you have a few 2n2222's you could get creative and wire 4 or 5 up to give you a nice distributed 1amp of power...

It's not that simple. Since no two transistors will have the same VceSat, you will need to share the current among them. Unless you go to a high-side switch, you will still have the losses. For the $1 price of a hefty FET, it's silly not to do it right.

Yeah mosfets in parallel maybe… BJT’s in parallel… not so good without some extra measures to prevent a runaway…

the circuit i designed using 2n2222’s should work fine…

(Uses chrome in order to view the circuit sorry)

or view the attached image.

I lowered it to 20ohm per transistor and 1 ohm allowing a 2watt 1ohm resistor to be used - the diode to supress any voltage spikes from the motor, but obviously you can increase the load on each providing you do it to all balancing them…

?
An simulation are a simulation not the real world.
Why the 300 ohm resistor? You loses base drive voltage.
Why 20 ohm balance resistor ? 1/10 would be better.
With this set up you get 500 mV and 500 mA.
Have I missed something?

Use ONE MOS transistor instead, that's much better.

Pelle

Did I or did I not talk of altering it’s load…

The problem with your design, CJDelphi is although it's a good electronics lesson about current sharing isn't going to be anything but very lossy. In order to power a Servo which was the OP's intent, we need to switch the HIGH side as MarkT already outlined in an earlier post. He suggested a PNP transistor, I suggested a P-Channel FET. Of the three, which solution gives you the lowest voltage drop and the least number of parts?

Then you never read my original post about the circuit, I said he could get creative and try that method, not because he should or it's better.... but because he can based on the fact I doubt he bought just 1 2n2222 transistor

I was taking into account parts available to him right now, I'd change the design of my circuit and supply current with separate 300 ohm resistors.

I did not design it for anyone here just how one would....

So tell me, he sits and does nothing or he can try what I suggested until the fet arrives.

MarkT:
Ah yes, another poor circuit. I'd just ignore that site. That circuit will have about
1V lost across the transistor when its on, whereas a high-side switch will have perhaps 0.1V
dropped across it. Their circuit will actually sort of work, but the transistor may get hot.
The lack of base resistor in their design is deliberate. The circuit they use is called an
emitter-follower.

To control the power to a servo whilst keeping the grounds connected you
need a high-side switch - which means you use a PNP transistor, not an NPN
transistor. With a PNP in high-side switch configuration you would connect thus:

PNP emitter to +ve supply for servo
PNP collector to servo's power
GNDs common between Arduino and servo and servo supply
Arduino pin via 180 ohm resistor to base.

You'll have to ensure the Servo supply is in the range 4.8 to 5.5V though,
to ensure the PNP is fully off when the Arduino pin is HIGH = 5.0V.

Pulling the arduino pin LOW will turn on the PNP transistor. The PNP transistor
should have a good max current rating, at least 1A.

[ Oh yes, the diode - not sure about this, but if its needed then across the servo's
power, cathode to +ve, anode to ground. I don't know if your servo has enough
decoupling to snub transients to reasonable levels (within the capabilities of the
switching transistor) ]

MarkT,
Thanks for pointing out that my circuit is wrong. I have updated the post on my site with a warning and will fix the post shortly.

There is little point in arguing what base resistor you need for this circuit as it is an emitter follower and so does not require one at all.

Wiring transistors in parallel simply will not work no matter what your simulation says. This is because in a simulator all the transistors are at the same temperature and the temperature coefficient track each other. In the real world this does not happen. I have been on a few projects that have tried this trick in the early days of transistors when you could not get high current ones. They have all failed.