Help with understanding NPN transistor results.

Thread Starter


Joined Apr 29, 2016

So I've been mucking around with some 2N2222A NPN transistors, a Raspberry Pi Zero, and a sourcing input module (1746-IV16) from Allen Bradley. My project is to use the transistors to drive inputs on the PLC. This will let the PLC use logic via a FIFO and produce a few outputs. The PLC side of things is done and tested via a few software trials. My issue is with the transistors. Typically we'd use Sinking inputs at work but this salvaged SLC rack had a sourcing input module. This SLC rack also powers the 24v I'm using to drive the inputs. Being still a pup and not being far enough in my schooling I started with a very basic idea of transistors. Starting out I tested my transistors using a handheld oscope and signal generator. I didn't use any base resistors since my current was super tiny anyway. Everything worked without a problem. Next was making it drive my input module. That's where things broke down. to make a long story short this is what I found:

  1. With no base resistor or any resistors besides the internal 3k Ohms of the input module my transistors would be saturated without voltage/current from the Raspberry pi. So they would be true 100% of the time.
  2. With a 3.2k OHM resistor between the tied Raspberry pi and emitter and the COM on the SLC I could operate 2 transistors but when a third was introduced my inputs would all go black.
So not having much luck I copied this circuit to Multisim 14. I found that with point #2 the voltage would drop below 5v (The required minimum for the 1746-IV16) whenever I'd switch a third transistor. This lead me to some experimentation. The following is what I then found out:
  1. If I changed the resistor used between the emitter and COM to 1k my voltage would then stay above 5v with all 5 transistors on. However I'd have to have 2 transistors on before the voltage would be high enough to activate a transistor. I also put in 10k OHM resistors at the base.
  2. If I took another 1k OHM resistor and put it between the power supply and the loads I could drive all the transistors without voltage issues.
What I'm unsure about is why this is the case. Even after reading all these: A BJT Circuit in Saturation.pdf
Examples in Electronics Demystified
Examples in the 2nd edition Fundamentals of Electric Circuits

I'm still not sure why the extra resistors between the supply and load and the tied COMs and the SLC COM is needed. So I guess my questions are these:

  1. What are the purpose of the 2 resistors? Are they needed for some type of current biasing loop?
  2. What is the math behind the loops? I'm guessing it's something to do with KCLs.
  3. Besides changing the input module to a sinking module and using PNPs is there an simplified version of this circuit?
Thank you for any insight you can give

Also here's some info on the 1746-IV16
and the Raspberry Pi

Voltage drop with 2 transistors @ 3.2k OHM
Voltage drop 1.PNG
Voltage drop with more than 2 transistors @ 3.2k OHM
Voltage drop 2.PNG
Voltage drop with 2 transistors @ 1k OHM
Voltage drop with 1k.PNG
Voltage drop with more than 2 transistors @ 1k OHM
Voltage drop with 2 1k.PNG
Working simulated circuit with 1 transistor
Working simulated circuit with all transistors
I am not farmillier with that IO unit generally a sourcing input would be pulled up internally and require a minimal impedance, or a contact, to pull it down which the PLC would then report as an active input.

If you look at the input block and see all zeros, with nothing connected, whilst your sourcing inputs are reading 12V then this is how it is working.
It is almost certain that the input current is limited by the PLC so connecting an input to ground will not harm it and is in fact how you are suppose to be using them. if you add an external resistor to ground and measure the current you can test this.
1K would produce a 24mA current, anything less than that is due to the resistance of the pullup on the PLC input so if you measured 12mA thr pullup must be 1K

Transistors are current amplifiers that create a emitter collector current equal to base emitter curent, until they saturate at which point you will see a forward voltage drop much like a diode.

You need to draw enough current from the input to lower its potential to a level that the PLC sees as a 1
You need to make this happen without putting 24V on a PI input.
You probably dont need to worry about the EC current so driving yoiur transistor to saturation is a good plan.

You should use your NPN with the emitter to ground and the collector directly on the input. this is called open collector and is commonly found on PLC outputs.
Bias the base to ground, slightly, just to stop stray voltages triggering the input.
add a current limiting resistor that is just big enough to turn the transistor fully on when the Pi output is high and you are done...

Alternatively get hold of a ULN2003A, or similar. This is a line driver that is an array of darlington transistors with all the biasing on board.
If you push its input to a little over 0.8V and dont exceed 30V the open collector output will be approximately 0.8V above ground, assuming the current is within its capabilities which are comparatively large, 100mA I think but you should check.
I use these for all sorts of things but level shifting digital signals is probably what I do most.
If you treat them as an inverting bufer and want a none inverting buffer just put two in series with about 2k2 of pull up between them.

To be honest as you dont care about slew rate and will not be handling significant currents a line driver is about as good as it gets, literally 1 chip and a few terminals, heck it doesn't even need a supply just a ground.

Thread Starter


Joined Apr 29, 2016
Ah that makes tons of sense thank you. I physically took a reading of the incidence between the module supply and an input. While I figured this to be 3k ohm based on the 8ma draw mentioned in the manual. What I measured was actually 500k. Getting my head around the fact I'm controlling everything with current is a mind bender. Thank you so much for your explanation.

Thread Starter


Joined Apr 29, 2016
Ok so I removed R1 and R12. I then took R7 - R11 and connected them to ground instead of straight to the base. I then disconnected the coms and separated them. Each voltage path is now separated. It worked like a charm. Thank you so much for your explanation. I think I was making it harder than it was.


Joined Sep 9, 2010
I haven't done the math but it looks like your base currents will be greater than the collector-emitter currents through those 500kΩ resistors. What's the point of that?

Wait a minute, you haven't shown that the two power sources share a common ground. It won't work if they aren't connected. They sort of are, through the bases of the transistors.