RGB controlling with processing,LEDS flicker

Hello,

I am new here and I have a problem with my first project.
I have bought 5m of RGB led strip, an arduino mega, 3 power mosfets to control each color and a 12v 14A power supply.
The intention is to control the strip with my iphone using processing and touchOSC. I've been following a tutorial to accomplish this and it goes like this

-StandardFirmata uploaded to the arduino
-installed all libray's that are required.
-Processing code:

import processing.serial.;
import cc.arduino.
;
import oscP5.;
import netP5.
;

Arduino arduino;
OscP5 oscP5;

float redAmount = 0.0f;
float greenAmount = 0.0f;
float blueAmount = 0.0f;

void setup(){
size(320, 480);
background(0);
oscP5 = new OscP5(this, 8000);
arduino = new Arduino(this, Arduino.list()[0],57600);
}

void draw(){
background(redAmount, greenAmount, blueAmount);

fill(0);
//Rode Rechthoek
stroke(255,0,0);
rect(34,39,67,255);
fill(50,40,40);
rect(34,39+255,67,-redAmount);

//Groene rechthoek
fill(0);
stroke(0,255,0);
rect(124,39,67,255);
fill(40,50,40);
rect(124,39+255,67,-greenAmount);

//Blauwe rechthoek
fill(0);
stroke(0,0,255);
rect(216,39,67,255);
fill(40,40,50);
rect(216,39+255,67,-blueAmount);

//Naar Arduino Schrijven(Rood op pin 11,groen op pin 10, blauw op pin 9)
arduino.analogWrite(11, int(redAmount));
arduino.analogWrite(10, int(greenAmount));
arduino.analogWrite(9, int(blueAmount));

}

void oscEvent(OscMessage theOscMessage){
String addr = theOscMessage.addrPattern();
float val = theOscMessage.get(0).floatValue();

if(addr.equals("/1/Rood")){ redAmount = val;}
if(addr.equals("/1/Groen")){ greenAmount = val;}
if(addr.equals("/1/Blauw")){ blueAmount = val;}
}

-Correct OSC program build using OSCeditor

Now my problem is that the controls and such work but the string is flickering irregularly like there is some kind of noise on it.

What could cause this? I've tried a single led on the arduino but it still does the same.

Thanks
LouisG

but the string is flickering irregularly like there is some kind of noise on it.

The string? Of what? LEDs? How can there be noise on the LEDs?

-Correct OSC program build using OSCeditor

And that program might be?

  arduino = new Arduino(this, Arduino.list()[0],57600);

The Arduino can handle speeds twice this fast.

void setup(){
  size(320, 480);
  background(0);
  oscP5 = new OscP5(this, 8000);
  arduino = new Arduino(this, Arduino.list()[0],57600);
}

Probably useful to tell the Arduino that the output pins ARE OUTPUT pins.

PaulS:

but the string is flickering irregularly like there is some kind of noise on it.

The string? Of what? LEDs? How can there be noise on the LEDs?

First of all I shall excuse myself for my bad English, it's not my language so it's a bit hard for my to write in :wink:
I do indeed mean the 5meters of led strips and with noise i mean some kind of electronic noise, unwanted electrical signals like there often is on (home build)electronic devices

PaulS:

-Correct OSC program build using OSCeditor

And that program might be?

It's hard to explain, OSCeditor allows you to make a visual program using sliders and buttons and such, and then upload it to your iphone.
Here's a youtube link to how it works

PaulS:

  arduino = new Arduino(this, Arduino.list()[0],57600);

The Arduino can handle speeds twice this fast.

And could this cause the flickering in the LED's?

PaulS:

void setup(){

size(320, 480);
  background(0);
  oscP5 = new OscP5(this, 8000);
  arduino = new Arduino(this, Arduino.list()[0],57600);
}



Probably useful to tell the Arduino that the output pins ARE OUTPUT pins.

Isn't it so that the StandardFirmata on the arduino determined if the pins are OUTPUTS or INPUTS?

it's not my language so it's a bit hard for my to write in

Understandable.

Isn't it so that the StandardFirmata on the arduino determined if the pins are OUTPUTS or INPUTS?

How would it know? It's best not to assume stuff like this.

I do indeed mean the 5meters of led strips and with noise i mean some kind of electronic noise, unwanted electrical signals like there often is on (home build)electronic devices

Whether this is true or not is hard for us to determine, without a lot more information about your setup.

I have bought 5m of RGB led strip, an arduino mega, 3 power mosfets to control each color and a 12v 14A power supply.

I would assume that 14A is sufficient, so that shouldn't be a problem. You'll need to confirm that assumption, though.

So, next I'd look at the mosfets. Are they wired correctly? Good ground? Stable connections to the LED strips? Are they capable of handling the current that the LED strips draw? Are they capable of switching on and off with just the current supplied by the Arduino? Are they capable of switching off and on fast enough (that is, at the frequency that the Arduino is switching them on and off)?

And could this cause the flickering in the LED's?

I'll assume that the iPhone application only sends data when there is an update to the slider. A bad assumption on my part, but one that I can not check.

You will need to look at the application that you are running, if you can.

If you can't, watch the RX led, and see when it flashes. If it's nearly continuous, increasing the baud rate might help. If it only flashes when the slider is moved, changing the baud rate won't help.

Ok, today I changed the baudrate to 115200 and declared the pins and the flickering is still here but a lot less.
The flickering is constantly there,so not only when you move the sliders, but also when for example all the leds are fully lit(or at any other steady position)

My setup:

-5meters of common anode RGB led strips fed by the powersupply
-3 IRLZ14 power mosfets who are more than sufficient for the purpose(datasheet:IRLZ14 Datasheet pdf - 60V Single N-Channel HEXFET Power MOSFET in a TO-220AB package - International Rectifier)
connected this way:
Source to ground powersupply and to gnd arduino
Drain of each mosfet to a LED color
Gate of each to a port on the arduino
-12v supply to a 1205 5v stabiliser and the 5v to the Vin on the arduino

-Arduino Mega 2560 with StandardFirmata(with baudrate 115200 now) on it(could this cause the problem?Could i make my own?Because 99% of the standardFirmata is useless for my purpose)
-Processingsketch like in my starterpost but with the pins declared and the baudrate changed to 115200
-iphone app touchOSC made with OSCeditor

Edit: F.Y.I. this is the tutorial i've used: Arduino iphone processing color mixer tutorial - YouTube

today i've bin working with my LED's again. When i broke down the table the leds were in to get to the arduino i have noticed something. The string of LEDS is flickering exactly the same as the TX led on the arduino. But is the TX light not to indicate the arduino is sending data to my computer? Why is it doing that? And how can this cause interferrence with all the ports on the arduino? Could it be a glitch in the Firmata ??

The first thing I would do is create a sketch that simply cycled through red, green, and yellow values, just like what the Arduino would receive if the red slider was moved through its full range, followed by the green slider, followed by the red slider.

If the LEDs still flicker, the problem is not with Processing or Firmata. If the LEDs don't flicker, then it is.

If they do, I'd dump firmata and write my own protocol. You are sending three bytes to the Arduino, although Processing converts the values to strings, and the Arduino converts them back. That takes a not-insignificant bit of time. Send a start of packet marker, three bytes, and an end of packet marker ("<", r, g, b ">", for example).

On the Arduino, look for the start of packet marker. Then read the next 4 bytes. If the 4th byte is the end of packet marker, use the 3 bytes before it. If not, a byte got fropped, so discard the packet.

Ok, I just tried to upload a normal RGB cycling script and the LEDS do not flicker anymore, so the hardware is not the problem.
However, once I had uploaded the StandardFirmata again, the arduino did not respond to processing anymore. The RX/TX lights are off and the processing program that displays the state of my iphone sliders is VERY slow(once i move my slider on my iphone, the change only show after 20-30 seconds on my computer). What is going on here? Now I am back at square one.. =( =(

Allright, today i've had a fresh start. Unplugged everything from my mac mini and started over aigain.
This time I was able to upload the StandardFirmata again and got processing and touchosc back running again. However the flickering has gone worse now.
It's clearly that the flickering is exactly the same as the flickering of the TX light on the arduino.

So how could the TX indicator light (wich means my arduino is sending data to my computer(what for and who said it could do that?????)) could be interfering with my PWM pins???

wich means my arduino is sending data to my computer(what for and who said it could do that?????

You did, when you uploaded the StandardFirmata sketch.

got the same problem here, try using the simpleanalog firmata sketch, that stopped flicker for me!

(sorry for my english!)

Charlie

I know this is old, but I spent 8.5 hours yesterday trying to fix this LED strip flickering problem.

Charlie's suggestion fixed this problem! I am grateful.

I hope that people googling / using the forum search may easily come across this if they have the same problem.

charlie_dream:
got the same problem here, try using the simpleanalog firmata sketch, that stopped flicker for me!
...
Charlie

So:
If one is controlling an LED strip with PWM using Processing and an Arduino and visible unwanted flickering in the LEDs is present, one should try loading the SimpleAnalogFirmata sketch instead of the StandardFirmata sketch onto the Arduino.
No need to edit the StandardFirmata to change how the Timers in the Arduino digital pins work or anything more complicated.

Just for the record, I am using:

  • Arduino Uno R3 with Atmega328
  • Processing 2.2.1
  • USB cable for computer-Arduino connection
  • 12V 5Amp wall power supply
  • 3 N-channel MOSFETs (rated for 30V / 60Amps)
  • jumper cable wires
  • half-size breadboard
  • a 2 meter RGB+Warm White LED strip - 60 LEDs / meter = 120 total LEDs

Thank you!