• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Low duty cycle PWM and LED brightness

ccurtis

Active Member
Hello,

I am driving an LED in series with a limiting resistor with a PWM generator in a PIC micro controller. It all functions properly, best I can determine.

I notice a surprising thing, that at only a 0.7% duty cycle, the brightness of the LED, though dim compared to full brightness, is much higher than I expected.

I tried several LEDs and current limiting resistors, same result.

It is so surprising, I am wondering is anyone can confirm my observation.
 

audioguru

Well-Known Member
Most Helpful Member
Like our hearing, the sensitivity of our vision is logarithmic. 1/10th the power sounds and looks half as loud or as bright.
Additionally, our eyes have the iris that closes a little to reduce brightness then opens to see dim light.
 

ccurtis

Active Member
I do know that, but, sheesh, I didn't know it was that extreme. I can only go one step lower (0.3%) and even that it brighter than I want before it's completely OFF. It's not like I am over driving the LED. I am selecting the resistor for the max continuous current rating for the highest, 100% PWM step. I can hardly believe my eyes.
 

Nigel Goodwin

Super Moderator
Most Helpful Member
I do know that, but, sheesh, I didn't know it was that extreme. I can only go one step lower (0.3%) and even that it brighter than I want before it's completely OFF. It's not like I am over driving the LED. I am selecting the resistor for the max continuous current rating for the highest, 100% PWM step. I can hardly believe my eyes.
What value resistor are you using?.
 

ccurtis

Active Member
What value resistor are you using?.
Well, Nigel, I'm using a 360 ohm resistor in series with a Green LED, for example. I am using an NPN transistor as a driver/switch to ground with the LED anode connected to +5VDC and a 1500 ohm base resistor connected to the PIC. The LED cathode is connected to the collector of the transistor. The transistor emitter is at zero volts (GND).
 

ccurtis

Active Member
You can increase the resistor value to reduce the current. You can also have more than one resistor from different PIC outputs if you want a wider range of brightness.
I am thinking about increasing the resistor value to lower the brightness to something reasonably low at the lowest duty cycle, but that will cut into the maximum brightness. Maybe a fair trade. I'll have to experiment to see how much impact at the high end, I guess. I'm still shocked and find it hard to believe it is as bright as it is at only 0.7% duty cycle. I would have never imagined that. I can't help but think there isn't something else going on, but I don't know what.

I'm using fixed 4 KHz PRI out of the PWM, for what that's worth.
 
Last edited:

Diver300

Well-Known Member
Have you measured the duty cycle at the LED?

You will have about 3 V across the resistor, so you'll get about 8 mA through the LED. You are driving the transistor with about 3 mA which is a lot more than you need to make a transistor conduct 8 mA.

Are you driving the PIC output and therefore the base low when turning off? I am wondering if the LED is staying on for a few microseconds longer than the PIC output, which could make a significant difference on high frequency PWM.

There is some information about saturation here https://www.physicsforums.com/threads/why-does-my-transistor-desaturate-so-slowly.577557/
 

ccurtis

Active Member
Have you measured the duty cycle at the LED?

You will have about 3 V across the resistor, so you'll get about 8 mA through the LED. You are driving the transistor with about 3 mA which is a lot more than you need to make a transistor conduct 8 mA.

Are you driving the PIC output and therefore the base low when turning off? I am wondering if the LED is staying on for a few microseconds longer than the PIC output, which could make a significant difference on high frequency PWM.

There is some information about saturation here https://www.physicsforums.com/threads/why-does-my-transistor-desaturate-so-slowly.577557/
Unfortunately I don't have a scope to measure that low a duty cycle. My Fluke DMM can measure duty cycle and it does measure a bit higher than I expect at the higher duty cycles that it is capable of measuring, but not unreasonable higher than expected. I measure 15% at 12.5% expected, 8% for 6% expected, 4.7% for 3% expected, 2.4% for 1.5% expected, the DMM can't measure lower than that.

That's a good point about the saturation. I selected the base resistor to later use higher power LEDs than I am experimenting with. I will look into that. Thanks.
 

Nigel Goodwin

Super Moderator
Most Helpful Member
Unfortunately I don't have a scope to measure that low a duty cycle. My Fluke DMM can measure duty cycle and it does measure a bit higher than I expect at the higher duty cycles that it is capable of measuring, but not unreasonable higher than expected. I measure 15% at 12.5% expected, 8% for 6% expected, 4.7% for 3% expected, 2.4% for 1.5% expected, the DMM can't measure lower than that.

That's a good point about the saturation. I selected the base resistor to later use higher power LEDs than I am experimenting with. I will look into that. Thanks.
I don't think that would be any concern, as you're running at a low frequency anyway - you can get incredibly cheap small handheld scopes, which are surprisingly capable - and plenty for what you need to check this.

I bought one of these earlier this year, and it's really VERY useful, and convenient with been so portable:

 

ronsimpson

Well-Known Member
Most Helpful Member
vision is logarithmic
We are logarithmic.
and
Using a 8 bit PWM:
The difference between level 255 & 256 is 9.96mA & 10.00mA. You eye probably can not see that.
The difference between level 1 & 2 is 0.04mA & 0.08mA which is a 1:2 change. Your eye will see that!
Some of my LCD monitors are 12 or 14 bit to get the very dim levels right.
 

ccurtis

Active Member
Nice, Nigel. Cheap enough it's hard to go wrong.

If someone has a variable pulse generator equipment and an LED and resistor and a few minutes, handy, I'd sure like to know what he sees at .7% and .3% duty cycle around the same PRI.

Ron, so that would tend to indicate I can sacrifice some on the high end and raise the resistor value to get sufficient dimming at the low end, don't ya think, since I can't notice much change at the high end anyhow? I can sure notice it at the low end, much more than I had imagined. The noticeable difference between OFF and pretty darn bright is well below a milliamp, if my pulse width is actually what it should be at that low a duty cycle.

The equation for the Duty Cycle is ([8 bit word}+[2 LSBs])/1024. I am not using the 2 LSBs in my code (those are set to zero), so the lowest duty cycle (not counting zero) is 4/1024 = 0.4% and that's still pretty darn bright.
 
Last edited:

ccurtis

Active Member
Yeah, I am considering that. Funny thing is even at 2/1024 = 0.2%, it's still brighter than I want to start with, but 1/1024 = 0.1% is okay. It will make my code more complicated and run slower, but I think I can probably live with that. I guess I am just having trouble believing what I am seeing.
 

ronsimpson

Well-Known Member
Most Helpful Member
Different project but human interface so almost the same.
I have a function on my compiler where:
0=0000000000 binary
1=00000000001
2=00000000010
3=00000000100
4=00000001000
…..
9=01000000000
10=10000000000
11=111111111111111 which is almost 1,0000000000
A 0 to 11 number gives me 12 outputs that are close to what the human eye sees. (each step is 2:1 larger) I only have 12 brightness steps but they cover a 0 to 1024 range.
 

ccurtis

Active Member
Recognizing that the eye is logarithmic (exponential) in response, I have a similar algorithm for what I am doing with the LED. In my code, I am scaling the linear input parameter (brightness) to a value from zero to 8, call it X. I am shifting the constant, 2, left by whatever X is to get a number between 0 and 256 for the PWM. Essentially. PWM=2^X. The special case is when the input is zero, I have to force the PWM to zero, since 2^0 is not zero.
 

Pommie

Well-Known Member
Most Helpful Member
Recognizing that the eye is logarithmic (exponential) in response, I have a similar algorithm for what I am doing with the LED. In my code, I am scaling the linear input parameter (brightness) to a value from zero to 8, call it X. I am shifting the constant, 2, left by whatever X is to get a number between 0 and 256 for the PWM. Essentially. PWM=2^X. The special case is when the input is zero, I have to force the PWM to zero, since 2^0 is not zero.
Does that mean your sequence is 0,2,4 instead of 0,1,2,4 etc.

Mike.
 

ccurtis

Active Member
Well, good question, because for simplicity in the explanation, I left out the fact that I am really shifting a 1 (not a 2), so the sequence ends up as 0,1,2,4, etc, and it still works out.
 

ccurtis

Active Member
And now I realize I never get to higher than 127, much less to 256, because the 1 falls off the 8 bit cliff after seven shifts. Hmmmm. I have to fix that.
 

audioguru

Well-Known Member
Most Helpful Member
You said it is a green LED. Is it an old 2V fairly dim green LED that I have not seen for 20 years or is it a modern 3.2V very bright green LED?
Maybe the old one saturates and causes you to turn up the current to be bright enough causing it to be too bright at low PWM.
 

Latest threads

EE World Online Articles

Loading

 
Top