# PNP transistor as current detector

#### srFelipes

Joined Jul 3, 2020
5
Hello, I'm currently working with a private protocol which uses only 2 wires and I have to replicate. The master device alternates the polarity of a 24v potential between the wires so it is sometimes +24v and others -24v (measured from one of the cables). The slaves answer by connecting and disconnecting an internal resistor to this potential and thus generating a current. In order to replicate the +24v/-24v master part I'm using a transistor based H-bridge circuit, and to detect the slave answer I made a circuit in which the current passes trough a PNP transistor base to emitter, this generates a 24V potential in the collector and then I get the needed 3.3V logical 1 via a voltage divider. I simulated this circuit in falstads circuitjs (http://tinyurl.com/y7rf8v62) and it works like a charm, but when I made the circuit in the protoboard the collector of the PNP transistor is always at 24V, I used smaller values for the resistor divider and the collector voltage dropped but I cannot fully understand whats going on. Later connecting and disconnecting parts of the circuit I noted that this voltage in the collector only occurs when the 1K resistor is connected to the base but its other end disconnected as if there was an small current flowing though the air(?) Does somebody understand what's going on, what causes this small current and collector voltage?

TLDR: I detect 24V in the collector of a PNP transistor when the emitter is connected to 24V and the base is connected to a 1K resistor whose other end is disconnected.

Last edited:

#### Irving

Joined Jan 30, 2016
820
All transistors have a small leakage current, akin to the reverse bias current in diode. Also with that base resistor disconnected any ambient pickup wil be amplified and will result in a small collector current.

Since your multimeter has at least a 1Mohm input impedance it only needs a microamp to give you a voltage reading...

#### srFelipes

Joined Jul 3, 2020
5
Thanks for the answer, I thought it could be something like that. What could I do in order to reduce this voltage generated by the leakage current? other than reducing the resistance of the voltage divider, I thought about using a low gain pnp transistor but I'm struggling to find one, do you know any transistor models of low gain and that is available in sot-23 package? Or do you have any idea of how could I achieve the current detection with another circuit?

#### Irving

Joined Jan 30, 2016
820
There's several ways. How is your receiver circuit powered? And how is the transmitting h-bridge connected?
Is the 2-wire line balanced about ground?
how do the slaves connect their resistors?
is the polarity of the line always the same when the slaves signal?

Last edited:

#### srFelipes

Joined Jul 3, 2020
5
How is your receiver circuit powered? With 2 lab bench power supply, one for the 24V and other for the 3.3V, both share ground.
And how is the transmitting h-bridge connected? Check the schematic in https://tinyurl.com/y7rf8v62 , basically the current detector is in the inner side of the H bridge, initially I thought that maybe the H bridge was generating a current of some sort but the current detection circuit behaves the same if it is powered by the H bridge or directly from the 24V
Is the 2-wire line balanced about ground? Not necessarily all I care is that the voltage drop between the H bridge output is +-24V
how do the slaves connect their resistors? I have no info about this, I'm currently simulating this behavior with a switch and that's why I have the resistor with an unconnected pin
is the polarity of the line always the same when the slaves signal? No, some slaves will answer when the voltage is 24V and others when is -24V, that's why the circuit is mirroed and has diodes in their connections so it works both ways. I also thought that the diodes might cause this problem but removing them didn't help or change anything.

Here it is a picture of the circuit in case that you couldn't see the link above

Inner current detection circuit:
Outer H bridge circuit:

#### Irving

Joined Jan 30, 2016
820
Ah, I see... and the switched 1k resistor in the simulation is at the slave end. The simulation doesn't work well on my phone!

Is the current detection done that way in the existing setup - I understood you're replicating something already done?

How does the slave detect the +/- 24v without loading the line? How is the 1k switched in/out?

#### Irving

Joined Jan 30, 2016
820
I've had a play on your simulator. To prevent detection when the switch is opened you need a resistor from base to emitter. In your setup the 1k resistor at the slave end would pull 22mA through the e-b junction, that's not good for the transistor. When the slave signals sufficient current should flow through the emitter-base resistor to generate a 0.7v differential. most current signalling systems use 4 - 20mA, but i would go low, so lets say 5mA which means 0.7/0.005 =~ 150ohm. That guarantees holding the transistor off when the base is floating. Then the signalling resistor can be bigger, say 3k3. The slave input impedance for sampling master/slave signalling can be, in total, as low as 7k between the lines without triggering the current detection. This looks pretty robust to me. Circuitjs file below...

How many slaves are there in total?

#### Attachments

• 2.4 KB Views: 1
Last edited:

#### Irving

Joined Jan 30, 2016
820
Yes, I did consider putting in an opamp but once I saw what the problem was it was an unnecessary complication. What the OP had proposed was fine, it just needed finessing. The transistor wasn't introducing error, it was just biased incorrectly, the concept was good.

A dedicated current sense device like the LT6100 would have been expensive overkill.

Sometimes old school is better...

#### srFelipes

Joined Jul 3, 2020
5
I've had a play on your simulator. To prevent detection when the switch is opened you need a resistor from base to emitter. In your setup the 1k resistor at the slave end would pull 22mA through the e-b junction, that's not good for the transistor. When the slave signals sufficient current should flow through the emitter-base resistor to generate a 0.7v differential. most current signalling systems use 4 - 20mA, but i would go low, so lets say 5mA which means 0.7/0.005 =~ 150ohm. That guarantees holding the transistor off when the base is floating. Then the signalling resistor can be bigger, say 3k3. The slave input impedance for sampling master/slave signalling can be, in total, as low as 7k between the lines without triggering the current detection. This looks pretty robust to me. Circuitjs file below...

How many slaves are there in total?
This is just what I need, I tested it and it works, thanks a lot.
About the high current in the base I also thought this could cause some problems, I read in some forums that as long as the total heat dissipation of the transistor is below its limit there should be no problem but, is this the case, I would love to hear your opinion about this. In the real application the device I'm working on it is thought to be used only once so I don't care too much about its lifespan, but I think that it is clever to use the transistor in this manner to work as a cheap current detector or even measurer.
I can't change the slave resistor value as this is the protocol especification. I understand that in this protocol up to 200 slaves can be connected and they all answer in different time slots so the minimum slave resistor will be 1k all the time.
Thanks again!