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.

PWM LED dimmer frequencies

Status
Not open for further replies.

crashmeplease

New Member
Hi All,

Does anyone have any calculations or knowledge on what PWM frequency is good to dim LEDs?

All I can seem to manage is blinking/flashing LEDs, or from visual appearance full brightness :)

I am using an AVR micro to create PWM signals by the use of timer interrupts, although this should be irrelevant, I am just after help in calculating good timings.

TIA :)
 

shimniok

Member
I can sometimes see the blinking of LED christmas lights fed off 60Hz. So something higher frequency than that would be good. I would think something in the 1 kHz range? I wonder if you could go too high with freq... how fast does an LED turn on/off ? Make the period less than that time.
 

ericgibbs

Well-Known Member
Most Helpful Member
Hi All,

Does anyone have any calculations or knowledge on what PWM frequency is good to dim LEDs?

All I can seem to manage is blinking/flashing LEDs, or from visual appearance full brightness :)

I am using an AVR micro to create PWM signals by the use of timer interrupts, although this should be irrelevant, I am just after help in calculating good timings.

TIA :)

hi,
Is the PWM synchronised in any way to the mains frequency.?:)
 

crashmeplease

New Member
Hmm, I think I have found a couple of flaws in my logic. Firstly I have been driving the PWM signal with an equal amount of on time as off time, and varying the time of one complete on/off cycle, so a slower speeds the flicker will always be quite obvious. I must read up more on PWM :)

Also I realise my old dev board has 1K resistors with the LEDs, so they're hardly running at full brightness to begin with and I would imagine be very difficult to dim them much further :)


hi,
Is the PWM synchronised in any way to the mains frequency.?:)

No it's driven purely by timers from a micro.
 

ericgibbs

Well-Known Member
Most Helpful Member
Hmm, I think I have found a couple of flaws in my logic. Firstly I have been driving the PWM signal with an equal amount of on time as off time, and varying the time of one complete on/off cycle, so a slower speeds the flicker will always be quite obvious. I must read up more on PWM :)

Also I realise my old dev board has 1K resistors with the LEDs, so they're hardly running at full brightness to begin with and I would imagine be very difficult to dim them much further :)
No it's driven purely by timers from a micro.

Depending upon the 'freq' of the PWM, as its not locked to the mains, sometimes when the PWM says ON, the 50Hz could be passing thru a zero portion of the mains sinewave or at other times when the sine is passing thru a maximum.

So what you could see is a 'beat' pattern in the light output as the PWM and mains Phase drift past each other.

I assume you are driving a triac or src with the PWM.???
 

crashmeplease

New Member
Depending upon the 'freq' of the PWM, as its not locked to the mains, sometimes when the PWM says ON, the 50Hz could be passing thru a zero portion of the mains sinewave or at other times when the sine is passing thru a maximum.

So what you could see is a 'beat' pattern in the light output as the PWM and mains Phase drift past each other.

I assume you are driving a triac or src with the PWM.???

I don't understand about being connected to the mains, my PWM signal is just driving an LED and resistor, and being driven by a micro running at 5V. Where is the mains component coming from?

Are you using the built in AVR PWM capability?

No, I am using timers to create a PWM signal, I intend to scale up the PWM driver to multiple outputs once I have it working properly. I can't try anything on this till Monday eve now anyway, as I would like to lower the value of resistors limiting the LEDs.
 

crashmeplease

New Member
I can sometimes see the blinking of LED christmas lights fed off 60Hz. So something higher frequency than that would be good. I would think something in the 1 kHz range? I wonder if you could go too high with freq... how fast does an LED turn on/off ? Make the period less than that time.

Hmm, I have been looking at some calculations that I made, Shimniok, did you mean 100Hz?
 

ericgibbs

Well-Known Member
Most Helpful Member
hi
I misread the leds as lights, sorry about that.:)

Basically you have to use a flash rate higher than 25/sec [say 50Hz] to get the appearance of a 'steady' light.

Whats the period and PWM at the moment.?
 

crashmeplease

New Member
Whats the period and PWM at the moment.?

Hmm, I have managed to get this working, but I figure there must be an error in my maths or understanding of PWM :)

My maths says it's running about 62Khz at the moment, and I can dim the LEDs very to near off with no flicker.

My micro is running at 16Mhz, the timer pre-scale is set to divide by 1. If I divide this up into 8bit, I get the following ;

(16Mhz ÷ 1 ) ÷ 255 = 62.745Khz

Do the numbers sound right or am I overlooking something? As if I up the timer pre-scale to divide by 8, then that works out about 7.8Khz, but I can see the blinking quite easily. If I didn't know better I would say my values should be 62Hz and 7.8Hz respectively from an observational point of view :)
 

ericgibbs

Well-Known Member
Most Helpful Member
Hmm, I have managed to get this working, but I figure there must be an error in my maths or understanding of PWM :)

My maths says it's running about 62Khz at the moment, and I can dim the LEDs very to near off with no flicker.

My micro is running at 16Mhz, the timer pre-scale is set to divide by 1. If I divide this up into 8bit, I get the following ;

(16Mhz ÷ 1 ) ÷ 255 = 62.745Khz

Do the numbers sound right or am I overlooking something? As if I up the timer pre-scale to divide by 8, then that works out about 7.8Khz, but I can see the blinking quite easily. If I didn't know better I would say my values should be 62Hz and 7.8Hz respectively from an observational point of view :)

hi,
The PIC cycle is the crystal freq/4.

So the internal clock cycle is 4MHz [250nS]

Say prescale is 8, so it becomes, 500Khz.

Div by 256 in the timer = 1953Hz.?
 

crashmeplease

New Member
hi,
The PIC cycle is the crystal freq/4.

So the internal clock cycle is 4MHz [250nS]

Say prescale is 8, so it becomes, 500Khz.

Div by 256 in the timer = 1953Hz.?


I am using an AVR :) An ATmega32 to be more precise, it was my understanding that they have no internal cycle divisions, in that clock speed = crystal speed, but I am unsure what I need to be looking at in the datasheets for the micro?
 

picbits

Well-Known Member
From experience ......

On a static display (i.e. not mounted in a moving vehicle) a minimum of 100Hz. Anything less and I see the flicker out of the corner of my eye.

On anything that vibrates or moves, 1Khz or more
 

ericgibbs

Well-Known Member
Most Helpful Member
I am using an AVR :) An ATmega32 to be more precise, it was my understanding that they have no internal cycle divisions, in that clock speed = crystal speed, but I am unsure what I need to be looking at in the datasheets for the micro?

hi,
Just been reading the AVR d/s [ I dont use this device] it would appear you are correct, no internal division.:)

Do you have a scope.?
[I'm a Rotherham boy]
 
Last edited:

ericgibbs

Well-Known Member
Most Helpful Member
From experience ......

On a static display (i.e. not mounted in a moving vehicle) a minimum of 100Hz. Anything less and I see the flicker out of the corner of my eye.

On anything that vibrates or moves, 1Khz or more

I agree a 100Hz flicker on peripheral vision can be a pain.

The persistance of vision seems to be less effective.
 

crashmeplease

New Member
I can get access to a proper scope during the week, however the simulated scope gives me the attached image.

Now I am even more confused :)

The time/division is set to ~7ms, there are 9 divisions between each rising edge, so each complete pulse is 0.063 seconds. 1 ÷ 0.063 = 15.87 cycles/second, 16Hz? and 1 ÷ (0.063 ÷ 255) = ~4Khz

And the current duty cycle appears to be around 40%, 3.5 divisions high ÷ 9 divisions per cycle = 0.39 (39%)
 

Attachments

  • scope.jpg
    scope.jpg
    164.7 KB · Views: 450

crashmeplease

New Member
:eek: The software simulator seems to have been set to 1Mhz, hehe, thus 1Mhz ÷ 255 = ~4Khz so I am reading the scope correctly :)

I wonder if the micro itself is set to an internal oscillator mode rather than use the external crystal, will have to check that later :)
 

ericgibbs

Well-Known Member
Most Helpful Member
:eek: The software simulator seems to have been set to 1Mhz, hehe, thus 1Mhz ÷ 255 = ~4Khz so I am reading the scope correctly :)

I wonder if the micro itself is set to an internal oscillator mode rather than use the external crystal, will have to check that later :)

I'm a PIC guy, so I cant help with the AVR, be interesting to know what the outcomes is.:)
 

rikilshah

Member
It will be better you use trial and error method.You try different freq. and you'll be easily come to conclusion.

But one thing you must keep in mind about human eye persistence and you'll do better...:eek:
 

crashmeplease

New Member
Sorry in the delay, my dev board broke so I decided to build a new one :)

I'm a PIC guy, so I cant help with the AVR, be interesting to know what the outcomes is.:)

Yes one of the AVR fusebits was set to internal oscillator mode, I forget what speed it was set to, but the pwm output on the new board seems smooth with a 8Mhz Crystal, so suspect it was set at this speed.


It will be better you use trial and error method.You try different freq. and you'll be easily come to conclusion.

But one thing you must keep in mind about human eye persistence and you'll do better...:eek:

I agree, I give up trying to do the math, what I have looks good and I have no reason to mess with it.
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top