1
\$\begingroup\$

I have 2 RGB controllers that I am trying to connect through a multiplexer that will be controlled from a GPIO pin on microcontroller (Seeed Xiao SAMD21) so I can freely switch between the controllers.

Both RGB controllers use NPN transistors as a low side switch and use PWM to control the brightness of each LED in a common anode 12V RGB LED strip that draws 60mA per LED. Most multiplexers I've found have a max current rating of 25mA so I can't pass the current from the LED directly through the multiplexer. Instead, I am using a PNP transistor whose base is connected to the NPN collector of each RGB controller. I only need to control 1 LED so the current ratings of a BJT are not a big concern. R1, D1, R8, Q4e, Q4b and Controller0 are all embedded in larger components and cannot be changed. The RGB controllers and MCU will use 3.3V logic.

  • Is this a practical way to work around the low current ratings of multiplexers? Edit: It is definitely a way to do this
  • Is this a proper application of a PNP transistor? Edit: Yes, this is an example of Emitter Follower aka Common Collector, but is not necessarily efficient. I'm currently working on replacing the PNP with an NPN and connecting a Pull-up resistor between the base and 12V but that then inverts the signal, still working on it...
  • The values of the resistors are pretty low, but the circuit seemed to function as I intended with almost no change for extremely high values, how would I know what a proper value for the resistors could be? Edit: I tried to find a more accurate LED model but I'm a little lost. The LEDs I'm controlling are embedded in a larger, shrouded component and I'm having a hard time finding how to determine the necessary values for simulation. I'm willing to pretend it's a 12V strip with 5050 RGB LEDS that is 3 LEDS in length. Note LEDS would be 4-pin RGB with common anode, not 3-pin ARGB Update: I have uploaded a new version of the original schematic (bottom of this post) to clarify which resistors I am having trouble choosing correctly. R1 values were chosen to represent a generic LED that draws 60mA
  • When the multiplexer source is changed from the GPIO the spice sim showed a nasty current spike (pictured in second image Edit: this spike is occurring on all pins of the MUX that aren't connected to ground ), how can I prevent this spike? Edit: I've discovered that charge injection is the effect I am referring to, but I'm still not sure how to prevent it. Update: By not using a multiplexer, and just using BJTs this should prevent the spikes
  • Is there a better way to switch between 2 low side switches?Edit Yes, see answers.
  • The Input control of the multiplexer is controlled by a not gate, is this a proper implementation? Is it necessary for a chip like the TMUX4053 that offers 1.8V logic compatible thresholds? Edit: It is not necessary for either of the aforementioned ICs.

NOTES: The schematic only shows a single generic LED rather than a complete RGB LED just for demonstration. The ADG1236 was used because the spice model was readily available, but I would most likely implement a different multiplexer like the TMUX4053 along with the recommended capacitors. Time values for PULSEs were chosen arbitrarily.

RGB_Hub_Concept

RGB_Hub_MUX_I_Spike

Edit: Thanks to those who interacted with this post, especially Ste Kulov who helped me to realize I was over complicating what could have been just a couple logic gates, and also convinced me to to learn more about applying MOSFETS.

Below I have added a modified version of the original schematic to clarify any questions that may have been left unanswered. All components in boxes are embedded and cannot be modified. They are approximations to model the behavior of the components I am working with. I removed the NOT gate that controlled the input of the MUX. The three remaining resistors are the ones I can change with very little effect. Based on the solutions I will be taking a different approach

~~~ This is not the solution ~~~ See answers for solution ~~~ enter image description here

\$\endgroup\$
10
  • \$\begingroup\$ Let's take a step back and clarify the intended behavior: you have two low-side switching controllers and you want to have one or the other controlling the same LED strip based on a signal from the microcontroller? \$\endgroup\$
    – vir
    Commented Feb 20, 2023 at 21:14
  • 1
    \$\begingroup\$ I believe the bases of Q2 and Q4 are inaccessible. That PNP transistor won't operate correctly on the low side. I think you should be able to use a low-side NPN or N-channel MOSFET and some creative wiring of a quad-NAND to translate the open-collector signals from the controllers and logic level signal from the microcontroller into a suitable control signal for the NPN/N-channel. \$\endgroup\$
    – vir
    Commented Feb 20, 2023 at 22:31
  • 1
    \$\begingroup\$ I like your solution. To clarify, you're using a PNP emitter follower (i.e. common collector; i.e. class A amplifier) to get more current out of your multiplexer. Some downsides to this are the make-before-break problem, you lose voltage headroom due to the base-emitter diode, and you might be wasting power in the PNP (plot the power dissipation in your simulation to make sure you're not burning it up). If you're confident you can solve the make-before-break using a different mux, and the voltage headroom is not an issue, and the power wasted is not an issue...then I think you'll be OK. \$\endgroup\$
    – Ste Kulov
    Commented Feb 21, 2023 at 19:36
  • 1
    \$\begingroup\$ One extra comment about the simulation. The LED symbol is using the default model D, which is a very basic silicon PN junction diode which will give you around 0.76V drop at 60mA. If you're going to rely on your simulation results for resistor and power draw calculations, you need to use a proper LED model which more closely matches your actual LED. Try picking from the built-in diode list and sort by type and find the few LEDs in the list. Try them out and plot the voltage across them to see which one works best for you. \$\endgroup\$
    – Ste Kulov
    Commented Feb 21, 2023 at 19:41
  • 1
    \$\begingroup\$ Sorry for the confusion. I should have said emitter-base diode, since I'm referring to Q1. I don't know your LED voltage drop so it's hard to say if it will affect you much. Basically, the equivalent circuit would be 12V->190Ω->LED->Si-Diode->GND. Yes, using NPN transistors will trade emitter-base drop for saturation voltage which is much lower. With less drop, you get more headroom and less power lost. I can propose you a solution using N-channel MOSFETs which will be much better, but I need a bit more info: Are you able to spare an additional MCU GPIO pin, or do you only have access to one? \$\endgroup\$
    – Ste Kulov
    Commented Feb 22, 2023 at 5:34

1 Answer 1

2
\$\begingroup\$

• Is this a practical way to work around the low current ratings of multiplexers?

• Is this a proper application of a PNP transistor?

It's a decent solution. You've created a PNP "emitter follower" (also called common collector) amplifier circuit to buffer your multiplexer output. This is also known as a "Class A Amplifier" and one of the first things you notice when you start reading up on this type of amplifier is that they are power inefficient. It's especially true in this case since your load is DC coupled, when most Class A amps have AC coupled loads. Basically, this means your PNP transistor is going to burn up extra heat in proportion to how much current needs to flow through your LED.


• The values of the resistors are pretty low, but the circuit seemed to function as I intended with almost no change for extremely high values, how would I know what a proper value for the resistors could be?

I'm not sure which resistors you're referring to. R1 is mostly going to set your LED brightness, so that one might have to be done experimentally. It's going to be highly dependent on the rest of your circuit, so maybe that one is best doing last. Make sure you pay attention to how much power that resistor is dissipating so you can select the correct wattage. The base resistors for the NPN transistors are going to depend on how hard you want to drive the transistors. You didn't make it clear if R2 and R3 are embedded into the controllers, so I'll ignore those assuming they are. R4 and R5 are going to effect how well your Q3 NOT gate is going to work in terms of switching speed and how much current to want use up from your GPIO pin when it's on. You can probably get away with 1K on the collector and 10K on the base. You should experiment yourself and see what works best for you. The collector resistor will also determine how much power you'll draw from the 12V rail when the transistor is on.


• I tried to find a more accurate LED model but I'm a little lost. The LEDs I'm controlling are embedded in a larger component and I'm having a hard time finding how to determine the necessary values for simulation. I'm willing to pretend it's a 12V strip with 5050 RGB LEDS that is 3 LEDS in length. Note LEDS would be 4-pin RGB with common anode, not 3-pin ARGB

Creating your own SPICE model is not going to be that easy. I don't know anything about RGB LEDs. If you think they are effectively 3 LEDs in series, then I would pick 3 LEDs from the built-in LTspice model library and connect them in series. You can try to do more bench experiments to gather more info or try to find a datasheet for your LEDs.


• When the multiplexer source is changed from the GPIO the spice sim showed a nasty current spike (pictured in second image), how can I prevent this spike?

You didn't explain through what component the spike is occurring through. It's likely due to the rapid switching between the two sides of the MUX. Slowing down the switching can reduce or eliminate this.


• The Input control of the multiplexer is controlled by a not gate, is this a proper implementation? Is it necessary for a chip like the TMUX4053 that offers 1.8V logic compatible thresholds?

It's unnecessary for either the ADG1236 or TMUX4053. You need to look at the \$V_{IH}\$ and \$V_{IL}\$ parameters in their datasheets and see if you meet the requirements. From what I can tell, a 3.3V GPIO from a CMOS microcontroller should be able to satisfy both requirements for either part.


• Is there a better way to switch between 2 low side switches?

Yes...two more low side switches in series with the existing ones. I think you're wasting effort with the analog switch (multiplexer). Analog CMOS switches are meant for switching voltages throughout the entire power rail swing (in this case: 0V through 12V). Since you're switching point is the collector of a emitter-grounded NPN transistor you only need to switch a few millivolts (due to \$V_{CE(sat)}\$) above ground. An analog CMOS switch is constructed with an N-channel MOSFET and P-channel MOSFET in parallel. The idea is that the N-channel is used for the low-side voltages and the P-channel for the high-side voltages and they work together in varying degrees for the values in the middle. Since you only need the low-side switching, you only need the N-channel half of it...so just use that half. Put another way, you can replace your SPDT switch (multiplexer) with two SPST switches (two discrete transistors).

In the comments you mentioned you are uncomfortable using MOSFETs, so we'll use NPN BJTs as the low-side switches. You also said you can use an additional GPIO pin from your microcontroller which will make the control easier and more customizable. This way you can turn one switch off in software, and then delay for a few clock cycles before you turn the next one on...and so forth. Below is an example using 2N3904 BJTs (image and also the LTspice .ASC file pasted as text):

enter image description here

Version 4
SHEET 1 1204 680
WIRE -64 -512 -128 -512
WIRE 96 -512 16 -512
WIRE 240 -512 160 -512
WIRE 384 -512 304 -512
WIRE 560 -512 448 -512
WIRE -128 -480 -128 -512
WIRE -128 -368 -128 -400
WIRE 560 -352 560 -512
WIRE 560 -352 64 -352
WIRE 1104 -352 560 -352
WIRE 64 -256 64 -352
WIRE 1104 -256 1104 -352
WIRE -112 -208 -176 -208
WIRE 0 -208 -32 -208
WIRE 928 -208 864 -208
WIRE 1040 -208 1008 -208
WIRE -176 -176 -176 -208
WIRE 864 -176 864 -208
WIRE -176 -64 -176 -96
WIRE 864 -64 864 -96
WIRE 64 32 64 -160
WIRE 1104 32 1104 -160
WIRE -160 80 -304 80
WIRE -112 80 -160 80
WIRE 0 80 -32 80
WIRE 880 80 736 80
WIRE 928 80 880 80
WIRE 1040 80 1008 80
WIRE -304 128 -304 80
WIRE -160 128 -160 80
WIRE 736 128 736 80
WIRE 880 128 880 80
WIRE 64 176 64 128
WIRE 1104 176 1104 128
WIRE -304 256 -304 208
WIRE -160 256 -160 208
WIRE 736 256 736 208
WIRE 880 256 880 208
FLAG -304 256 0
FLAG -160 256 0
FLAG 64 176 0
FLAG 736 256 0
FLAG 880 256 0
FLAG 1104 176 0
FLAG -176 -64 0
FLAG 864 -64 0
FLAG -128 -368 0
FLAG -176 -208 GPIO1
FLAG 864 -208 GPIO2
SYMBOL voltage -304 112 M0
WINDOW 123 0 0 Left 0
WINDOW 39 0 0 Left 0
SYMATTR InstName V1
SYMATTR Value 3.3
SYMBOL res -176 112 R0
SYMATTR InstName R1
SYMATTR Value 10k
SYMBOL res -16 64 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName R2
SYMATTR Value 220
SYMBOL npn 0 32 R0
SYMATTR InstName Q1
SYMATTR Value 2N2222
SYMBOL voltage 736 112 M0
WINDOW 123 0 0 Left 0
WINDOW 39 0 0 Left 0
SYMATTR InstName V2
SYMATTR Value PULSE(3.3 0 12.5m 10u 10u 12.5m 25m)
SYMBOL res 864 112 R0
SYMATTR InstName R3
SYMATTR Value 10k
SYMBOL res 1024 64 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName R4
SYMATTR Value 220
SYMBOL npn 1040 32 R0
SYMATTR InstName Q2
SYMATTR Value 2N2222
SYMBOL voltage -176 -192 M0
WINDOW 123 0 0 Left 0
WINDOW 39 0 0 Left 0
SYMATTR InstName V3
SYMATTR Value PULSE(3.3 0 70m 10u 10u 70m 140m)
SYMBOL npn 0 -256 R0
SYMATTR InstName Q3
SYMATTR Value 2N3904
SYMBOL res -16 -224 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName R5
SYMATTR Value 1k
SYMBOL voltage 864 -192 M0
WINDOW 123 0 0 Left 0
WINDOW 39 0 0 Left 0
SYMATTR InstName V4
SYMATTR Value PULSE(0 3.3 71m 10u 10u 68m 140m)
SYMBOL npn 1040 -256 R0
SYMATTR InstName Q4
SYMATTR Value 2N3904
SYMBOL res 1024 -224 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName R6
SYMATTR Value 1k
SYMBOL voltage -128 -496 R0
SYMATTR InstName V5
SYMATTR Value 12
SYMBOL res 32 -528 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName R7
SYMATTR Value 82
SYMBOL LED 96 -496 R270
WINDOW 0 32 32 VTop 2
WINDOW 3 0 32 VBottom 2
SYMATTR InstName D1
SYMATTR Value QTLP690C
SYMATTR Description Diode
SYMATTR Type diode
SYMBOL LED 240 -496 R270
WINDOW 0 32 32 VTop 2
WINDOW 3 0 32 VBottom 2
SYMATTR InstName D2
SYMATTR Value QTLP690C
SYMATTR Description Diode
SYMATTR Type diode
SYMBOL LED 384 -496 R270
WINDOW 0 32 32 VTop 2
WINDOW 3 0 32 VBottom 2
SYMATTR InstName D3
SYMATTR Value QTLP690C
SYMATTR Description Diode
SYMATTR Type diode
TEXT -280 40 Left 2 ;Controller0
TEXT 760 48 Left 2 ;Controller1
TEXT 304 360 Left 2 !.tran 1
RECTANGLE Normal 160 0 -400 304 2
RECTANGLE Normal 1200 0 208 304 2

One other option is to use the single GPIO and invert it using an NPN inverter. The NPN inverter is so slow that the inherent delay will cause the first one to turn off before the 2nd turns on. The delay is a function of the resistors though, so you have to play around with those to get what you want. The 2 GPIO pins with software control option is easier in that respect.

enter image description here

Version 4
SHEET 1 1204 680
WIRE -64 -512 -128 -512
WIRE 96 -512 16 -512
WIRE 240 -512 160 -512
WIRE 384 -512 304 -512
WIRE 560 -512 448 -512
WIRE -128 -480 -128 -512
WIRE 560 -384 560 -512
WIRE 560 -384 64 -384
WIRE 1104 -384 560 -384
WIRE -128 -368 -128 -400
WIRE 784 -336 560 -336
WIRE 560 -304 560 -336
WIRE 784 -304 784 -336
WIRE 64 -256 64 -384
WIRE 1104 -256 1104 -384
WIRE -128 -208 -176 -208
WIRE -112 -208 -128 -208
WIRE 0 -208 -32 -208
WIRE 784 -208 784 -224
WIRE 1040 -208 784 -208
WIRE 560 -192 560 -224
WIRE 784 -192 784 -208
WIRE -176 -176 -176 -208
WIRE -128 -144 -128 -208
WIRE 608 -144 -128 -144
WIRE 720 -144 688 -144
WIRE -176 -64 -176 -96
WIRE 784 -64 784 -96
WIRE 64 32 64 -160
WIRE 1104 32 1104 -160
WIRE -160 80 -304 80
WIRE -112 80 -160 80
WIRE 0 80 -32 80
WIRE 880 80 736 80
WIRE 928 80 880 80
WIRE 1040 80 1008 80
WIRE -304 128 -304 80
WIRE -160 128 -160 80
WIRE 736 128 736 80
WIRE 880 128 880 80
WIRE 64 176 64 128
WIRE 1104 176 1104 128
WIRE -304 256 -304 208
WIRE -160 256 -160 208
WIRE 736 256 736 208
WIRE 880 256 880 208
FLAG -304 256 0
FLAG -160 256 0
FLAG 64 176 0
FLAG 736 256 0
FLAG 880 256 0
FLAG 1104 176 0
FLAG -176 -64 0
FLAG -128 -368 0
FLAG 560 -192 0
FLAG 784 -64 0
FLAG -176 -208 GPIO
SYMBOL voltage -304 112 M0
WINDOW 123 0 0 Left 0
WINDOW 39 0 0 Left 0
SYMATTR InstName V1
SYMATTR Value 3.3
SYMBOL res -176 112 R0
SYMATTR InstName R1
SYMATTR Value 10k
SYMBOL res -16 64 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName R2
SYMATTR Value 220
SYMBOL npn 0 32 R0
SYMATTR InstName Q1
SYMATTR Value 2N2222
SYMBOL voltage 736 112 M0
WINDOW 123 0 0 Left 0
WINDOW 39 0 0 Left 0
SYMATTR InstName V2
SYMATTR Value PULSE(3.3 0 12.5m 10u 10u 12.5m 25m)
SYMBOL res 864 112 R0
SYMATTR InstName R3
SYMATTR Value 10k
SYMBOL res 1024 64 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName R4
SYMATTR Value 220
SYMBOL npn 1040 32 R0
SYMATTR InstName Q2
SYMATTR Value 2N2222
SYMBOL voltage -176 -192 M0
WINDOW 123 0 0 Left 0
WINDOW 39 0 0 Left 0
SYMATTR InstName V3
SYMATTR Value PULSE(3.3 0 70m 10u 10u 70m 140m)
SYMBOL npn 0 -256 R0
SYMATTR InstName Q3
SYMATTR Value 2N3904
SYMBOL res -16 -224 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName R5
SYMATTR Value 1k
SYMBOL npn 1040 -256 R0
SYMATTR InstName Q4
SYMATTR Value 2N3904
SYMBOL voltage -128 -496 R0
SYMATTR InstName V5
SYMATTR Value 12
SYMBOL res 32 -528 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName R7
SYMATTR Value 82
SYMBOL LED 96 -496 R270
WINDOW 0 32 32 VTop 2
WINDOW 3 0 32 VBottom 2
SYMATTR InstName D1
SYMATTR Value QTLP690C
SYMATTR Description Diode
SYMATTR Type diode
SYMBOL LED 240 -496 R270
WINDOW 0 32 32 VTop 2
WINDOW 3 0 32 VBottom 2
SYMATTR InstName D2
SYMATTR Value QTLP690C
SYMATTR Description Diode
SYMATTR Type diode
SYMBOL LED 384 -496 R270
WINDOW 0 32 32 VTop 2
WINDOW 3 0 32 VBottom 2
SYMATTR InstName D3
SYMATTR Value QTLP690C
SYMATTR Description Diode
SYMATTR Type diode
SYMBOL npn 720 -192 R0
SYMATTR InstName Q5
SYMATTR Value 2N3904
SYMBOL res 704 -160 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName R8
SYMATTR Value 10k
SYMBOL voltage 560 -320 R0
SYMATTR InstName V4
SYMATTR Value 3.3
SYMBOL res 768 -320 R0
SYMATTR InstName R9
SYMATTR Value 1k
TEXT -280 40 Left 2 ;Controller0
TEXT 760 48 Left 2 ;Controller1
TEXT 304 360 Left 2 !.tran 1
RECTANGLE Normal 160 0 -400 304 2
RECTANGLE Normal 1200 0 208 304 2

I won't get too much further into it, but you can use N-channel MOSFETs for either option. The main benefits for using MOSFETs are: (1) that you don't waste any current driving the gate since it is voltage controlled instead of current controlled, and (2) you can acheive much lower voltage drop across the transistor (low Rds(on) versus Vce(sat)) resulting in less power dissipation in the transistor. Your currents are quite low and you don't seem concerned about battery life, so it looks to me these won't effect you much. Sounds like if you reduced power/voltage-drop in your transistors, you would have to just increase your LEDs' series resistor to keep the 60mA you want...effectively just moving where the power will be dissipated.

\$\endgroup\$
5
  • 1
    \$\begingroup\$ I see now that the MUX was an unnecessary complication, this solution is brilliant thank you. \$\endgroup\$
    – superN8
    Commented Feb 23, 2023 at 23:29
  • \$\begingroup\$ I am curious though, why did you choose the 2N3904? Is that simply your jelly bean transistor of choice? I chose the 2N2222 and its compliment the 2N2907 because (it's my go-to for everything and) they generally have a higher current rating (not that it's of large concern as both options greatly exceed 60mA). \$\endgroup\$
    – superN8
    Commented Feb 23, 2023 at 23:57
  • 1
    \$\begingroup\$ @superN8 The 2N2222 and 2N2907 come in outdated TO-18 tin can cases. The 2N3904 and 2N3906 come in easier to use (and get) TO-92 and I have them in my part drawers if I ever need to work up something quick on the bench. It's also easy to find surface mount equivalents of them and also two of them in a single package, especially if you need matched pairs. A long-winded answer of "yes" to your "Is that simply your jelly bean transistor of choice?" question. If you notice, the SPICE models between my transistors and yours are almost identical. So it doesn't really matter besides current rating. \$\endgroup\$
    – Ste Kulov
    Commented Feb 24, 2023 at 0:30
  • \$\begingroup\$ you mentioned in the comments you could propose a solution using MOSFETs, i have a better understanding now of how they are more efficient but Ive been struggling to apply them. I tried using N-channel as drop in replacements for the NPNs, but that resulted in lots of current spikes. I asked another question (that better portrays my lack of understanding about the components im tryin lm trying to use) about it on this site, but I wanted to ask if youd be willing to share the idea you mentioned \$\endgroup\$
    – superN8
    Commented Mar 4, 2023 at 22:36
  • 1
    \$\begingroup\$ Link to follow-up question: electronics.stackexchange.com/questions/657307/… \$\endgroup\$
    – Ste Kulov
    Commented Mar 6, 2023 at 2:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.