2n2222 collector-emitter on GND or VCC?

On my project, I want to use a transistor to cut power to a servo when not used. Im controlling the base of the 2n2222 with a logic pin from my uC (attiny85), linked with a 220ohm resistor to limit current to its base. My servo uses 100mA, and 2n2222 has a max collector current of 800mA so I should be good.

I can place the emitter-collector between battery GND and servo GND, or between battery VCC and servo VCC, and both seem to work, but it's problematic. (I know electrons flow from emitter to collector, and not the opposite, so I put the emitter on the battery side when I put it on GND, and vice versa when on the VCC side --- I tested flipping collector and emitter and current doesnt flow).

So it works, but I noticed on my multimeter that it consumes around 300uA when I put it on the GND side?? when I put the transistor on the vcc side, no energy is wasted. I'd place it on the vcc side instead, but it makes the servo move weakly, which I don't understand why either, because it moves just right when I place the transistor on gnd.

So, for now both have a disadvantage, but I can't explain why any of this happens.. I tried with a mosfet connected to GND of the servo but the same 300uA are wasted?? anyone has an idea? thanks a lot!

[u]Here is a typical motor driver circuit[/u].

The problem with high-side switching is that the base voltage has to be at least 0.7V higher than the emitter. So you can't saturate the transistor unless the base voltage is higher than the collector voltage (and you've only got 5V available).

I don't know why you're getting more leakage current one way than the other way. It might be coming into the servo through the data lines. That's just a guess.. I haven't studied the 2N2222 datasheet or analyzed the circuit.

My servo uses 100mA

That must be a very-small servo!

DVDdoug: [u]Here is a typical motor driver circuit[/u].

The problem with high-side switching is that the base voltage has to be at least 0.7V higher than the emitter. So you can't saturate the transistor unless the base voltage is higher than the collector voltage (and you've only got 5V available).

I don't know why you're getting more leakage current one way than the other way. It might be coming into the servo through the data lines. That's just a guess.. I haven't studied the 2N2222 datasheet or analyzed the circuit. That must be a very-small servo!

Yes it's a cheap eBay microservo haha!

So I see on your typical circuit he puts the transistor on the ground side. Is there a way I can reduce the leakage? like putting a diode somewhere, or anything?

And what happens when you are trying to switch a 12v circuit with a mosfet with 5v arduino? you cannot get a 0.7v higher logic pin voltage like you mentionned, because the logic pin is 7V lower than the other mosfet pins!

Thanks a lot

You need to use high-side switching and to set the servo pin to LOW (detach it in the Servo library and digitalWrite it LOW) before powering down the servo, otherwise you'll phantom-power the servo through its signal pin which is a bad idea. This may be the 0.3mA current you are seeing.

So a PNP or p-channel device is needed (high side switching requires this).

MarkT: You need to use high-side switching and to set the servo pin to LOW (detach it in the Servo library and digitalWrite it LOW) before powering down the servo, otherwise you'll phantom-power the servo through its signal pin which is a bad idea. This may be the 0.3mA current you are seeing.

So a PNP or p-channel device is needed (high side switching requires this).

So I did like you said. My code will be cleaner and it did reduce the current by around 25-50 uA. I did find what was wrong on the VCC side though, where there is no current leakage at all. My Multimeter was the problem. I dont know how, maybe it was causing a voltage drop, but when I removed it from the circuit, the servo was spinning alright. I must say its cheap eBay multimeter.

Hi, Have you got the gnd of the Arduino and the gnd of the servo and its supply connected together?

Thanks... Tom... :)

MarkT:
digitalWrite it LOW) before powering down the servo, otherwise you’ll phantom-power the servo

Or set the pin mode to INPUT.

wvmarle: Or set the pin mode to INPUT.

Which will then be floating - probably best to write LOW for less risk of random behaviour.

BTW I notice the original question asserts the servo only uses 100mA - frankly that's not believable, servos take peaks a lot more than that. A 2N2222 might struggle.

Always use low side switching unless you have a compelling need for high side switching - I don’t think you do here. N-channel MOSFETs and NPN transistors are always better for a given price point (or cheaper for given performance). If you must switch high side, you use a P-channel MOSFET or PNP transistor - but if switching more than the voltage the microcontroller runs at, you need an additional N-channel mosfet or NPN transistor just to switch the voltage on the gate/base of the high side switch.

However, if you switch the low side, then you need the data line to be high - either set that pin to INPUT (in which case the servo’s protection diodes will probably pull it up to 5v in short order), or digitalWrite() it high after “detaching” the servo library from the pin. I see no problem with leaving the pin INPUT - the servo is unpowered, so it’s hard to imagine how it would behave oddly here, and it is safe whether switching high or low side.

Doing this - do you still see that leakage current when it’s off? My guess is that you will not.

MarkT: Which will then be floating - probably best to write LOW for less risk of random behaviour.

Behaviour will be quite predictable as long as that servo is powered down. Low side switch and pin set to OUTPUT, LOW does give the risk of parasitic powering.