Pages: [1]   Go Down
Author Topic: Flickering leds problem  (Read 2036 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 1
Posts: 32
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I made a Philips Ambilight clone using BobLight (google it if interested) and Arduino Mega.
The system is now up and works nicely. I have only one problem:
The leds are flickering a bit. They are controlled with ULN2003 ic and the ics are feeded with arduinos pwms.
I know that the analog write values that I write in the loop are stable but for some reason leds are flickering noticably.

My questions are:
Do you have an idea  what is causing this?
Is there an easy solution to somehow even out / filter the current to the leds with some electronic component (capacitor, resistor, etc..)?

Thanks in advance
-orbitrek
« Last Edit: February 03, 2011, 11:48:25 am by orbitrek » Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16548
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There are many reasons that might cause flickering. However without a schematic drawing and posting your code it's nearly impossible to try and guess at what might be the cause(s).

Lefty

Logged

0
Offline Offline
Newbie
*
Karma: 1
Posts: 32
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
Thanks for the reply.
My schematic is dead simple. It is nicely described in the picture in this thread (see a post by "Makkan").
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1236091181

This is the code: (which is also quite simple)
Code:
// Declare variables for pin numbering
int r1Pin = 9;
int r2Pin = 2;
int r3Pin = 5;

int g1Pin = 10;
int g2Pin = 3;
int g3Pin = 6;

int b1Pin = 11;
int b2Pin = 4;
int b3Pin = 7;

// Declare variables for serial data read
// R1R2R3G1G2G3B1B2B3
int RR1 = 50;
int RR2 = 50;
int RR3 = 50;
int GG1 = 50;
int GG2 = 50;
int GG3 = 50;
int BB1 = 50;
int BB2 = 50;
int BB3 = 50;

void setup()
{
  // Set pins for data output
  pinMode(r1Pin, OUTPUT);  
  pinMode(r2Pin, OUTPUT);
  pinMode(r3Pin, OUTPUT);  

  pinMode(g1Pin, OUTPUT);  
  pinMode(g2Pin, OUTPUT);
  pinMode(g3Pin, OUTPUT);
 
  pinMode(b1Pin, OUTPUT);  
  pinMode(b2Pin, OUTPUT);
  pinMode(b3Pin, OUTPUT);
 
  // open serial port
  Serial.begin(9600);
}

void loop()
{
    // read data from serial (MoMoLight-"protocol")
    while(true){
      if (Serial.available() > 8) {
RR1 = Serial.read();
RR2 = Serial.read();    
RR3 = Serial.read();
GG1 = Serial.read();
GG2 = Serial.read();
GG3 = Serial.read();
BB1 = Serial.read();
BB2 = Serial.read();
BB3 = Serial.read();
      }
    
    // Write values to PWM ports (values = 0...255)
    analogWrite(r1Pin, RR1);
    analogWrite(r2Pin, RR2);
    analogWrite(r3Pin, RR3);
    
    analogWrite(g1Pin, GG1);
    analogWrite(g2Pin, GG2);
    analogWrite(g3Pin, GG3);
    
    analogWrite(b1Pin, BB1);
    analogWrite(b2Pin, BB2);
    analogWrite(b3Pin, BB3);
}
}

If you have any ideas, I'd be glad to hear them. Thank you.

EDIT: And I noticed it is more clearly visible with some specific shades.
« Last Edit: February 06, 2011, 04:24:16 pm by orbitrek » Logged

Austin, TX
Offline Offline
Faraday Member
**
Karma: 64
Posts: 6055
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The thread you reference doesn't so a schematic with ULN2003s in it.  You'll need to provide an actual schematic of your circuit.

Probably not related to the flickering you are seeing, but there is no need for the "while(true)" loop.  loop() already does this for you.
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 514
Posts: 31543
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Is it this one?


If so the first thing to note is that you are over driving that chip. You can't have 1.2A being switched on at the same time due to the thermal dissipation limit of the chip. See :- http://www.thebox.myzen.co.uk/Tutorial/Power_Examples.html

Next flickering covers a wide variety of behavior, can you be more specific?

To eliminate a software problem, write a sketch that doesn't read anything from the input and just changes the intensity of each lamp on an algorithm of some sort. Like incrementing one light every 100mS, it's OK to use delay for testing.
Logged

0
Offline Offline
Newbie
*
Karma: 1
Posts: 32
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yep, That's the one. Thanks for the heat dissapation link.
The led strip is driving 180 mAmps per channel at max and it is rarely reached. There's max 5 channels per chip. So 0,9 amps is the max.

How would I explain the flickering. It is some (high frequency) changes in the intensity of the light. So that light is not stable and calm and steady. It is actually doing it really little, but enough to catch the eye.

I need to do some testing without serial reading.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 514
Posts: 31543
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
There's max 5 channels per chip. So 0,9 amps is the max.
So too much then.

Quote
It is some (high frequency) changes in the intensity of the light
It is the high frequency that is the important factor. When you switch a lot of current you can get instability in a circuit, try a bit of decoupling:- http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html

Quote
I need to do some testing without serial reading.
Yes you need to see if you are telling the software to make it flicker first.
« Last Edit: February 10, 2011, 01:08:59 pm by Grumpy_Mike » Logged

Pages: [1]   Go Up
Jump to: