Continue to Site

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.

  • 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

Status
Not open for further replies.

ccurtis

Well-Known 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.
 
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.
 
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.
 
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?.
 
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).
 
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:
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/
 
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.
 
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:

 
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.
 
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:
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top