Go Down

Topic: Controlling multiple P9813 modules with dumb strings individually with FastLED (Read 191 times) previous topic - next topic

lightsycle

Hello All,

HW

Adruino Uno (DFRduino variety) v3.0 R3
Cascabable P9813 LED strip driver modules x4 This one
One 5m roll RGB LED (dumb)

I am having a problem getting my modules to be controlled as individuals. I can get them to function all at the same time or connected individually, but not as 4 separate "LEDs" connected to one Arduino.

I have 12v to the power connectors and 5V to module power of all 4 modules VIA a bread board. The Arduino is connected to the PC with USB. Power is coming from the PC PSU, so I guess they are sharing a common ground, just not directly.

The data and clock pins are 2-9; Module#1 :CLK-2, DATA-3, Module#2: CLK-4, DATA-5, etc.

I have tried many examples in the FastLED library (perhaps I should use another library?)

This is the blink example...mostly:

Code: [Select]

#include "FastLED.h"
// How many leds in your strip?
#define NUM_LEDS 4

#define DATA_PIN_0 3
#define CLOCK_PIN_0 2
#define DATA_PIN_1 5
#define CLOCK_PIN_1 4
#define DATA_PIN_2 7
#define CLOCK_PIN_2 6
#define DATA_PIN_3 9
#define CLOCK_PIN_3 8

// Define the array of leds
CRGB leds[NUM_LEDS];

void setup() {
 Serial.begin(115200);   
     
      FastLED.addLeds<P9813, RGB>(leds, NUM_LEDS);
     
      FastLED.addLeds<P9813, DATA_PIN_0, CLOCK_PIN_0, RGB>(leds, NUM_LEDS);
      FastLED.addLeds<P9813, DATA_PIN_1, CLOCK_PIN_1, RGB>(leds, NUM_LEDS);
      FastLED.addLeds<P9813, DATA_PIN_2, CLOCK_PIN_2, RGB>(leds, NUM_LEDS);
      FastLED.addLeds<P9813, DATA_PIN_3, CLOCK_PIN_3, RGB>(leds, NUM_LEDS);
}

void loop() {
 for(int i = 0; i < NUM_LEDS; i++) {
     leds[i] = CRGB::Green;
     FastLED.show();
     // clear this led for the next time around the loop
     leds[i] = CRGB::Black;
     Serial.println(i);
     Serial.println(leds[i]);
     
     delay(250);
     }
}


Here is the current running code where they all blink green, or whatever color I put in "CRGB::[color]"

I can set the CLK and DATA pins of each module individually and they function as they should; blink, colors, time, or with the current code they all act as one, doing the same thing.

I googled in the forums and got about 5 returns for p9813 modules, and have been searching other places for a few days now.

I am not using smart LEDs. I have one 3-LED segment of an RGB roll on each module for testing. Didn't want my desk clogged with long strips. :-)

What I want to do is have the program see each module as "one" LED and be able to control that one independently of the others, as in one red, one blue, one green and one off.

I had hopped that the example would do that and would cause the "one" LEDs to chase or run as they cycled through the number of LEDs, but that was not the case. I am unable to control them separately when more than one is connected.

I inserted a print line to output the arrays. The output I get is 0 0, 1 0, 2 0, 3 0 repeating. One array is cycling (void loop I'm speculating), but the one that identifies the LED module is not.(again speculating) "i" is incriminating as it should by the counter in the loop but (leds) is not.

If I have left out anything, or more detail is needed I will provide.

Thanks.

P.S. I am not new to computers or electronics, but my knowledge of coding is small, and very rusty.

Grumpy_Mike

Quote
I am unable to control them separately when more than one is connected.
That is because you are not writing your code correctly. You can make it look like you are controlling each LED individually if you only change that number LED in the data buffer and rewrite it all out again. Only the one LED changes and all the others stay the same.

lightsycle

I presumed I was writing my code incorrectly, but I can't find any examples of multiple independent led strings. Everything I found involves smart pixels. I've looked over the library info and didn't see what I was looking for. That's why I've posted here hoping to get some help, or nudge in the right direction.

I hope the fastled library is capable if what I want , but I can't seem to find anything definitive that says one way or another. Lots of mention of many strings of smart leds, and even strings of strings.

Perhaps,  Grumpy_Mike, you could offer a command or function or snippet even, rather than just telling me I'm doing it wrong. I already knew that.

Wawa

Confused.
Never worked with these modules, but..

In your code I see four cascaded LED boards defined.

But I also see four clock pins and four data pins.

16 boards?
Leo..

Grumpy_Mike

Quote
Perhaps,  Grumpy_Mike, you could offer a command or function or snippet even, rather than just telling me I'm doing it wrong. I already knew that.
I did tell you how to do it right did you miss that? Or did you not understand what I said? If not then ask about what you did not understand.

Quote
but I can't find any examples of multiple independent led strings.
In the examples folder that came with the libiary their is a folder called 'Multiple", this contains four example codes for using multiple strings. Please explain why one of them is not what you want and say exactly what it is you want.

It also says in those sketches that for more information about this see https://github.com/FastLED/FastLED/wiki/Multiple-Controller-Examples

lightsycle

My coding skills are not very good. I'm learning, and relearning as I go. I'm not looking for someone to code for me, just explain some things.

Quote
In your code I see four cascaded LED boards defined.

But I also see four clock pins and four data pins.
I was under the impression that each board had to have its own data and clock connection to be independent... Is this no the case? Can the modules all be controlled independently from one set of pins?

Perhaps I should read up on the modules.

Grumpy_Mike:

I tried a few of the multiple examples, but they don't seem to fit, unless I'm going about it wrong.

The one that says array of arrays, it has Num_Strips 3, and LED/Strip 60. I could use that I suppose. Mine would be 3 strips and 1 LED, but that seems like it is more complicated than it needs to be.

I will look at that example more closely.

Thanks for the help thus far people.

Wawa

It seems the board is electrically the same as a single addressable LED.
Only with power mosfet outputs, to control an RGB LED string.

If so, then the four modules should be treated as one string of four addressable LEDs.
Leo..

Grumpy_Mike

Quote
but that seems like it is more complicated than it needs to be.
Do you mean it has a two dimensional array and you are not too sure abut them?
If so just look what the code is doing, it is taking a refrence for each string you declare, stick them in separate arrays if you want not a two dimensional array.

lightsycle

Thanks for the help. I rewired them in the chainable fashion instead of trying to have each with its own connection to the arduino and they are working! That was my problem. Not treating each module as a smart pixel. I can now control them individually by referencing the array position led with variable or number.:D

Thanks for helping me work this out.

Grumpy_Mike

Glad you got it working to your liking but:-
Quote
I rewired them in the chainable fashion instead of trying to have each with its own connection to the arduino and they are working!
It will work the way you originally wired it, if you get the software right.

Go Up