Pages: [1]   Go Down
Author Topic: NPN as a switch question  (Read 637 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Sr. Member
****
Karma: 0
Posts: 252
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm using a voltage divider to change 12v in to 4.3 volts out to monitor battery voltage. The voltage divider seems to be working properly.

I'm using a 2n4401 NPN as a switch so that I'm not draining power through the voltage divider (even through it would be a low draw anyway, I'm using 3.3k/2k as R1 + R2 on the divider).

When I measure voltage on the v out while using the NPN, High state voltage = 4.19 (close enough), Low state voltage = 0.80.

The NPN is between R2 and GND, the Base has a 1k resistor between B and the +5v

If the NPN is at low(off) why I'm I getting a voltage? Any clues?
Logged

0
Offline Offline
Faraday Member
**
Karma: 13
Posts: 2857
ruggedcircuits.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, you're always going to get SOME kind of reading. It's actually not a very good circuit because with the transistor off, it's as if the transistor and R2 do not exist. So you have a path from 12V, through the 3.3k resistor, and into your Arduino. The 3.3k resistor limits your current but it's still not a good idea to apply 12V to the Arduino input pin.

I would not have predicted the 0.80V myself (I would have thought it was closer to the maximum possible reading). Is it possible your code is not designed to handle a reading of 1023 (maximum 10-bit ADC value) and prints out 0.80 erroneously?

--
The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, speaker, microphone, light sensor, potentiometer, pushbuttons
Logged

Offline Offline
Sr. Member
****
Karma: 0
Posts: 252
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Whoa!!! Good catch! Lucky I was testing this on a breadboard without connection to the arduino. I had the NPN up stream of the voltage divider and was getting 1.65 at Vout (High) and 0 at Vout (Low). I got confused as to why the voltage was so low so I thought to put it downstream.

Any idea why I was losing so much voltage through the NPN?
Logged

0
Offline Offline
Faraday Member
**
Karma: 13
Posts: 2857
ruggedcircuits.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

With the NPN "upstream" (I'm guessing that means collector at 12V, emitter connected to the 3.3k resistor) you are not saturating it since the emitter voltage is rising when it turns on, and the collector-emitter junction has to stand off everything between 12V and ~4.3V. NPN transistors don't really work well as "high side" switches in this way. I'd recommend a PNP transistor arrangement instead (or P-channel MOSFET arrangement). Let me know if you get stuck and I'll try to draw you up a circuit smiley

--
The Aussie Shield: breakout all 28 pins to quick-connect terminals
Logged

Offline Offline
Sr. Member
****
Karma: 0
Posts: 252
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you sir!

I was trying to skirt around using a MOSFET because I had a NPN laying in the box and a MOSFET would require a trip to the store... LOL.

I'm not sure if its even worth the trouble. The circuit will only draw .002A at 12V...
Logged

0
Offline Offline
Faraday Member
**
Karma: 13
Posts: 2857
ruggedcircuits.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Indeed, if you kick up your resistances to 33k and 20k then your voltage estimates should be quite good enough, you won't need a transistor, and current draw is only 231 microamps.

--
The Rugged Motor Driver: two H-bridges, more power than an L298, fully protected
Logged

Pages: [1]   Go Up
Jump to: