The eye's response to brightness is not linear, its logarithmic. At low levels it is very sensitive and can easilly distinguish between 8 bit pwm levels. Even 16 bit levels are just about perceptible. At high levels, much less so and 8 bit pwm levels merge smoothly.
So notwithstanding how many bits you use, steps in the range say, 1 to 64 are always going to be quite visible, whilst the top 64 are going to be indistinguishable.
But if you use 16 bits, you probably do not need to use steps in the 1 to 64 range as they represent the least 1/1000 of full intensity. (Remember LCD screens advertising "1000:1" contrast range?)
So how many bits are really needed to go from 0-100% smoothly?
Also i was reading about LEDs that the dimm-frequency should preferably not be less then 100Hz and not be more then 500Hz and a good dimm-frequency would be 200Hz.
I'm reading and reading but don't understand the connection between dimm-frequency and 8bits vs 10/12/16bits.
There is no conection between the pwm frequency and the number of brightness levels.
The pwm frequency should not be much lower than 100Hz because it would flicker visibly. It can be much higher than 500Hz with no problem.
The brightness of the led is not determined by the pwm frequency, but by the pwm duty cycle. That is, what % of the time it is lit vs off.
The number of bits determines how accurately you can control the duty cycle %. 8 bits allows control down to about 0.4%. 16 bits allows control almost down to one thousandth of one percent.
Yeah - PWM frequency is another thing you need to worry about when making LED lighting look good - not really connected the resolution. PWM frequency is very important if the LEDs are moving - with low frequencies, you can see that they're blinking if they move (or your view of them changes) - I find it intensely distracting.
Brief anecdote on the impact of using 8 bit pwm - I noted during the opening act at a show I went to, that their LED multicolor spotlights must have been using 8 bit pwm - at low brightness, they didn't fade smoothly. (the opener wasn't my thing, hence why I was looking at the stage lighting) A few weeks earlier, I went to a show with similar - but better - lighting of that sort, and they must have had 16+ bit PWM - they could smoothly dim it all the way down, and used that for dramatic effect during their performance.
MrGlasspoole:
I still wonder about that statement from somebody with so many posts
Well, don't waste any more of your time worrying about it! Many posts do not make someone an expert. It was only half wrong, after all. At higher brightness levels, it is hard to distinguish 8-bit pwm levels.
The eyes response to brightness follows the CIE LAB curve, which is approximately logarithmic.
Yes, for higher power LEDs the brightness steps in lumen are bigger.
In my LED systems ( trippylighting.com) I find 256 steps with 12 bit resolution provides very smooth color fading. I use 700mA high power RGB LEDs (Luxeonstar)
Whether a step is perceivable also depends on how fast you fade. The slower you fade the more visible a step becomes.
I've experimented with this quite a bit. If you fade all 3 LEDs in an RGB led down equally and slowly enough you can still perceive steps at 10 bit (meaning 1024 steps with 12 bit resolution). That's really only of academic value, however
BTW PaulS is a very knowledgeable, active and helpful member of the Arduino community, but in this case he's wrong
You are correct about the number of steps for a nunber of bits, but when dimming, you don't have to use them all. You might choose to use all of the steps in the lower values, but at the middle and higher end, because the levels are increasingly difficult for the eye to distinguish, you might use only every other step or one in every 3 or 4 steps. This would allow you to keep the apparent speed of fading roughly the same if you are changing the pwm value on a fixed time interval.
My point before was that the lower (lowest) steps are always going to be discernible (and the highest steps will not be).
If you wish to perform progressive dimming, you start with a 16 bit value (or indeed, a long) and multiply at each step by a step factor such as 0.9375 or to increase, 1.0625; these being extremely fast mathematical operations. You then use however many MSBs you need to feed the PWM value. When the resultant value decreases to 16 or overflows, you have reached the limit.