Author Topic: driving external BJT using internal pull-up resistor?  (Read 1237 times)

0 Members and 1 Guest are viewing this topic.

Offline 240RSTopic starter

  • Regular Contributor
  • *
  • Posts: 82
  • Country: fr
driving external BJT using internal pull-up resistor?
« on: September 28, 2022, 08:10:49 am »
I am using STM32G4's a lot and solder through-hole nucleo boards. If I drive quite some transistors (BC549C with high gain), I use 10k base resistor normally if I want to switch 6mA to ground (1/20th of collector current).

Would be nice if I could drive the transistor directly from the MCU without the base transistor and thought of the following: why not use the internal pull-up to switch the transistor on pull the output pin low for logical to switch the transistor off. Is that being done?

At powerup and down, I need to make sure the transistor is never switched on. Is there a risk that cannot be done by configuring the PWR registers correctly?

The only thing I am trying to do is save space by using less through-hole resistors.

Also, I want the the collector-emitter voltage to be as low as possible at 6mA and use a 1/20th base current as rule of thumb. With a higher gain transistor like the BC549C (hfe in the 100s), is this still 1/20th? The internal pull-up of the MCU seems to be around 40k. My ideal value was 10k.

Thanks!
 

Offline wek

  • Frequent Contributor
  • **
  • Posts: 486
  • Country: sk
Re: driving external BJT using internal pull-up resistor?
« Reply #1 on: September 28, 2022, 08:30:57 am »
I don't like the idea, but I am not a HW expert. If the datasheet-guaranteed maximum pullup resistance, minimum used VDD and datasheet-guaranteed minimum hfe at the datasheet-given Vce yields the required current, and if you don't need speed, well then maybe it's OK.

From the powerup/down point of view, the GPIO state during reset is not influenced by PWR or any other internal register, and is given in GPIO chapter of DS (with the extra USBC-PD caveat in 'G0/'G4). Most pins are floating/analog in 'G4 during and after reset, check the leakage table in datasheet and assert, if max leakage x maximum hfe won't result in exceedingly high current for your application. Note, that some pins (the JTAG/SWD ones) do have pullups/pulldowns switched on during reset.

Also from programming point of view, using pullups/pulldowns dynamically brings in atomicity problem, if you want to use it in interrupts (note that when using "normal" outputs, atomicity at hardware level is ensured by using GPIO_BSRR register).

JW
« Last Edit: September 28, 2022, 08:36:50 am by wek »
 

Offline srb1954

  • Super Contributor
  • ***
  • Posts: 1085
  • Country: nz
  • Retired Electronics Design Engineer
Re: driving external BJT using internal pull-up resistor?
« Reply #2 on: September 28, 2022, 10:11:24 am »
I am using STM32G4's a lot and solder through-hole nucleo boards. If I drive quite some transistors (BC549C with high gain), I use 10k base resistor normally if I want to switch 6mA to ground (1/20th of collector current).

Would be nice if I could drive the transistor directly from the MCU without the base transistor and thought of the following: why not use the internal pull-up to switch the transistor on pull the output pin low for logical to switch the transistor off. Is that being done?

At powerup and down, I need to make sure the transistor is never switched on. Is there a risk that cannot be done by configuring the PWR registers correctly?

The only thing I am trying to do is save space by using less through-hole resistors.

Also, I want the the collector-emitter voltage to be as low as possible at 6mA and use a 1/20th base current as rule of thumb. With a higher gain transistor like the BC549C (hfe in the 100s), is this still 1/20th? The internal pull-up of the MCU seems to be around 40k. My ideal value was 10k.


I wouldn't recommend using the internal pull-up resistors in the micro as they usually don't have a sufficiently well controlled resistance value to ensure adequate base current drive to your BJT. There is also a risk that the BJTs and the micro are damaged by excessive current if you accidentally configure the port O/Ps as a strong active push-pull drive and there is no resistor to limit the base current.

Considerable space saving could be made by using resistor arrays. Depending on your PCB design rules you save 50-75% of the space of discrete resistors.

Two other options that can completely eliminate base resistors are:
(a) Use a MOSFET and drive it directly from the micro O/P pin. You will need to ensure that the MOSFET is a low threshold device that can be fully turned on by the available output voltage swing of the micro port pin. Suitable low-threshold MOSFETs will likely be more expensive than a BJT and there is also a possibility that the MOSFET is inadvertently switched on by port leakage during the power-up process of the micro and until such time as the S/W sets the ports to O/Ps and to the correct inactive state.
(b) Use BJTs with internal bias resistors, sometimes known as 'digital transistors'. These are more predictable during power-up conditions as they incorporate an internal base-emitter resistor that will keep the transistor turned off while the micro is performing its power-up procedure.

 
The following users thanked this post: thm_w

Offline 240RSTopic starter

  • Regular Contributor
  • *
  • Posts: 82
  • Country: fr
Re: driving external BJT using internal pull-up resistor?
« Reply #3 on: September 28, 2022, 01:46:23 pm »
Thanks for the two posts. This concludes it for me: I will just use base resistors. Thanks. Learned a lot.
 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 1965
  • Country: us
Re: driving external BJT using internal pull-up resistor?
« Reply #4 on: September 28, 2022, 02:32:10 pm »
I have done that with other processors, and it has worked well.  But I only do hobby stuff, not production design.  In the end, you might want to just try it and see what happens.  If the internal pullup is 40K, and the DC gain of the transistor is at least 90, then switching 6mA should be no problem.  And if the GPIO pins are floating on powerup, I don't think the transistors will turn on, even momentarily.  That leads to the question of how you would turn the transistors off.  In theory, you could just disable the pullup so the port is floating.  Without base current, the transistor should turn off.  But in a very noisy environment, you might want to change the port to output, low.  Just be careful to change it back to input first to turn the transistor back on.  You don't want it to ever be output, high.

Well I'll defer to the judgement of the EEs here, but my suspicion is it would work just fine.

 

Offline wek

  • Frequent Contributor
  • **
  • Posts: 486
  • Country: sk
Re: driving external BJT using internal pull-up resistor?
« Reply #5 on: September 28, 2022, 08:21:59 pm »
Quote
  But in a very noisy environment, you might want to change the port to output, low.
STM32 have also switchable pulldowns, and the control for both is through the same register for a given pin, so a "swap" from pullup can be done in a single operation.

JW
 

Offline thm_w

  • Super Contributor
  • ***
  • Posts: 6272
  • Country: ca
  • Non-expert
Re: driving external BJT using internal pull-up resistor?
« Reply #6 on: September 28, 2022, 09:25:11 pm »
Considerable space saving could be made by using resistor arrays. Depending on your PCB design rules you save 50-75% of the space of discrete resistors.

OP said they are using through hole resistors... so you'd definitely save 75%+ space by using SMD resistor arrays.
https://www.alliedelec.com/m/d/e3a99357d474a10a17a554dd52b3f6d3.pdf
Profile -> Modify profile -> Look and Layout ->  Don't show users' signatures
 

Online Benta

  • Super Contributor
  • ***
  • Posts: 5839
  • Country: de
Re: driving external BJT using internal pull-up resistor?
« Reply #7 on: September 28, 2022, 10:06:13 pm »
No matter what you do (base resistor or not), the transistors will be "on" at powerup/reset with your design.
If this is OK for you, fine. Otherwise you need to rethink it.
 

Offline wek

  • Frequent Contributor
  • **
  • Posts: 486
  • Country: sk
Re: driving external BJT using internal pull-up resistor?
« Reply #8 on: September 28, 2022, 11:17:59 pm »
No matter what you do (base resistor or not), the transistors will be "on" at powerup/reset with your design.
Are you sure? BC549C are NPN.

JW
 

Offline PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 1473
  • Country: au
Re: driving external BJT using internal pull-up resistor?
« Reply #9 on: September 28, 2022, 11:36:09 pm »
I am using STM32G4's a lot and solder through-hole nucleo boards. If I drive quite some transistors (BC549C with high gain), I use 10k base resistor normally if I want to switch 6mA to ground (1/20th of collector current).
Would be nice if I could drive the transistor directly from the MCU without the base transistor and thought of the following: why not use the internal pull-up to switch the transistor on pull the output pin low for logical to switch the transistor off. Is that being done?
Measure it and see :) - use a small series R and check the drop across it, keep in mind the pullups can be non linear, depending on the chip design.
 
You can measure the available base current, and the Vcesat follows a curve.
Better data sheets show the saturation region  eg this one https://datasheet.lcsc.com/lcsc/2008011835_LGE-BC547C_C713614.pdf

These days, mosfets and pre biased / digital transistors are a more common solution to avoid the resistor. 

At powerup and down, I need to make sure the transistor is never switched on. Is there a risk that cannot be done by configuring the PWR registers correctly?
You do need to check the pin reset values for your MCU, as how they handle the default port settings (float or pullup) varies with vendor and family.
 

Offline thm_w

  • Super Contributor
  • ***
  • Posts: 6272
  • Country: ca
  • Non-expert
Re: driving external BJT using internal pull-up resistor?
« Reply #10 on: September 29, 2022, 12:21:13 am »
I wouldn't measure it when they give you the number in the datasheet: https://www.st.com/resource/en/datasheet/stm32g474cb.pdf
Profile -> Modify profile -> Look and Layout ->  Don't show users' signatures
 

Offline srb1954

  • Super Contributor
  • ***
  • Posts: 1085
  • Country: nz
  • Retired Electronics Design Engineer
Re: driving external BJT using internal pull-up resistor?
« Reply #11 on: September 29, 2022, 01:51:11 am »
Considerable space saving could be made by using resistor arrays. Depending on your PCB design rules you save 50-75% of the space of discrete resistors.

OP said they are using through hole resistors... so you'd definitely save 75%+ space by using SMD resistor arrays.
https://www.alliedelec.com/m/d/e3a99357d474a10a17a554dd52b3f6d3.pdf
You can get THT resistor arrays as well; these are commonly known as SIL (single-in-line) resistor packages. My estimate of 50-75% space saving was based on using SIL packages.

You can certainly do a lot better by by going to SMD technology even if you use discrete SMD resistors, especially if you are prepared to go to 0201 or smaller package sizes.
 
The following users thanked this post: thm_w

Online Benta

  • Super Contributor
  • ***
  • Posts: 5839
  • Country: de
Re: driving external BJT using internal pull-up resistor?
« Reply #12 on: September 29, 2022, 06:27:36 pm »
No matter what you do (base resistor or not), the transistors will be "on" at powerup/reset with your design.
Are you sure? BC549C are NPN.

JW
Yes, I'm sure. The transistors will be "on". But if you mean that the output (collector) voltage will be "low", then that's true as well.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf