I am controlling an RGB LED strip using PWM Pins 9,10,11 according based on this tutorial:
When I dim the light the LEDs start flickering. Shouldn't the the PWM frequency be high enough so that i cant see the flickering?
Does anyone knows the the standard frequency of PWM? Should I manipulate the PWM frequency?
Its kinda hard to tell what is happening and not. It sounds like maybe you are trying to run the whole strip of LEDs off the arduino, which sounds like too much current for the arduino, but then again, its hard to say from here.
If you can include more details (like show us the entire circuit, including power supply, how many LEDs, which type of arduino you are using, ...)
I use an Arduino "compatibel" to the Nano 328. I am using mosfets so the LEDs strip current does not flow over the arduino and the ground and the +12V supply are the same for the arduino and the LED Strip. The wiring is identical to the tutorial:Usage | RGB LED Strips | Adafruit Learning System
What do you actually mean by flickering?
Is it perceivable looking directly at the light?
Or is it that you want to see no flicker as you rapidly scan your eyes across the field of view that contains the lights?
Hi lukeskymuh, I believe I might be encountering the same issue as you. The flickering I encounter is when the leds are dimmed to a low pwm value, they flicker in a way a candle flame does right before it goes out. Not like a refresh rate problem. I thought it was my hardware but I realize now I am not encountering the problem when I set the pwm to a fixed value, or strobe it with a simple loop. Turns out, the only time I can get this flicker to happen is when running that color swirl code form adafruit which you linked to. We have different hardware setups, but we are using that same bit of code. Do you have the flicker when setting the pwm to a value of 10 or when doing a simple pwm increase loop on the leds?
Sathi:
Hi lukeskymuh, I believe I might be encountering the same issue as you. The flickering I encounter is when the leds are dimmed to a low pwm value, they flicker in a way a candle flame does right before it goes out. Not like a refresh rate problem. I thought it was my hardware but I realize now I am not encountering the problem when I set the pwm to a fixed value, or strobe it with a simple loop. Turns out, the only time I can get this flicker to happen is when running that color swirl code form adafruit which you linked to.
What TLC library is that using? It's definitely possible to cause flicker by not controlling the chip properly.
No where in the thread was the TLC mentioned, yet you guessed that I might be using it? I am indeed. Is this a known issue? When I get home I will check what version of the library I have. Thanks.
Not sure what the deal is, but I can generate all sorts of weird artifacts based on different code parameters. If I increase
the pwm values at a slow rate, the leds increase in brightness in pulsating sort of pattern, like they are breathing. At faster speeds things look smooth. But I can't get it to fade slowly from one color to the next in a smooth manner. Especially at low
pwm values where they have that strange candle light like flicker. I'll avoid hijacking this guys thread and make a new topic on this I can't get it worked out. Thanks.
Know this is old but I thought I'd just chime in here as this was doing my head in!
I was seeing the exact same thing and no change in the code seemed to fix it.
It was barely noticeable on the red channel, but very noticeable on green and a bit less on blue.
Anyway, I was using a 12V 1A adapter and even though the strip i was using should have been drawing less than that, when I swapped it for a 6A unit, all flickering ceased.
Anyway, I was using a 12V 1A adapter and even though the strip i was using should have been drawing less than that, when I swapped it for a 6A unit, all flickering ceased.
That is probably because you did not have enough decoupling capacitors on your power supply. A couple of caps would have saved you from buying a 6A supply.
Grumpy_Mike:
That is probably because you did not have enough decoupling capacitors on your power supply. A couple of caps would have saved you from buying a 6A supply.
Seems I misread the current draw for the strips. With the 6A supply connected I measured 3A draw at %100 white. Stats were correct, I was just not accounting for the correct strip length.
3A from a 1A supply. Flickering should have been the least of my worries!
(I was using pins 5, 6, 9 on an ATmega328P, 5+6 being controlled by timer0)
of course, that means that milliseconds now last twice as long but I can live with that
maybe it will help someone who has the same kind of problem...
btw, the flickering does seem to depend on the current drawn (as it was way less noticeable and sometimes completely unnoticeable with a shorter strip) but even though my LED strip draws ~1.5Amp, even buying a 5Amp power supply for it didn't solve the issue before I tried the timer tweak.
I'm a bit sorry as this thread is so old, but I'm also so near to the solution...
@blueshade how did you do it?
I've read the article, but I'm new to Arduino and honestly I haven't understood it 100%, I only got what the exact problem is. It would be very nice if you could provide the code which got it working for you.
I got it!
I found this article: Arduino Playground - TimerPWMCheatsheet
I think it's a bit better explained here how you get to a solution.
So I just put this into setup:
and made this change in the wiring.c file (revert this change! only use it for this one sketch so that the millis and delay are correct here):
// the prescaler is set so that timer0 ticks every 64 clock cycles, and the
// the overflow handler is called every 256 ticks.
#define MICROSECONDS_PER_TIMER0_OVERFLOW (clockCyclesToMicroseconds(64 * 510))