Author Topic: Critique my LED PWMer  (Read 7116 times)

0 Members and 1 Guest are viewing this topic.

Offline robzyTopic starter

  • Regular Contributor
  • *
  • Posts: 119
  • Country: au
Critique my LED PWMer
« on: October 17, 2021, 08:52:59 am »
So I have a few LEDs that I'll be running at 1-amp so that they meet their characterised spec (i.e. wavelength of light) but I want to run them at low brightness/power.

So I've come up with the following schematic which I think will achieve that. Every 6.66 milliseconds (i.e. 150Hz) it will turn the LED on for anywhere between 1 microsecond and 256 microseconds.

I expect there might be some slight inaccuracies ~10% at low brightness, like for the 1 or 2 microseconds pulses, because of the turn-on time of the MOSFETs and LEDs, but I can live with that.

What do you think? Have I done anything bone-headed?




Links to semiconductor datasheets:
MCP1404: https://ww1.microchip.com/downloads/en/devicedoc/22022b.pdf
SSM3K345R: https://toshiba.semicon-storage.com/info/docget.jsp?did=55842&prodName=SSM3K345R
 

Offline moffy

  • Super Contributor
  • ***
  • Posts: 1695
  • Country: au
Re: Critique my LED PWMer
« Reply #1 on: October 17, 2021, 10:06:58 am »
Your circuit is pretty straight forward, not much to go wrong. I assume you chose the resistors to match the different voltage drops of the LEDs, and 150Hz should be above noticeable flicker. Is it wise to use the Tx pin? Is that used for serial coms? Might want to keep that free if it is.
 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6209
  • Country: fi
    • My home page and email address
Re: Critique my LED PWMer
« Reply #2 on: October 17, 2021, 10:27:39 am »
I'm only a hobbyist, so I cannot say anything about your circuit, really.  The reason I'll annoy you with my opinion, is that I've got a couple of DIY LED lights (a floor-standing reading light) I'd like to dim, preferably down close to zero output if desired, but have it be silent (since I like quiet when reading; any buzzing annoys me), so perhaps my real-world observations may help.  If not, feel free to ignore!

For a stroboscopic effect, 150 Hz is in my opinion borderline, possibly problematic.  When tired, I can definitely perceive the 100 Hz flicker from fluorescent lights, and it is not only annoying but occasionally causes headaches.  Although the frequency is higher, the relatively large dead time between pulses may make it more observable.  Furthermore, the switching frequency most likely yields audible noise.

(I do understand that my preferred solution, something like TPS61169 which LCSC has TPS61169DCKR (SC-70-5) in stock for under $1 USD apiece as of 2021-10-17, will probably not work for you, since your duty cycle varies from 0.015% to 3.88%, and these typically don't go that low; I think TPS61169 practical minimum is something around 1-2%.)
 
The following users thanked this post: tooki

Offline NiHaoMike

  • Super Contributor
  • ***
  • Posts: 8998
  • Country: us
  • "Don't turn it on - Take it apart!"
    • Facebook Page
Re: Critique my LED PWMer
« Reply #3 on: October 17, 2021, 02:32:54 pm »
150Hz probably won't cause a visible flicker, but there's really no reason to not use a few kHz or more instead. Add 10 ohm or so resistors in series with the MOSFET gates to prevent ringing. Add 10k pulldowns on the MOSFET driver inputs to prevent spurious operation during boot. The decoupling capacitor seems quite small so make a provision to fit a bigger one instead.

If you're making a PCB, add (spots for) extra channels on each PWM capable pin if space allows even if you have no immediate plan to use them. Break out all other remaining pins to test points. You might want to think about provisions for improvements like a spot for a light sensor and different options for the power input connector. Remember that you pay for board area and not the "complexity" of the board given the same number of layers.
Cryptocurrency has taught me to love math and at the same time be baffled by it.

Cryptocurrency lesson 0: Altcoins and Bitcoin are not the same thing.
 

Offline StillTrying

  • Super Contributor
  • ***
  • Posts: 2850
  • Country: se
  • Country: Broken Britain
Re: Critique my LED PWMer
« Reply #4 on: October 17, 2021, 04:22:31 pm »
Every 6.66 milliseconds (i.e. 150Hz) it will turn the LED on for anywhere between 1 microsecond and 256 microseconds.

If it's for illumination all of those short on times at 150 Hz would be very visible and annoying, - to me.
.  That took much longer than I thought it would.
 
The following users thanked this post: tooki

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8156
  • Country: fi
Re: Critique my LED PWMer
« Reply #5 on: October 17, 2021, 04:22:40 pm »
150Hz causes almost definitely disastrously noticeable flicker, unless you only use low intensity LEDs at high duty cycles so that it doesn't matter. I don't understand how this is so difficult year after year. It's discussed dozens of times on this forum, yet all the otherwise very intelligent frequent contributors get this wrong time after time.

For anything running at low duty cycles or high intensity LEDs (schematic does say "1 amp LED"), go for 1kHz bare minimum. If you don't want to hurt tooki's eyes, go for 2kHz bare minimum.

And at least 12-bit PWM resolution is highly recommended.
« Last Edit: October 17, 2021, 04:24:30 pm by Siwastaja »
 
The following users thanked this post: tooki

Offline NiHaoMike

  • Super Contributor
  • ***
  • Posts: 8998
  • Country: us
  • "Don't turn it on - Take it apart!"
    • Facebook Page
Re: Critique my LED PWMer
« Reply #6 on: October 17, 2021, 05:46:06 pm »
A lot of modern LCD monitors pulse at 120Hz to reduce motion blur. If 120Hz flicker really is that noticeable to most users, that feature won't sell very well. (Where that typically becomes insufficient is in 3D mode where the glasses split that to 60Hz, a big reason why 3D TV failed.)

In this case, the hardware can easily go well into 10s of kHz before switching losses even start to become significant (and the upper practical frequency is likely into the hundreds of kHz), thus the frequency is a software selection that plays almost no part in the hardware design.

One other thing is that by adding provision for resistors in series with the MOSFET source and a NPN transistor pulling down the gate when the voltage across that resistor gets to about 0.65V, you can make it a constant current driver. You'll also have to raise the gate resistor to 100 ohms or above to not get excessive current from the gate driver and consider the dissipation in the MOSFET which would then be operating in linear mode.
Cryptocurrency has taught me to love math and at the same time be baffled by it.

Cryptocurrency lesson 0: Altcoins and Bitcoin are not the same thing.
 

Offline magic

  • Super Contributor
  • ***
  • Posts: 6735
  • Country: pl
Re: Critique my LED PWMer
« Reply #7 on: October 17, 2021, 05:52:04 pm »
They don't pulse at 120Hz, they refresh at 120Hz. I'm sure their backlight PWM runs at many kHz.

I found that several hundred Hz is the minimum not to see flicker even when the light source (or something illuminated by it) moves fast in the corner vision, which is where the strobe effect becomes worst.
 
The following users thanked this post: tooki

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8156
  • Country: fi
Re: Critique my LED PWMer
« Reply #8 on: October 17, 2021, 06:42:33 pm »
A lot of modern LCD monitors pulse at 120Hz to reduce motion blur.

... at high duty cycle, not 5% for example.
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8156
  • Country: fi
Re: Critique my LED PWMer
« Reply #9 on: October 17, 2021, 06:47:56 pm »
They don't pulse at 120Hz, they refresh at 120Hz. I'm sure their backlight PWM runs at many kHz.

They do have this "flicker mode". The point is, as explained above by NiHaoMike, to reduce motion blur. If you just "update" at 120Hz but have continuous backlight, your eyes kind of integrate the image continuously, making the two adjacent frames "blur" together. Which isn't necessarily a bad thing. But some prefer to see crisper, sharper images during motion, in that case the answer is to add flicker deliberately by showing the image... then show some black screen... then show the next image. So blink the backlight in sync with the updates. Like the good old CRT TV did, or the good old cinema film projector did. (The film projector did show the same image twice or three times, though, causing interesting effects.)

So the mentioned mode simulates old tech and adds flicker deliberately. The flicker has to be at the same frequency as the update rate, but they can still adjust the flickeriness (is that a word) by adjusting duty cycle. Go too low, and it's too flickery for most users.
 
The following users thanked this post: NiHaoMike

Offline magic

  • Super Contributor
  • ***
  • Posts: 6735
  • Country: pl
Re: Critique my LED PWMer
« Reply #10 on: October 17, 2021, 07:06:06 pm »
Okay, I didn't realize it's a thing. Guess I'm not enough of a gamer ::)
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9887
  • Country: us
Re: Critique my LED PWMer
« Reply #11 on: October 17, 2021, 09:49:57 pm »
Quote
Every 6.66 milliseconds (i.e. 150Hz) it will turn the LED on for anywhere between 1 microsecond and 256 microseconds.

So, the LED is only going to be on for a very small percentage of the time.  It looks like about 3.8% of the time, maximum.  Hm...

You should breadboard this thing before getting too invested.
 

Offline robzyTopic starter

  • Regular Contributor
  • *
  • Posts: 119
  • Country: au
Re: Critique my LED PWMer
« Reply #12 on: October 18, 2021, 03:16:16 am »
Thanks all for your input! I hear what you're saying about the 150Hz PWM rate. I would've preferred 1kHz+, but there's a reality face when you want to scale down the 1A current to 1mA.

At the end of the day the PWM module is very configurable, and I can change the current resistors, so I have a lot of freedom to experiment and fine-tune when its built. Right now I'm mostly focusing on the topology.

Two questions have occured to me as I've been choosing parts on DigiKey:

1) Doing 1-amp of current for 256uS of every 6666uS period. This will be an average of 1A*256/6666=38mA, but what will my USB port see? I've loaded the LEDs up with 100uF of capacitance to smooth the load on the USB port, but is that enough? I've done some Google and can't find much in the way of calculating the waveform of power that will be drawn from the USB port.

2) Turns out that the gate driver IC datasheet requests a 1uF film decoupling capacitor. These are bigger than I want on my PCB. How can I determine the impact of choosing a lower value? I'm aware that the goal is to as-quickly-as-possible push charge into the MOSTFET gate to turn it on, but 1uF seems like an over-abudance of capacity.
« Last Edit: October 18, 2021, 04:17:02 am by robzy »
 

Offline magic

  • Super Contributor
  • ***
  • Posts: 6735
  • Country: pl
Re: Critique my LED PWMer
« Reply #13 on: October 18, 2021, 06:02:09 am »
Thanks all for your input! I hear what you're saying about the 150Hz PWM rate. I would've preferred 1kHz+, but there's a reality face when you want to scale down the 1A current to 1mA.
MOSFETs switch in a fraction of a microsecond.

2) Turns out that the gate driver IC datasheet requests a 1uF film decoupling capacitor. These are bigger than I want on my PCB. How can I determine the impact of choosing a lower value? I'm aware that the goal is to as-quickly-as-possible push charge into the MOSTFET gate to turn it on, but 1uF seems like an over-abudance of capacity.
Is it some very old driver? Why not MLCC? Still low ESR, even less ESL, very small.
 
The following users thanked this post: tooki

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8156
  • Country: fi
Re: Critique my LED PWMer
« Reply #14 on: October 18, 2021, 08:11:29 am »
1uF MLCC for the gate driver comes in 0402 or 0603 package, not a problem.

You can easily switch the MOSFETs in 50ns, but can choose to use 100ns or so to reduce EMI a bit. Even then, 0.2µs total spent in switching is still small compared to planned minimum on-time of 1µs. It starts to show some minor non-linearity, though. Flicker will be the real problem at such low duty cycle. You may want to up the freq even if that means that your minimum on-time is even lower and the low side control steps will be even more non-linear. You want to test that out in practice. At very low duty cycles, a large part of conduction period will be partially conducting i.e. switching loss but this doesn't need to be a problem. It does kill the efficiency, but only when measured as a percentage of that already very low average current, usually this doesn't matter. (In practice, what I mean is current consumption goes down and down as you dim the LEDs, but at the few lowest steps, LED brightness goes down faster than the current consumption does.)

150Hz frequency also has the problem of requiring significantly more bypass capacitance not to make the USB port see the 1A peak current.

In worst case, capacitors alone might not do it, an LC filter would help with the ripple current the USB port sees, but likely you don't need to go that far. It's all about optimizing size and cost.
« Last Edit: October 18, 2021, 08:13:37 am by Siwastaja »
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8156
  • Country: fi
Re: Critique my LED PWMer
« Reply #15 on: October 18, 2021, 08:18:22 am »
To get a more exact idea of the waveform the USB port sees, I suggest you simulate this in Spice, approximating the USB cable and connector resistance and inductance, ESR of the capacitors, and so on.

For example, draw a 5V voltage source with 0.1ohm series resistor and 100nH series inductor, then your 100uF electrolytic capacitor with ESR set to say 5 ohms, and then the 1A current source running PWL value list going between 0 and 1A with some 100ns rise/fall times.

The answer likely is to add MLCCs because the ESR of the elcap is too high compared to the ESR of the USB port. Then if you remove the electrolytic cap, you could see how the very low ESR MLCCs make the thing oscillate, at least during power-up transient. So you add the elcap back in parallel with the MLCCs and be happy with it.

But try to simulate this, it'll be interesting and LTSpice is free to download.
 
The following users thanked this post: tooki

Offline robzyTopic starter

  • Regular Contributor
  • *
  • Posts: 119
  • Country: au
Re: Critique my LED PWMer
« Reply #16 on: October 18, 2021, 11:43:57 am »
Thanks for the nods-of-approval for the 1uF MLCC, I'll switch to those. I'll also throw some across the LED's 100uF tantulum caps.

It starts to show some minor non-linearity, though. Flicker will be the real problem at such low duty cycle. You may want to up the freq even if that means that your minimum on-time is even lower and the low side control steps will be even more non-linear. You want to test that out in practice. At very low duty cycles, a large part of conduction period will be partially conducting i.e. switching loss but this doesn't need to be a problem.
Yep. That's my thinking on the matter as well. The non-linearity is material and it sucks, but the good news is that it seems like there's a delay in both MOSFET turn-on *and* turn-off, which will cancel out some of the non-linearity. At the end of the day I just want to get it built and start testing. Firmware is flexible and LED current resistors can be changed.


To get a more exact idea of the waveform the USB port sees, I suggest you simulate this in Spice, approximating the USB cable and connector resistance and inductance, ESR of the capacitors, and so on.
Its disappointing that it's not possible to calculate this analytically. To my naive mind the 100uF capacitor I'm using will simply form a low-pass LC filter. It's just not the usual "filtering a voltage source", instead it "filters a current sink".

Anyway, I've decided that I'll just use a USB powerbank which can comfortable handle 1A. And really, most USB ports (especially USB3) shouldn't struggle with this load.
 

Offline tooki

  • Super Contributor
  • ***
  • Posts: 11425
  • Country: ch
Re: Critique my LED PWMer
« Reply #17 on: October 18, 2021, 01:19:28 pm »
A lot of modern LCD monitors pulse at 120Hz to reduce motion blur. If 120Hz flicker really is that noticeable to most users, that feature won't sell very well. (Where that typically becomes insufficient is in 3D mode where the glasses split that to 60Hz, a big reason why 3D TV failed.)
The flicker of an image and the flicker of an LED are different things. The only things in motion on a screen are things within the image.

When LEDs are used for lighting and indication, the user is often moving, or the LED may be in motion. These cause very different issues.


People REALLY need to learn that the frequencies for frame rates and the ones for PWM are in no way comparable.
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8156
  • Country: fi
Re: Critique my LED PWMer
« Reply #18 on: October 18, 2021, 03:41:47 pm »
Thanks for the nods-of-approval for the 1uF MLCC, I'll switch to those. I'll also throw some across the LED's 100uF tantulum caps.

Across the LEDs? I hope that's a typo :).

Tantalum is a bit iffy, but USB is kinda current limited with some source resistance usually there limiting inrush so it's not a huge issue. Still, remember to derate voltage, 10V or 16V part is needed for 5V bus, and look up the inrush current specification and max ripple current from the datasheet.

USB spec limits allowable bus capacitance (to limit inrush duration), if I recall correctly that's some 47µF, so you need to add a precharge circuit to be able to use more. It's getting some sort of PITA.

If you don't have precharge, you can't have much capacitance, and if you don't have much capacitance, the USB sees all those 1A peaks, in which case you would need to enumerate and ask for more current, or hope everything's OK.

Its disappointing that it's not possible to calculate this analytically.

Of course you can, but the equations get really complex when you include "everything", including cable ESR, ESL, capacitor C, ESR, ESL, and possibly C, ESR and ESL of another set of (different type of) capacitors. Spice handles coming up with all the equations and solving them for you. Tools are there to help.
« Last Edit: October 18, 2021, 03:43:30 pm by Siwastaja »
 

Offline magic

  • Super Contributor
  • ***
  • Posts: 6735
  • Country: pl
Re: Critique my LED PWMer
« Reply #19 on: October 18, 2021, 04:51:52 pm »
The non-linearity is material and it sucks, but the good news is that it seems like there's a delay in both MOSFET turn-on *and* turn-off, which will cancel out some of the non-linearity. At the end of the day I just want to get it built and start testing. Firmware is flexible and LED current resistors can be changed.
Delay times are determined by the amount of charge that needs to be moved before reaching the Miller plateau.
The actual switching is an approximately linear ramp determined by Miller capacitance and drive current (i.e. by voltage and resistance).
You can probably get it quite symmetric by driving with a voltage roughly 2x the Miller plateau voltage (3.3V may do).

 

Offline robzyTopic starter

  • Regular Contributor
  • *
  • Posts: 119
  • Country: au
Re: Critique my LED PWMer
« Reply #20 on: October 19, 2021, 03:55:52 am »
Across the LEDs? I hope that's a typo :).
"Across the capacitor belonging to the LEDs" :P The ownership apostrophe in LED's was important.

Still, remember to derate voltage, 10V or 16V part is needed for 5V bus, and look up the inrush current specification and max ripple current from the datasheet.
Thanks for the reminder. Did you mean that the capacitor datahseet will have an inrush current specification and max ripple current?

USB spec limits allowable bus capacitance (to limit inrush duration), if I recall correctly that's some 47µF, so you need to add a precharge circuit to be able to use more. It's getting some sort of PITA.
Oh! So it does! It looks like its actually 10uF. Eeep. I'm putting 300uF on the bus.

If you don't have precharge, you can't have much capacitance, and if you don't have much capacitance, the USB sees all those 1A peaks, in which case you would need to enumerate and ask for more current, or hope everything's OK.
Yeah, I'm reading a TI application report on this now (SLVA670A). It would be nice if there was a single IC that would handle all this for me. I'll do some Googling.

I wonder why I can't just put a charge resistor between Vusb and my capacitors? And have the ESP32 monitor the voltage on the caps, and when the voltage hits 5v the ESP32 will turn on a MOSFET that bypasses the charge resistor? That feels promising!

With a 12.5ohm resistor it should take less than 50milliseconds for the capacitors to reach 4.99v on turnon.

Of course you can, but the equations get really complex when you include "everything", including cable ESR, ESL, capacitor C, ESR, ESL, and possibly C, ESR and ESL of another set of (different type of) capacitors. Spice handles coming up with all the equations and solving them for you. Tools are there to help.
I don't want to include "everything", just the equivalent of the simple RC filters that students learn in college EE.
 

Online ejeffrey

  • Super Contributor
  • ***
  • Posts: 3701
  • Country: us
Re: Critique my LED PWMer
« Reply #21 on: October 19, 2021, 04:17:41 am »
Thanks for the nods-of-approval for the 1uF MLCC, I'll switch to those. I'll also throw some across the LED's 100uF tantulum caps.

It starts to show some minor non-linearity, though. Flicker will be the real problem at such low duty cycle. You may want to up the freq even if that means that your minimum on-time is even lower and the low side control steps will be even more non-linear. You want to test that out in practice. At very low duty cycles, a large part of conduction period will be partially conducting i.e. switching loss but this doesn't need to be a problem.
Yep. That's my thinking on the matter as well. The non-linearity is material and it sucks, but the good news is that it seems like there's a delay in both MOSFET turn-on *and* turn-off, which will cancel out some of the non-linearity. At the end of the day I just want to get it built and start testing. Firmware is flexible and LED current resistors can be changed.

Why is the non-linearity important or a problem?  What is the application?  The proposal (max duty cycle <5%) doesn't seem to make a lot of sense for general purpose illumination or display purposes.  Non-linearity in the drive circuit wouldn't usually be important for those applications because visual perception is more non-linear.  If you are doing something completely different, then the advice above is potentially not applicable.
 

Offline robzyTopic starter

  • Regular Contributor
  • *
  • Posts: 119
  • Country: au
Re: Critique my LED PWMer
« Reply #22 on: October 20, 2021, 05:23:06 am »
Linearly is important because I want to now how much power the LEDs are putting out. If the MOSFET's materially eat into the 1uS pulses, then it will be a pain to figure out the true output from the LEDs at 1uS.

I've come up with my precharge delay circuit. It's not as simple as I was expecting it to be. I did some Googling but couldn't come up with a simpler answer. Any suggestions?

The ESP32 will monitor VMEAS and enable the MOSFETs to short the resistor when the caps have charged to a high enough voltage.

 

Offline magic

  • Super Contributor
  • ***
  • Posts: 6735
  • Country: pl
Re: Critique my LED PWMer
« Reply #23 on: October 20, 2021, 05:59:25 am »
Do you realize what will happen if Vin catches some ESD while the fuse is blown? ;)
 

Offline robzyTopic starter

  • Regular Contributor
  • *
  • Posts: 119
  • Country: au
Re: Critique my LED PWMer
« Reply #24 on: October 20, 2021, 06:04:24 am »
Do you realize what will happen if Vin catches some ESD while the fuse is blown? ;)
Are you suggesting that it will blow Q8? I thought that the 10k R9 would save the Q8 from ESD etc....

Did I mis-identify the problem? Or is my solution not right? :P
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf