Author Topic: Bypassing caps - for transistors driving a 7-seg display  (Read 1372 times)

0 Members and 1 Guest are viewing this topic.

Offline SaimounTopic starter

  • Frequent Contributor
  • **
  • Posts: 570
  • Country: dk
Bypassing caps - for transistors driving a 7-seg display
« on: October 11, 2020, 08:45:55 am »
Hi

I have a simpe circuit with a multiplexed 7-segment display. I'd like to reduce the noise generated by the display on the power line, so I am thinking adding some extra bypass caps.

Problem is it is driven by my MCU directly (for many reasons), which only has one VDD and one VSS pin. There are already bypass caps right next to the MCU.
The circuit is very "standard" with transistors:
  • The display is common anode, using one PNP transistor on each digit
  • each PNP transistor has its emitter connected to VDD
  • and its base connected to a GPIO (active low)
  • each segment is directly connected to a GPIO (also active low)
(basically similar to the one shown here: https://www.onetransistor.eu/2018/12/wiring-of-4digit-7segment-display.html)

My question is: will it help adding some bypass capacitors next to the PNP transistors (since they are connected to the VDD line), even though the loop is quite large?
By "large loop" I mean that when I follow the current it goes:
* VDD -> PNP transistor -> LED's inside the display -> GPIO pins of the MCU -> VSS pin of the MCU -> GND

Thinking about the loop, it looks like ideally I will need a bypass cap with one end next to the PNP transistor, and the other end next to the VSS pin of the MCU. (But it's not really possible to place the PNP transistors next to the MCU as this is already a very crowded area on the PCB). What are your thoughts on this?

Thank you!  ;D

Simon
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 3832
  • Country: nl
Re: Bypassing caps - for transistors driving a 7-seg display
« Reply #1 on: October 11, 2020, 10:31:26 am »
Noise is generated by fast switching stuff, and fast changing currents.

There are a lot of things you can do to reduce it.

Start by increasing the base resistors for your transistors to drive them less strongly, but beware of production tolerances in Hfe. Then add capacitors between base and emitter to make your transistors switch slower, or, probably even better, add the capacitors between base and collector to make good use of the miller effect.
When you deliberately make the switching slower, you probably also have to increase the "dead time" during multiplexing to prevent ghosting on the display.

Another trick you can do is to use NPN transistors. These would then be used as emitter followers in a Common Anode display.

Your LED displays are high current devices, so decoupling with a few 100nF capacitors is probably not sufficient. Adding some bigger Buffer caps in addition to small ceramic caps is probably a good idea, and also add an inductor in series to make an LC filter. LC filters are notorious for oscillation, so also add a series resistor to bring the Q of the filter down to 0.7

Then there is the physical layout of the PCB, which is a very important part of the design to mitigate noise from switching effects.

In the circuit you linked to there are both base drive resistors and resistors for limiting the segment currents.
Draw an imaginary circle around the display on the PCB, and put all resistors on the edge of that circle. The goal is to keep the noise inside the circle, and use the resistors as a barrier for the noise to get out.
Also put the components of the RLC filter on the boundary line. Some physical distance between the display and the uC may also help a bit, but most noise is likely to be condcuted through the wires.
 
Additional to all this, you should reduce the area of a current to the display, and it's return path through the GND plane. GND should be continuous, or at least as close as possible to each conductor of the display.

The next part to think about is your microcontroller itself, and the currents that go on there. If you go from zero current during the dead time for your display, to displaying an "8", (all 7 segments on) and each segment has 12mA, that is from 0 to 84mA for your poor microcontroller, and even if you have ideal decoupling on your micro controntroller itself, this will introduce voltage changes over the resistance of the bond wires in the chip, and this is quite a nuisance if you also want to use the ADC in the chip for measurements. For a common Cathode display the segment currents are through the GND pin of your microcontroller, and will therefore change the GND level of the die inside the chip compared to the GND level on your PCB.

The only real solution for this is to separate the "measuring part" from the "display part", in such a way that this 84mA does not go through the same chip which you use as GND reference for the ADC. This can be done in several different ways. Some of them are:
* Use an external ADC such as ADS1115.
* Use a ULN2803 to switch the cathode currents of the display (put this chip also on that circle)
* Use a separate uC for the display, ideally via I2C which is (should be) slew rate limited.
 

Offline SaimounTopic starter

  • Frequent Contributor
  • **
  • Posts: 570
  • Country: dk
Re: Bypassing caps - for transistors driving a 7-seg display
« Reply #2 on: October 11, 2020, 11:45:35 am »
Thank you for this very detailed answer - very valuable knowledge :)

Then add capacitors between base and emitter to make your transistors switch slower, or, probably even better, add the capacitors between base and collector to make good use of the miller effect.
This is interesting and not something I have heard before - would you care to develop? Thanks :)

Also even though as I understood from your answer there are many other ways to reduce the noise, what is the answer to my specific question - i.e. will bypass caps between VDD and VSS located next to the transistors help, or should I just get rid of them?
« Last Edit: October 12, 2020, 10:56:34 am by simonlasnier »
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 17117
  • Country: us
  • DavidH
Re: Bypassing caps - for transistors driving a 7-seg display
« Reply #3 on: October 11, 2020, 11:11:30 pm »
My question is: will it help adding some bypass capacitors next to the PNP transistors (since they are connected to the VDD line), even though the loop is quite large?
By "large loop" I mean that when I follow the current it goes:
* VDD -> PNP transistor -> LED's inside the display -> GPIO pins of the MCU -> VSS pin of the MCU -> GND

Thinking about the loop, it looks like ideally I will need a bypass cap with one end next to the PNP transistor, and the other end next to the VSS pin of the MCU. (But it's not really possible to place the PNP transistors next to the MCU as this is already a very crowded area on the PCB). What are your thoughts on this

You got it exactly right; add the capacitors between the PNP emitters and the Vss pin of the MCU to minimize the high current loop area.
 

Offline SaimounTopic starter

  • Frequent Contributor
  • **
  • Posts: 570
  • Country: dk
Re: Bypassing caps - for transistors driving a 7-seg display
« Reply #4 on: October 12, 2020, 07:16:18 am »
Ok thanks  ;D
But like I said they are not next to each other since the MCU area is quite crowded - also I have 3 transistors (3 digits).
But I put my caps next to the transistors, and the GND return path to VSS is as short as it can be.

On the other side, reading Doctorandus' answer makes me think that as much as I liked driving the display from the MCU maybe it is a bad idea anyways...
I reduced the currents a lot by using 220Ohm resistors - with my 3.3V supply it should give max 8mA current per segment (probably less), but like Doctorandus said going from black to an 8 on the display still means a change from (almost) 0mA to 56mA, that sounds heavy (I am also thinking in terms of EMI).
« Last Edit: October 12, 2020, 10:58:54 am by simonlasnier »
 

Offline SaimounTopic starter

  • Frequent Contributor
  • **
  • Posts: 570
  • Country: dk
Re: Bypassing caps - for transistors driving a 7-seg display
« Reply #5 on: October 12, 2020, 09:58:32 am »
Then add capacitors between base and emitter to make your transistors switch slower, or, probably even better, add the capacitors between base and collector to make good use of the miller effect.
Ok I have looked a bit into this, and I think it will really help if I go with the MCU-driving option.

I am not so sure which values I should put though, or how I calculate the change time.

I want to go from 0mA to 8mA and back, going from 3.3V to 0V (and back) on the base. The circuit:
* GPIO1 -> 4.7k res -> base
* 3.3V rail -> emitter
* collector -> 220 ohm res -> red LED (about 1.6V-1.8V drop) -> GPIO2 (already high = 3.3V)
* we add a 22nF cap between the base and the collector

with GPIO1 high (3.3V) the cap is fully discharged.
Then if I change GPIO1 from high to low, the cap and 4.7k res make an RC circuit and the cap is "fully" charged after 5*RC=0.52ms
Then if later I change GPIO1 from low to high, the caps is discharged through the 4.7k resistor, so again "fully" discharged after 0.52ms

I am pretty sure here I remove the fact that it is charged through the BJT which will only be "ON" while the base voltage is changing - so my guess is these values are very wrong and the chargin/discharging time is a lot more... Is it something like 0.52ms*hfe?

Thanks

PS: FYI this is the transistor I am using: https://assets.nexperia.com/documents/data-sheet/PMBT3906.pdf
« Last Edit: October 12, 2020, 10:57:03 am by simonlasnier »
 

Offline SaimounTopic starter

  • Frequent Contributor
  • **
  • Posts: 570
  • Country: dk
Re: Bypassing caps - for transistors driving a 7-seg display
« Reply #6 on: October 12, 2020, 10:11:25 am »
Ok sorry still thinking - I can see my calculations are right if the cap is between the emitter and the base?, right? Because in this case it does not charges *through* the transistor, but directly from the 3.3V rail and through the 4.7k res.
 

Offline Vovk_Z

  • Super Contributor
  • ***
  • Posts: 1454
  • Country: ua
Re: Bypassing caps - for transistors driving a 7-seg display
« Reply #7 on: October 12, 2020, 10:45:40 am »
Emitter-base cap is not "bypass" cap, but it is a low-frequency filter, it lowers the rise and fall time.
 

Offline SaimounTopic starter

  • Frequent Contributor
  • **
  • Posts: 570
  • Country: dk
Re: Bypassing caps - for transistors driving a 7-seg display
« Reply #8 on: October 12, 2020, 10:55:53 am »
Yes my last comments are not about the bypass caps - they are about me trying to implement what Doctorandus mentionned in his comment.

My plan is to keep one or two 4.7uF caps (between VDD and GND) around the transistors to help global decoupling, and then add these filter caps.
« Last Edit: October 12, 2020, 10:58:23 am by simonlasnier »
 

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 14749
  • Country: de
Re: Bypassing caps - for transistors driving a 7-seg display
« Reply #9 on: October 12, 2020, 11:24:18 am »
The transistors are usually not such a big problem. The base resistor alone avoid really fast transitions to worry about RF emissions. With some µCs one can slow down the GPIO pins to switch a little slower.
Slowing it down with extra caps only needs an extra dark phase between segments.
The faster switching would be at the segments anyway.

Using a single resistor at the common anode makes the brightness depend on the displayed value: a 8 looks less bright than a 1. It would be about 8 mA total, not 8 mA per segment.
The normal way would be a resistor for each output of the µC to drive the segments. Than it may get ~ 8 mA per segment - not sure if so much current is needed.

With only 3.3 an NPN transistor is not a real option, as another 0.7 V would be lost.

With the LEDs it would be more about lower frequencies. So not some 100 nF, but more like some 100 µF.
 

Offline SaimounTopic starter

  • Frequent Contributor
  • **
  • Posts: 570
  • Country: dk
Re: Bypassing caps - for transistors driving a 7-seg display
« Reply #10 on: October 12, 2020, 03:22:40 pm »
Thank you for the answer, I am a bit confused about it though.

Quote
Slowing it down with extra caps only needs an extra dark phase between segments.
The faster switching would be at the segments anyway.
What is an extra dark phase? and do you mean adding caps between base and emitter add phase?

Quote
Using a single resistor at the common anode makes the brightness depend on the displayed value: a 8 looks less bright than a 1. It would be about 8 mA total, not 8 mA per segment.
The normal way would be a resistor for each output of the µC to drive the segments. Than it may get ~ 8 mA per segment - not sure if so much current is needed.
I agree :) And apologies for the confusion I can see I wrote before:
collector -> 220 ohm res -> red LED (about 1.6V-1.8V drop) -> GPIO2 (already high = 3.3V)
what I meant was:
collector -> red LED (about 1.6V-1.8V drop) -> 220 ohm res -> GPIO2 (already high = 3.3V)
(i.e. there is one 220 ohm res per segment)
 

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 14749
  • Country: de
Re: Bypassing caps - for transistors driving a 7-seg display
« Reply #11 on: October 12, 2020, 03:30:49 pm »
When the PNP transistors switch to slow, they are also slow turning off. So when switching from one digit to the next one would not to do it with an extra short phase in between where all segments are off. So digit1 , off, digit2 , off , ....
Otherwise one would see some leakage from one digit to the next.
 

Offline SaimounTopic starter

  • Frequent Contributor
  • **
  • Posts: 570
  • Country: dk
Re: Bypassing caps - for transistors driving a 7-seg display
« Reply #12 on: October 12, 2020, 04:00:44 pm »
Oh ok I understand now  8)
But yes Doctorandus already mentionned that ("you probably also have to increase the "dead time" during multiplexing to prevent ghosting on the display.").

And the nice thing about driving the display directly from the MCU is that I am in full control of the multiplexing - so I can easily add a bit more time between switching.
 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2141
  • Country: us
Re: Bypassing caps - for transistors driving a 7-seg display
« Reply #13 on: October 12, 2020, 05:34:47 pm »
This may not be relevant if you've already built your board, but there's an alternative way to multiplex 7-segment displays that would reduce the parts count and possibly help with the noise.  The alternative is to multiplex by segment instead of by digit.

On each refresh you would turn on one of the segment drivers together with the anodes of the digits which should have that segment lit.  Then on subsequent refreshes you do the other segment lines one at a time.  This means that a segment driver would have to sink current for a maximum of three segments at a time, and the anode driver only has to source current for one segment at a time.  So of course you don't need the transistors at all, or any resistors on the segment lines, just a single resistor on each anode.  That might leave room for your additional caps.

The maximum current the circuit has to deal with is three segments at a time rather than seven segments at a time.  But you have to refresh 7/3 as often to prevent flicker, which means the resistors have to be 3/7 of 220R to produce the same brightness.  So at least in theory the total current is the same as multiplexing by digit to achieve the same brightness, which you would expect given the "no free lunch" rule.

And I don't know what this does to noise.  Speaking of noise, are you actually seeing noise on the 3.3V rail on your scope?  I ask because I don't recall 7-segment displays being a big noise problem.

Here's a video on multiplexing by segment:



As mentioned in the video, there actually is one free lunch which could significantly impact your current draw, and that is the efficiency of your display, which varies quite a bit among displays.
 

Offline SaimounTopic starter

  • Frequent Contributor
  • **
  • Posts: 570
  • Country: dk
Re: Bypassing caps - for transistors driving a 7-seg display
« Reply #14 on: October 13, 2020, 07:04:06 am »
Hey Peabody thanks this is brilliant thinking  8) ;D

I really like the idea of dropping a few resistors and the transistors. My system has 8 segments (with DP) and 3 digits.
If I make the math, I had before:
* 8 segments
* 8mA per segment
* 64mA total (with all segments on)
* duty 1/3

To get the same brightness I need to change my resistors by 8/3. Then I get:
* 3 digits
* 8mA * 8/3 = 21.3mA per digit
* 64mA total (with all digits on - yes there's no free lunch)
* duty 1/8

I still think it is brilliant, it removes the transistors which in my case will be one thing less off the BOM. Problem is 21.3mA is close to the limit for one GPIO, my small MCU has a 25mA absolute maximum rating limit. But truth is I think I can go a bit lower, it will also lower the 64mA total.

I will try it and let you know!

EDIT: Ahh wait - I just realized that still means that if you are sourcing 21.3mA per digit, and for a given segment you have all 3 digits on, then it means your segment pin is sinking the 64mA! That would be over the specs for most MCUs :/ One way is to stick to the 8mA, that means maximum 24mA for one pin (still a bit too close to 25 IMO), but since the duty is 1/8 that makes the display significantly less bright. It will works ok on a two digit display depending on the brightness requirements :)
So I think I will go back to the original idea - I will make a new post to ask about the Miller effect/caps on the transistor since this post's question is answered. Thank you all :)

EDIT2/PS: Peabody I have given it a few more thoughts, actually the one and only thing you gain by multiplexing on the segments instead of the digits is a few resistors. My analysis with (f.x.) 8 segments and 2 digits:

Case 1 - You are multiplexing on the segments (like you said)
Let's say using 10mA per digit
In this case you get on your MCU:
* 10mA on each digit pin
* 20mA (max) on each segment pin
* What you "see" is 10/8 = 1.25mA per segment (since you have a duty cycle of 1/8)

Let's compare with
Case 2 - You are multiplexing on the digits
If you are using 2.5mA per segment, then you get on your MCU:
* 2.5mA on each segment pin
* 20mA (max) on each digit pin
* What you "see" is actually 2.5/2 = 1.25mA per segment (with a 1/2 duty cycle)

Basically in both cases you are limited by how much one pin of your MCU can handle. And when using transistors to get to higher currents, clearly multiplexing on the digits makes more sense since then you only need 3 transistors (instead of 8 ).
« Last Edit: October 13, 2020, 12:31:20 pm by simonlasnier »
 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2141
  • Country: us
Re: Bypassing caps - for transistors driving a 7-seg display
« Reply #15 on: October 13, 2020, 02:33:00 pm »
Yes, it all depends on being able to sink enough current through a GPIO pin without resorting to a transistor.  But I would just ask you to notice near the end of the video that I am using a 680R resistor in the digit line, and the rail is 3.3V.   So that's 2mA per digit pin and 4mA per segment driver pin, and even the lowly TI MSP430G2553 can handle that.  And it looks acceptably bright to me in normal room lighting.  Yet if your 220R is right, I should need a 100R resistor.  So you might consider whether you really need 220R, and if you do, then you might consider whether a more efficient display would make a major difference in current draw and effectively eliminate any noise problems along with all those resistors and transistors.

The other thing is that while the perception of bightness by humans is supposed to be a function of the average illumination over time, I'm not sure the relationship is linear.  I can't prove it, but I wonder if an LED segment that's on only 1/7 or 1/8 of the time really appears to be as dim as the numbers say it's supposed to be.

« Last Edit: October 13, 2020, 02:45:25 pm by Peabody »
 

Offline SaimounTopic starter

  • Frequent Contributor
  • **
  • Posts: 570
  • Country: dk
Re: Bypassing caps - for transistors driving a 7-seg display
« Reply #16 on: October 14, 2020, 12:11:52 pm »
Well as far as i know our eyes react exponentionally to light - just like our ears to sound level.

So yes, going from 6mA to 3mA will not look "half as bright", just a bit dimmer ;)

You have a good point about the efficiency of the display. I am using the cheapest display I could find, and testing it I find that below 2mA (average) per segment it really looks dim to me (with your 660R resistor it goes down to 2/8=0.25mA average). Maybe it is also because my display is large (0.8'' digits), so already at 2mA average you start to see that there is more light in the middle of the segments than on the edge.

Anyways, thanks for the help :D I actually did loads of testing on the display as well as measuring a lot the effect of capacitors and will end up adding one 22nF cap between emitter and base on each transistor. I will also add two 4.7uF caps between VDD and GND between the transistors and the MCU, to help global decoupling. That should be enough in my case :)
 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2141
  • Country: us
Re: Bypassing caps - for transistors driving a 7-seg display
« Reply #17 on: October 14, 2020, 02:09:11 pm »
Well for future reference, the displays I used were Vishay single digits.  I don't think Vishay makes multi-digit modules, but I have a Kingbright 4-digit module CC56-21SRWA which is also pretty bright.  That's .56" digit size.  A 3-digit common anode would be CA56-12SRWA.  Anyway, I'm glad you found a solution.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf