# Transistor needs 4mA to saturate and turn on - my GPIO cannot source more than 0.1mA. What to do?

Thread Starter

#### Mahonroy

Joined Oct 21, 2014
332
Hey guys,
So I decided to use an IO-expander IC in a design, and I was not paying attention to the amount the GPIOs can source and sink. This thing can sink 20mA, and for some reason I assumed it could source close to 20mA as well.....turns out it can only source 0.1mA max on a GPIO! Because of this the MMBT3904 transistor cannot activate.

Datasheet for IO-expander:
https://www.nxp.com/docs/en/data-sheet/PCF8574_PCF8574A.pdf

Circuit:

Would a good solution be to use a darlington transistor instead, such as this one? (MMBTA13 or MMBTA14)
Datasheet:
http://www.mouser.com/ds/2/258/MMBTA13-MMBTA14(SOT-23)-349671.pdf

The old transistor had a gain of 30, while this one has a gain of 10,000, thus only requiring around 0.01 mA instead of 4mA.... if I am understanding this correctly that is. So if it only needs 0.01, then I should be able to drive this directly with my IO-expander IC I am thinking, and don't need to change anything else.

Is there a better way I should re-design this for the future? Or is the darlington transistor a good way of doing this?

Thanks and any help or advice is greatly appreciated!

#### MaxHeadRoom

Joined Jul 18, 2013
22,011
2n7000 'Fetlington'?
Max.

#### crutschow

Joined Mar 14, 2008
26,012
If the transistor needs 4mA, just add a pull-up resistor between the power rail and the transistor input to provide the 4mA.
Since the GPIO can sink 20mA it can readily pull the output to logic zero.

Thus for example, if the power supply is 5V then the resistor value would be (5V-0.7V) / 4mA ≈1kΩ.

Thread Starter

#### Mahonroy

Joined Oct 21, 2014
332
2n7000 'Fetlington'?
Max.
Cool, do you think this would be a better choise than the part number I chose above? Which value in the datasheet indicates how much amps it might take to activate this mosfet?

If the transistor needs 4mA, just add a pull-up resistor between the power rail and the transistor input to provide the 4mA.
Since the GPIO can sink 20mA it can readily pull the output to logic zero.

Thus for example, if the power supply is 5V then the resistor value would be (5V-0.7V) / 4mA ≈1kΩ.
Thanks for the advice. I had considered this, but I was worried that the relays would activate before the IO-expander had a chance to pull it down to zero. The default state for the pins are input at power up, so by default the relays would trigger.

#### MaxHeadRoom

Joined Jul 18, 2013
22,011
Cool, do you think this would be a better choise than the part number I chose above? Which value in the datasheet indicates how much amps it might take to activate this mosfet?
.
Mosfets are not current operated devices, similar to valves, they are voltage operated (trans-conductance) devices.
Max.

#### Attachments

• 831 KB Views: 6

#### kubeek

Joined Sep 20, 2005
5,736
Thanks for the advice. I had considered this, but I was worried that the relays would activate before the IO-expander had a chance to pull it down to zero. The default state for the pins are input at power up, so by default the relays would trigger.
You could switch the NO and NC contacts on the relay to overcome that.

Thread Starter

#### Mahonroy

Joined Oct 21, 2014
332
Mosfets are not current operated devices, similar to valves, they are voltage operated (trans-conductance) devices.
Max.
Ok. So it looks like this would be a direct swap part for me?, SOT23 package, 2N7002K-7:
https://www.diodes.com/assets/Datasheets/ds30896.pdf

And I can just swap the 1K resistor out with a 100 ohm (or a 0 ohm?), and leave the 10K, and should be good to go?

Last edited:

#### Bordodynov

Joined May 20, 2015
2,737
Use npn 2SD2704K

Thread Starter

#### Mahonroy

Joined Oct 21, 2014
332

#### Bordodynov

Joined May 20, 2015
2,737
The transistor I proposed is more robust than a field-effect transistor. With a field effect transistor, you must act very carefully (you can say gently). Touching a hand or a soldering iron to the gate of the field-effect transistor, it is easy to break through a thin oxide and the transistor will die.

#### MaxHeadRoom

Joined Jul 18, 2013
22,011
The transistor I proposed is more robust than a field-effect transistor. With a field effect transistor, you must act very carefully (you can say gently). Touching a hand or a soldering iron to the gate of the field-effect transistor, it is easy to break through a thin oxide and the transistor will die.
I have been using the 2n7000 since its inception some decades ago and other FET's and have never given any consideration these precautions, and don't ever recall losing one.
I have applications out in the field that are ~ 30yrs since inception and still operating.
Max..

#### Bordodynov

Joined May 20, 2015
2,737
I have been using the 2n7000 since its inception some decades ago and other FET's and have never given any consideration these precautions, and don't ever recall losing one.
I have applications out in the field that are ~ 30yrs since inception and still operating.
Max..
So you use an isolated soldering iron and do everything neatly!

#### MaxHeadRoom

Joined Jul 18, 2013
22,011
Weller WTCPN which has a 24v transformer, but I don't really handle them with any consideration of static damage.
Max.

#### crutschow

Joined Mar 14, 2008
26,012
Power MOSFETs have a large gate capacitance, which tends to protect them from small ESD events.
It acts as a voltage divider between the ESD voltage from your body capacitance and the gate.
Thus they are much less sensitive to ESD then a device with very low capacitance and thin gate oxides such as 74HC CMOS logic gates.

#### dl324

Joined Mar 30, 2015
12,241
but I don't really handle them with any consideration of static damage.
I try to handle them correctly and still had several damaged in the past few months. None completely dead, but experiencing high leakage.

#### Audioguru

Joined Dec 20, 2007
11,249
Read the datasheet for the 2N7000 Mosfet. The gate must be +10V for all of them to fully turn on. Some of them barely turn on when the gate is +3V (the minimum threshold voltage) which is very close to the +3.3V or a little less from your IO expander. If the supply for the IO Expander is 5V then all 2N7000 Mosfets will turn on well enough for your circuit.

What is the maximum allowed reverse voltage for your LEDs? Mine are 5V but your circuit gives them 8.7V which might destroy the LEDs or destroy the IO expander.

#### Audioguru

Joined Dec 20, 2007
11,249
You said the MMBT3904 transistor has a gain of 30. But why talk about linear gain when you want it to saturate? Its base current must be 1/10th its collector current for it to saturate. I assume that your relay plus LED need 100mA.
The same for the high gain oriental transistor. It needs plenty of base current for all of them to saturate.

Thread Starter

#### Mahonroy

Joined Oct 21, 2014
332
Read the datasheet for the 2N7000 Mosfet. The gate must be +10V for all of them to fully turn on. Some of them barely turn on when the gate is +3V (the minimum threshold voltage) which is very close to the +3.3V or a little less from your IO expander. If the supply for the IO Expander is 5V then all 2N7000 Mosfets will turn on well enough for your circuit.

What is the maximum allowed reverse voltage for your LEDs? Mine are 5V but your circuit gives them 8.7V which might destroy the LEDs or destroy the IO expander.
I said that I tried the darlington transistor not the 2N7002.

Thread Starter

#### Mahonroy

Joined Oct 21, 2014
332
So I experimented some more and I just can't figure this thing out. I was able to swap in both the darlington, and the 2n7002, changed the resistor values to this:
Darlington: R11=1K, R10=60K
2n7002: R11=0ohm, R10 = 10K

Both will activate the relay on and off just fine..... however.... on power up the GPIO defaults to Input (with an internal 100uA pullup resistor). So because of this, on power up it activates the relay. Once the thing has finished booted up everything is fine, but this is a problem for before it boots up.

I experimented with lowering R10 in an attempt to overpower the internal pullup resistor, but with no luck. I decreased it down to 15K and it still activates the relay at power up. Changing it to 12K and the relay stays off and remains off.

How should I go about this? Do I just have messed up resistor values here?

Thanks again and any help is greatly appreciated!