How to smooth the LED brightness transition with PWM control at low levels? - Page 1
Forum section: electronics / projects

author: Faranight
author_rank: Unknown
timestamp: October 12, 2021, 08:06:28 pm
content: Hello! Is there a novel way to smooth out LED brightness control driven by PWM at low duty-cycles?Lemme explain. I am working on a prototype where there is a100 kHz PWM driver with 8-bit resolutionthat drives the gate of an N-channel mosfet. The mosfet then drives a colored high-brightness LED on a 24VDC rail. I've noticed that whenever I set the PWM duty cycle to very low levels like steps 2/255, 1/255 and 0/255 (off) I don't get a smooth brightness transition to darkness. Instead, the LED dims to low brightness as I approach the duty cycle 1/255, but then in the final step (0/255) goes completely dark. I was wondering, if there is a way to make this transition smoother. I've made a simplified test circuit on a breadboard and the schematics are posted below. R1 is there to prevent current spikes on the mosfet driver. R2 is there to turn the mosfet off while PWM driver isn't yet initialized. R3 was adjusted so the current of the 5mm led on the breadboard was 20 mA at 100% duty cycle (fully open mosfet). Vcc is 24VDC.I've wired the test pointsTP1(C1, yellow) andTP2(C2, purple) to an oscilloscope, and I've been watching how changing the PWM duty cycle affects waveforms and the LED brightness. The square waveforms look nice with decent rise and fall times compared to the PWM frequency. This picture shows 50% duty cycle.As expected, when I set the duty cycle to 0%, the LED is completely dark. However, at the next duty-cycle step (value 1 = 1/256 = 0.39%) there will be a tiny spike on TP2 (and a tiny drop on TP1), but that's already enough to light up the LED to a decently visible degree. I can't set the duty cycle to 0.5 or something in-between because it's 8-bit PWM, and there is no transition between these two steps.I was wondering what would be a good way to fix this. I've tried adding a small 4,7nF ceramic capacitor in parallel to R2, and it smoothed out the transition a bit by making the LED dimmer on lower duty-cycle values, but unfortunately it also moved the maximum LED brightness from 100% duty cycle down to about 83% (higher values had no effect, TP1 shows mosfet is fully open). Waveform images with and without cap:Any suggestions?

author: Kleinstein
author_rank: Super Contributor
timestamp: October 12, 2021, 08:20:51 pm
content: There is usually no need to use 100 kHz for the PWM, this only produces extra EMI issues. Some 200 Hz should be fast enough for the PWM frequency. At the lower frequency one usually has more PWM resolution, like 12 bit or 16 bit. The steps are than small and no problem to also get enough resolution at the lower setting.

author: Benta
author_rank: Super Contributor
timestamp: October 12, 2021, 08:41:13 pm
content: First, you need to learn how to make a schematic readable for other people. This circuit is so simple that it's not a major problem, but it's still horrible. I've attached a better version.Second, PWM at 100 kHz is completely unnecessary, as Kleinstein said. A few hundred Hz is enough.Third, 100 kohm as turnoff/pulldown resistor for the MOSFET gate is far too high. Try with 1 kohm.

author: ejeffrey
author_rank: Super Contributor
timestamp: October 12, 2021, 08:59:39 pm
content: Brightness perception is non-linear so you want to use a non-linear mapping function -- typically a power-law -- on your drive signal. 8 bit resolution is not enough if you use a linear scale to get smooth transitions at the low end. You can read about gamma curves at wikipedia:https://en.wikipedia.org/wiki/Gamma_correction. Gamma correction is how 8-bit/channel RGB gets good enough performance to use in most display applications.You can implement an analog circuit to handle the non-linearity but more realistically just throw more bits at it. A 12- to 16-bit PWM should work much better. You will still want to do the mapping in software if you want smooth transitions.

author: Benta
author_rank: Super Contributor
timestamp: October 12, 2021, 09:18:37 pm
content: ^^^ This!Your eyes are not linear.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: October 12, 2021, 09:46:26 pm
content: 8 bits is not enough. 10 would be an absolute minimum, 12 ideally.Start with an 8 bit input value, square it and send the uppermost bits to the hardware.If your PWM hardware is only 8 bit, you can often use dithering to get 10-12 effective bits.100KHz is ridiculous, and may introduce nonlinearities due to capacitance. Maybe this was a misprint for 100Hz?

author: Whales
author_rank: Super Contributor
timestamp: October 12, 2021, 10:57:58 pm
content: LEDs have non-linear light-output vs power-input curves; and human eyes also have non-linear observed-brightness vs actual-brightness curves (making the problem even worse). I believe words like "perceptual brightness" are the right terms to search with?No one seems to like 100KHzIndeed if your LEDs are a long distance away from the transistor and capacitor then this can potentially cause EMI issues. I'll add a counter-point: a few hundred hertz is still noticeable when you move your eyes ("dot patterns" trail in your vision). I find this distracting, but to each their own. Also sucks to be a pet animal with a different visual perception rate. Personally I'd prefer if it's possible to PWM into at least a few KHz.

author: dmendesf
author_rank: Frequent Contributor
timestamp: October 13, 2021, 12:01:00 am
content: Everything said is true (including a few hundred hertz being a pain for moving lights for some people like me) but there's another option: you could alternate 0x00 and 0x01 codes for a lower duty cycle when you hit the lower end of the scale. Fainter lights have less ghosting effects.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: October 13, 2021, 01:56:35 am
content: Yeah, lower frequency, more bits, and note you don't have to use fixed frequency PWM: you can vary the TOP count while keeping the COMPARE count constant, or vary both at the same time (say when one happens to be a whole multiple of the other, they can be rescaled without changing the output level). This gives more resolution when COMPARE is very small.Can also switch to an analog method (i.e., use a current sink rated for say 1% of the total output, and controllable down to 0.01% or less), which is still ultimately limited by DAC accuracy/linearity/range, but at least avoids problems with PWM linearity failing at very low drive levels (i.e., where comparable time is spent rising or falling, as fully-on). Lower current does change the CRI a bit, but it's not usually enough to mind, or indeed at low light levels it might not be perceptible anyway.Quote from: dmendesf on October 13, 2021, 12:01:00 amMore generally, you can dither between any set of levels as a sigma-delta modulator. Usually it's just used for one LSB, so the above is an especially good example. Note that the period of a S-D modulator output corresponds to the desired ratio (input value) in an inconsistent way (varies with setpoint), so you may get obnoxious flashing or strobing at certain levels. Another reason to keep the clock frequency high, I suppose.Which, to add my opinion on that -- a flash rate above a few kHz is very difficult to see,mechanicallyspeaking -- and by that I mean, even if the lights are moving very fast indeed through your visual field. Even with the pinpoint sources of bare LEDs, you'll at worst see a "string of beads" sort of image. This is my recommended PWM rate for lights, if I have no particular reason to go to lower frequencies (e.g. I have adequate resolution in the timer/counter, and sufficient rise/fall time in the driver). Lower frequencies may be acceptable, but you will definitely want to have a think about it -- several kHz is the "do not care" threshold.For illumination purposes, 100Hz is definitely insufficient for some people, especially at low duty cycles (it's more about the off-time duration between pulses than the overall frequency), and 200Hz is probably pretty safe, though you will still sometimes see tracks of dots across your visual field from poorly diffused / point sources or specular reflections. Raising the frequency makes those visual artifacts smaller, and harder / less common to see.Tim

author: Faranight
author_rank: Unknown
timestamp: October 13, 2021, 08:05:38 am
content: Guys, guys, chill!First of all, thank you for all the input. I see a lot of you dislike the 100 kHz PWM frequency. The issue with my application is that I'm using an external I²C PWM controller with 8 outputs at 8-bit PWM resolution and a fixed frequency of 100 kHz, so I can't lower the frequency without replacing the IC. Technically, the actual controller frequency is 97 kHz, but I was testing the circuit on a single channel at 100 kHz square wave from a function generator. If I needed fewer PWM channels, I would have used the internal microcontroller PWM with lower frequency instead (has 6 hardware PWM outputs, I need 8 of them). I also agree that a frequency in the 100Hz range is too bothersome to my eyes - that's why I was looking for something with at least a few kHz.Here's my PWM controller datasheet:https://www.nxp.com/docs/en/data-sheet/PCA9634.pdfIf you know of a similar external 8-channel I²C PWM controller with frequency of only a few kHz and a resolution of 10 to 14 bits, I'm all ears.Quote from: Benta on October 12, 2021, 08:41:13 pmHmm, are you sure about this? The 100k pulldown resistor was supposedly added only to hold the line low while the microcontroller and PWM driver initialize (takes a second). The PWM driver is programmed to act as a totem pole (alternating between source and sink) and should be fully capable of driving the mosfet without the pulldown resistor. Here's a snippet from the datasheet:The LED output driver is programmed to be either open-drain with a 25 mA current sink capability at 5 V or totem-pole with a 25 mA sink, 10 mA source capability at 5 V.Quote from: ejeffrey on October 12, 2021, 08:59:39 pmYes, I've already done my homework on gamma correction and implemented an algorithm in the microcontroller, but the problem remains. I mean, the fading is nice even at low PWM values at 8-bit resolution. It's just that the issue is with that final step where I go from the lowest duty cycle of 1/255 down to a complete off (0/255) - this is where the change in brightness is too big. The LED should be barely visible or already turned off at the lowest duty cycle (1/255), but instead it's way too bright.

author: Kleinstein
author_rank: Super Contributor
timestamp: October 13, 2021, 08:39:02 am
content: If really needed, one could reporgram the PWM generator to alternate between a low PWM and off at the low levels. However this would be quite some trafic for the I2C bus.If really needed, one could get a slightly nonlinear PWM by making the MOSFET to turn on slow and turn of fast. With a resistor on the source side the MOSFET would turn on the current slightly slower. For the very low PWM setting this could result in an about square relation, though the frist few settings would be lost and still off.With only 1 kHz or so there would still be the option to use software PWM - though this would keep the µC buissy.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: October 13, 2021, 09:06:21 am
content: OK with 100kHz, there woudl be scope to add some dithering at lower frequency - An issue with most external PWM chips is you typically can't synchronise to it. However if your dither frequency is sufficiently far from the PWM frequency you may get away with it. I'd try something like a 4-bit dither at a few hundred Hz, which should be doable.The easiest way to generate the dither signal is to have a phase accumulator register per channel, add the sub-PWM level to it on every sub-PWM cycle. If it generates a carry, add 1 to the main PWM value.

author: DavidAlfa
author_rank: Super Contributor
timestamp: October 13, 2021, 09:50:41 am
content: The human perception is non linear, so you also need to make a non-linear brightness curve:https://learn.adafruit.com/led-tricks-gamma-correctionSo instead of setting pwm to 50%, you need a different approach, ex. a "setBrightness" function that computes the PWM duty cycle using some kind of polinomial or a look-up table.

author: Psi
author_rank: Super Contributor
timestamp: October 13, 2021, 11:22:13 am
content: Looks like that chip has an additional 8-bit Group PWM controller that can dim all channels at once. Separately to the individual 8bit pwm controlhm.. I wonder..Would it be possible to combine this 8bit individual + 8bit global PWM to build maybe a individual 12 bit pwm system?If you change the global PWM it will affect all LEDs, which you don't want. But perhaps if you reduce the dynamic range that you're using in the individual PWM bits then you can use the extra range to offset any LED and compensate for any unwanted brightness change every time you adjust the global PWM amount?It would be a bit tricky and i'm not actually sure if it would gain you anything, maybe someone else knows? Does this kind of approach gain you anything or do you just end up with 8bit control again?

author: Renate
author_rank: Super Contributor
timestamp: October 13, 2021, 11:34:06 am
content: You need something with greater dynamic range, like the LM3630A from TI. Many smart phones use it as a backlight controller.https://www.ti.com/product/LM3630A

author: StillTrying
author_rank: Super Contributor
timestamp: October 13, 2021, 12:21:42 pm
content: Could you use 2 channels per LED, a high current one and a low ~1/10 or less current one, and swap over around 20/255 or 25/255.So instead of going down from 20//255 to 19/255 you go to 190/255 but on the low 1/10 current channel, that would make the light step changes below 20/255 10 times smaller.It's all I can think of.

author: DrG
author_rank: Super Contributor
timestamp: October 13, 2021, 12:24:43 pm
content: @FaranightI could be wrong, but I don’t believe that your results are for the reason that you think.A simple test would be to hook up a single LED with an appropriate current limiting resistor directly to the PCA9634 exactly as shown in “10. Application design-in information”, for LED0 - from the data sheet that you linked. This eliminates the mosfet and all of the additional drive circuitry. My guess is that you will see a very different brightness function.While 8 bit resolution is weak, you should not be seeing the level of brightness at PWM=1 that is shown in your picture. That is, it looks very suspicious to me.Would you be willing to try this simple test and report the results?FYI: We had a thread about LED brightness scalinghttps://www.eevblog.com/forum/beginners/dividing-0-to-100-exponetially-for-dimming-light/and I posted a program in a second threadhttps://www.eevblog.com/forum/programming/scaling-brightness-using-pwm/msg3531636/#msg3531636that calculates PWM values at different PWM resolution bit sizes and step size.

author: tooki
author_rank: Super Contributor
timestamp: October 13, 2021, 01:44:24 pm
content: As someone who is very, very sensitive to flicker (it's extraordinarily distracting and annoying), I applaud the OP for wanting to use something more than the couple of hundred Hz most people erroneously think is sufficient.Quote from: Kleinstein on October 12, 2021, 08:20:51 pmNonononono!Quote from: Benta on October 12, 2021, 08:41:13 pmOhgodnopleasedon't!Please see this reply of mine in another thread about LED PWM:https://www.eevblog.com/forum/projects/pwm-lighting-120hz-to-dc/msg3582880/#msg3582880It contains a scientific paper explaining that some test subjects could detect flicker up to 4.9KHz.It takes about 2KHz for me to not detect it.If moving objects are involved, it can taketens of KHzto fully eliminate flicker in edge cases.Quote from: Whales on October 12, 2021, 10:57:58 pm100KHz is unnecessary. I used around 20KHz in my DIY dimmer at home, so that any switching noise would be outside of human hearing.Quote from: Whales on October 12, 2021, 10:57:58 pmIt's called the "phantom array" effect. I find it insanely distracting. I went to a show recently (a film, with live music before and after, and interview with the director), and the stage lights were PWM dimmed. I had to strain to keep my eyes focused on one object so as to not constantly be distracted by phantom arrays. And even the projector they used (mind you, in the main auditorium of the Zurich Film Festival, so a proper digital cinema projector, not some dinky conference room toy) exhibited some rainbow effects to me.Quote from: T3sl4co1l on October 13, 2021, 01:56:35 am200Hz? Oh god, please, no! Specular reflections are everywhere, and LEDs themselves are more or less point light sources. I caneasilymake out phantom array effects at 1KHz in indoor lighting. (I did extensive testing when building my own LED dimmer.)2KHz was enough for me, but it made the power supply whine audibly, so I used 20KHz-ish.

author: tooki
author_rank: Super Contributor
timestamp: October 13, 2021, 01:52:46 pm
content: Quote from: DrG on October 13, 2021, 12:24:43 pmNah, 8-bit PWM simply sucks at the low end. You can easily test this with an Arduino. The difference between PWM=1 and PWM=2 isn't that huge, but from PWM=0 to PWM=1 is a big jump. Our vision isfarmore sensitive to changes in brightness at the low end, and 1/256th simply isn't enough dynamic range, at least with low ambient light levels.

author: ejeffrey
author_rank: Super Contributor
timestamp: October 13, 2021, 03:28:07 pm
content: Quote from: Faranight on October 13, 2021, 08:05:38 amThen if you look at the gamma correction function it should be clear why this isn't working. Using a gamma of 2 which is just squaring (2.2 is more common but more computationally expensive) if your input code is 16 your output code is 1. This means you have no intermediate outputs available for the lowest 15 input codes, or the bottom 1/16 of the range. Effectively your 8 bit PWM actually only has 4 bits when looking at the dim end of the scale. You can use an 8 bit brightness code but you really need 10, 12, or even 16 bit PWM to get smooth transition down to zero brightness -- 16 bits would be needed to have a true 8 bit dynamic range using gamma=2.You can correct for this with some analog circuitry (such as using a slow on / fast off time) or software dithering, but honestly it seems like you just have the wrong PWM chip for the job. Are all the channels dedicated to LEDs or are you using other applications that need the 100 kHz frequency?

author: RoGeorge
author_rank: Super Contributor
timestamp: October 13, 2021, 03:29:52 pm
content: Quote from: Faranight on October 12, 2021, 08:06:28 pmYes. Use Delta-Sigma or PDM (Pulse Density Modulation) instead of PWM. You can implement as many as you like on almost any microcontroller, at higher resolution and faster refresh rates.Here's a demo I built once, it looks better in reality. Some step artifact are from the video camera and the movie encoders.Yellow trace is PDM, blue trace is PWM while dimming the same. Some explanations, comparisons and sources example for all the pins of a MSP430 controlling each the intensity of a separate LED.https://hackaday.io/project/6356-delta-sigma-versus-pwm

author: Siwastaja
author_rank: Super Contributor
timestamp: October 13, 2021, 03:36:32 pm
content: Likely easiest is to replace the driver IC with another I2C controlled LED PWM driver with higher number of bits - preferably 12 or more.Dithering between different PWM values is easy when you do the PWM on microcontroller so can change the values in ISR. With external IC, through such slow and unsynchronized I2C bus, dithering may not work very well, but you can try what happens if you just keep updating values 0 and 1 alternatively as fast as you can. This should be quick to test, report back how it works.

author: BrianHG
author_rank: Super Contributor
timestamp: October 13, 2021, 04:09:28 pm
content: If the current is low, like something < 100ma, you can replace the mosfet with an emitter follower transistor amp with an RC filter at the base driving the LED in a linear fashion. This will leave you with a bunch of dead lower LED luminance values, but, you will find a nice curve in brightness beginning at around (say 10-20). Note that you loose the efficiency of a switched design, however, you already have a series resistor in your circuit driving the LED.

author: ejeffrey
author_rank: Super Contributor
timestamp: October 13, 2021, 04:16:42 pm
content: Quote from: Faranight on October 13, 2021, 08:05:38 amHere is a 16 channel 12 bit controller that can operate at 1.5 kHz also from NXP: PCA9685https://www.nxp.com/products/power-management/lighting-driver-and-controller-ics/ic-led-controllers/16-channel-12-bit-pwm-fm-plus-ic-bus-led-controller:PCA9685This was just the first one I found, I'm sure there are others.Since you are using logic level totem pole outputs to drive external MOSFET, another option would be to use a separate dedicated microcontroller that you communicate with over I2C. MCUs usually have much more flexible PWM peripherals than any dedicated chip and you can implement things like delta or delta-sigma modulation by updating the control registers every cycle. The main advantage of dedicated LED drivers is that they have high current capable open-drain outputs to drive LEDs directly which you aren't using.

author: ajb
author_rank: Super Contributor
timestamp: October 13, 2021, 04:19:18 pm
content: Quote from: mikeselectricstuff on October 12, 2021, 09:46:26 pmI'd actually say that 12 bits is the minimum, with 16 being preferable. If the control value is only 8 bits, then mapping that to a 12-bit PWM value with a simple curve applied is often perfectly adequate and very simple to implement. The true minimum is highly application-dependent, since the visual context matters. The environment, in particular the ambient lighting, will affect the adaption of the eye which will affect its sensitivity to brightness changes. The way you look at the source also matters, since peripheral vision in humans is mostly provided by rods (non-color sensitive photoreceptors) that are much more sensitive to brightness changes than the cones (color sensitive photoreceptors) that are concentrated in the fovea and provide most of our visual acuity.Quote from: tooki on October 13, 2021, 01:44:24 pmThat's interesting, with the growth of LED source technology in stage lighting and the simultaneous growth of video integration (especially streaming now, but also broadcast and imag) PWM rate is an increasingly important spec for people who are purchasing gear. (Especially now that most people are finally accepting that before long tungsten and discharge sources just won't be an option anymore.) I'm curious what kind of lighting equipment that venue had and what the actual PWM frequency was. As far as the projector, it's still quite likely that it was a discharge lamp + color wheel + DLP arrangement. Laser/LED source projectors are still relatively new and I don't think have a ton of market penetration yet outside of smaller compact systems. Even a lot of current-model laser based DLP projectors use a phosphor wheel. Given the price tag on big projectors like that equipment turnover isn't that rapid, so the mechanical limitations of using a spinning wheel are going to be a factor in the display quality for many years to come. Single-chip projectors with direct laser/LED sources should be able to achieve better performance since the limitation on changeover time between colors is probably limited by the MEMS performance well before the modulation performance of the sources. Three-chip projectors should be able to do even better since the colors don't have to be temporally overlaid at all.

author: tooki
author_rank: Super Contributor
timestamp: October 13, 2021, 06:19:04 pm
content: Quote from: ajb on October 13, 2021, 04:19:18 pmIs it, really? Going by the fact that inevery. single. threadhere about PWM, there are people who think that the same 60Hz frame rate threshold that applies to moving images also applies to PWM, I think the importance of high PWM frequencies is not widely accepted yet.Quote from: ajb on October 13, 2021, 04:19:18 pmI have no idea what it was, no way to look at it. If I had to guess, I'd peg the PWM frequency at somewhere around 500-1000Hz. Not super low, but still enough for me to easily detect it without trying.Quote from: ajb on October 13, 2021, 04:19:18 pmGoodcolor wheel-based projectors are just fine. I've watched many a movie in digital cinemas over the years, and this was the first time I ever noticed any rainbow effect at all. It was very subtle, unlike in bargain-basement DLP data projectors.FYI, the MEMS speed is not the limiting factor, not even by a long shot. The micromirrors can move thousands of times per second (over 9000 in current-generation ones), such that they're actually flipped back and forth dozens of times per subframe in order to produce intermediate brightness values. They also use higher-RPM color wheels with far more than 3 segments (adding more colors, and often multiple segments per color) to increase the effective frame rate to 240fps or more. With pulsed LED or laser illumination, it could potentially go much higher.

author: Faranight
author_rank: Unknown
timestamp: October 13, 2021, 06:37:51 pm
content: Quote from: DrG on October 13, 2021, 12:24:43 pmThere is some truth that the mosfet may distort the PWM waveform in some manner. Looking at the circuit, you can see that there is a gate resistor present before the mosfet. I was told to put this 100 ohm resistor there to prevent large current spikes on the mosfet driver. But thinking about it, the mosfet has some internal gate capacitance, and together with the resistor they both form an RC filter on the line. I've already checked the scope and the waveform looks quite different (much narrower and spiky) on the input than the one behind the resistor on the mosfet gate. I tried removing the gate resistor and feed the waveform from the function generator directly into the mosfet gate, and the only change this seems to have caused is more ringing on the gate terminal. LED brightness did not seem to change noticeably. I'll try to do a proper test with the output of the driver connected directly to an LED and a current limiting resistor.Quote from: ejeffrey on October 13, 2021, 03:28:07 pmNo, you misunderstand. The gamma correction algorithm is present on the microcontroller, but I was doing the tests with a separate function generator that outputs a square waveform of given duty cycle with no gamma correction. The problem isn't gamma correction, but the fact that the change of brightness on the final step from 1/255 to 0/255 duty cycle is too big while the changes from 1/255 to 2/255, 2/255 to 3/255, 3/255 to 4/255, etc are barely noticeable. Seetooki's reply one post above yours. All 8 channels are dedicated to different and separate LED's.Quote from: ejeffrey on October 13, 2021, 04:16:42 pmYeah, I just found it myself. It's a 12-bit, but 16-channel PWM driver that apparently even has an external clock input pin. They don't have an 8 channel one though. In worst case I'll have to discard 8 channels, or asStillTryingsuggested, maybe use 8 channels for high current and the other 8 for low current? I'll have to study this possibility.Thanks for all the suggestions so far, everyone. I wasn't expecting my thread to get this much attention.I'm getting new helpful posts faster than I can process them. That sigma-delta modulation approach does look interesting. Although I'm unsure I'll be able to implement it on an existing microcontroller since it already has to process quite a lot of code.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: October 13, 2021, 07:51:35 pm
content: QuoteI think most cinema-size projectors use three seperate DLPs rather than colour wheels

author: StillTrying
author_rank: Super Contributor
timestamp: October 13, 2021, 07:53:19 pm
content: Quote from: Faranight on October 13, 2021, 06:37:51 pmOK, another theory.Steps 1/255 and 2/255 might be out (too long or too bright) because of the problems trying to get the mosfet to produce pulses which are only 40ns and 80ns wide. The gate's fast charging and discharging edges getting through the gate-drain capacitance will have a relatively big effect on what the drain is doing at those small pulse widths, especially if the gate's turn off is very fast.The 3 scope shots show the full 10us period but aren't fast enough to show what's happening to the drain pulses only 40ns to 120ns wide.

author: Faranight
author_rank: Unknown
timestamp: October 13, 2021, 08:33:36 pm
content: Well, here's the zoomed-in version of the waveform for the mosfet turn-on. This *is* on the breadboard after all...Yellow is voltage on the mosfet drain, purple is voltage on the frequency generator output (before 100 ohm resistor), cyan is voltage on the mosfet gate (after 100 ohm resistor).Ring ring, hello? Ring ring, hello? Rign ring, hello? I have a bad connection!

author: StillTrying
author_rank: Super Contributor
timestamp: October 13, 2021, 09:05:00 pm
content: I don't know what to make of that, I've seen a lot worse.It looks like the drain is staying on a bit but that might just be the LED's capacitance holding the voltage, when you switch a LED off by opening a switch the voltage across the LED drops a few 10s of mV and it stops conducting current but the LED's capacitance is still charged for a while soit lookslike the switch is not switching off properly, at least on a scope.All I can think of is to compare the drain pulse widths for the steps 1/255 to 5/255.

author: DavidAlfa
author_rank: Super Contributor
timestamp: October 14, 2021, 08:34:39 am
content: Lower the pwm frequency, it's just a lot, regulation won't be accurate.10KHz should be more than enough to avoid flickering.Also you might want a mosfet gate driver.Also 8 bits are too low for a decent range.Another way would be a constant current led driver.

author: tooki
author_rank: Super Contributor
timestamp: October 14, 2021, 09:24:21 am
content: Quote from: mikeselectricstuff on October 13, 2021, 07:51:35 pmEh, it’s not just about the size. From browsing Christie’s site, just as one example, their cinema projectors are all 3-DLP, while their event projectors are about half 1-DLP and half 3-DLP. I would assume that the cinema models are intended for permanent installation, whereas the event projectors are designed to handle the rigors of being schlepped from place to place.Clearly the film festival happened to rent a 1-DLP projector, or else the rainbow effect would not have manifested.

author: tooki
author_rank: Super Contributor
timestamp: October 14, 2021, 09:30:15 am
content: Quote from: StillTrying on October 13, 2021, 07:53:19 pmYou can verify the problem with 8-bit PWM using an Arduino with an LED (via current limiting resistor) connected directly to a GPIO. Note that the 8-bit, 490Hz PWM from an Arduino is only the default; you can also change it to higher frequencies and/or resolutions. You could, for example, use one to test 16-bit, 245Hz PWM to see the effect of the greater resolution.

author: tooki
author_rank: Super Contributor
timestamp: October 14, 2021, 09:31:41 am
content: Quote from: DavidAlfa on October 14, 2021, 08:34:39 amThe frequency is a fixed value in the LED driver IC. It can’t be changed. If they want better resolution, they’ll have to use a different driver IC.

author: StillTrying
author_rank: Super Contributor
timestamp: October 14, 2021, 02:01:00 pm
content: If I simulate with some of the low power low capacitance mosfets the drain voltagesyellow, and the currents through the LEDgreen, don't look too bad for such short 40ns to 160ns pulses. 100R in series with the gate.So I don't know why the brightness of the first 4 or 5 PWM steps aren't right.

author: BrianHG
author_rank: Super Contributor
timestamp: October 14, 2021, 02:25:11 pm
content: Quote from: tooki on October 13, 2021, 06:19:04 pmCinema grade projectors implicitly demand the use of 3 chip DLP projectors. No spinning color wheel BS. No blinking as the PWM rate is way above 240Hz per pixel which have a dedicated DLP chip per color channel. You will never see a rainbow effect in the cinema with those Barco or Christie projectors.

author: tooki
author_rank: Super Contributor
timestamp: October 14, 2021, 04:05:39 pm
content: Quote from: BrianHG on October 14, 2021, 02:25:11 pmYup, hence my suspicion that they used an event projector at the film festival. (I should mention, it wasn’t in any of the cinemas in the city — they’re much too small — so it was actually held at the convention center.) But despite being a temporary setup, I would have expected the film festival to have specified something better.Don’t get me wrong, it was clearly a high-end projector (size and brightness alone would have limited it to something from the likes of Barco or Christie), just not the best.Or maybe the convention center already had a large-venue projector installed and they just used that? I really don’t know. (And my Google-fu didn’t turn up anything, alas.)

author: ejeffrey
author_rank: Super Contributor
timestamp: October 14, 2021, 10:13:10 pm
content: Quote from: Faranight on October 13, 2021, 06:37:51 pmMy point is that if you pay attention to what the gamma correction curve is telling you about visual perception then this behavior is expected. 1/255 is much brighter than 0. It is roughly equivalent to a 4-bit resolution in that if you put 16 equally spaced (gamma corrected) samples in a row each one would be clearly distinguishable from the next. The next-to-last one would be 1/256 as bright as the first if you were using gamma=2, if you were using a more standard gamma=2.2 the next-to-last would be 1/445 as bright as the first.The effect is exacerbated when you are comparing off to on but I suspect that if you toggle between 1/255 and 2/255 at 1 Hz you would see that clearly too.

author: DavidAlfa
author_rank: Super Contributor
timestamp: October 14, 2021, 11:34:58 pm
content: Quote from: tooki on October 14, 2021, 09:31:41 amOops you're right, my bad. I forgot the LED driver part, thinking it was mcu-driven. Different driver then, yes