0

Run two strips in different layouts with arduino uno
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Run two strips in different layouts with arduino uno

by Exterior on Tue Jul 16, 2019 3:38 am

Hey guys, I've got some questions again and hope, you can help me.

I'm trying to run two strips (300 pixels each) in two different layouts:

1. both strips with the same program but with separate data pins
2. both strips combined to one long strip.

I operate those strips with an arduino uno.

In both layouts, I experience some problems.

The first layout is pretty simple: Two strips, two power supplies. One strip is connected to pin 5 on my arduino uno, the other one is connected to pin 6.
I try to run it with this code:

Code: Select all | TOGGLE FULL SIZE
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif

#define PIN 5
#define SECPIN 6

#define NUM_LEDS 300

#define BRIGHTNESS 255

Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_RGBW + NEO_KHZ800);
Adafruit_NeoPixel strip2 = Adafruit_NeoPixel(NUM_LEDS, SECPIN, NEO_RGBW + NEO_KHZ800);

byte neopix_gamma[] = {
    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,
    1,  1,  1,  1,  1,  1,  1,  1,  1,  2,  2,  2,  2,  2,  2,  2,
    2,  3,  3,  3,  3,  3,  3,  3,  4,  4,  4,  4,  4,  5,  5,  5,
    5,  6,  6,  6,  6,  7,  7,  7,  7,  8,  8,  8,  9,  9,  9, 10,
   10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16,
   17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 24, 24, 25,
   25, 26, 27, 27, 28, 29, 29, 30, 31, 32, 32, 33, 34, 35, 35, 36,
   37, 38, 39, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 50,
   51, 52, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 66, 67, 68,
   69, 70, 72, 73, 74, 75, 77, 78, 79, 81, 82, 83, 85, 86, 87, 89,
   90, 92, 93, 95, 96, 98, 99,101,102,104,105,107,109,110,112,114,
  115,117,119,120,122,124,126,127,129,131,133,135,137,138,140,142,
  144,146,148,150,152,154,156,158,160,162,164,167,169,171,173,175,
  177,180,182,184,186,189,191,193,196,198,200,203,205,208,210,213,
  215,218,220,223,225,228,231,233,236,239,241,244,247,249,252,255 };


void setup() {
  strip.setBrightness(BRIGHTNESS);
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'

  strip2.setBrightness(BRIGHTNESS);
  strip2.begin();
  strip2.show(); // Initialize all pixels to 'off'
 
  fullOff();
}

void loop {
   fullWhite();
}

void fullWhite() {
    for(uint16_t i=0; i<strip.numPixels(); i++) {
        strip.setPixelColor(i, strip.Color(0,0,0, 255 ) );
    }
    strip.show();


    for(uint16_t i=0; i<strip2.numPixels(); i++) {
        strip2.setPixelColor(i, strip2.Color(0,0,0, 255 ) );
    }
    strip2.show();
}

void fullOff() { 
    for(uint16_t i=0; i<strip.numPixels(); i++) {
        strip.setPixelColor(i, strip.Color(0,0,0, 0 ) );
    }
    strip.show();


    for(uint16_t i=0; i<strip2.numPixels(); i++) {
        strip2.setPixelColor(i, strip2.Color(0,0,0, 0 ) );
    }
    strip2.show();
}


But only the strip on Pin 5 is reacting and turns white, the other one on pin 6 just stays off. When I change the constants and SECPIN is pin 5, then the second strip will light up.

Do you know, how I can fix this? I just want to drive both strips from one arduino. I don't need parallel driven animations and so on, just lighting up white.

The second layout is fairly simple, too: Both strips are connected to form a single strip with 600 pixels. The two power supplies are used to feed in the power at different points.

I run this strip with the same program as above, but without all the code for the second strip. And it works to a certain extend. But I can only light up up to 466 Pixels. When I change the constant "NUM_LEDS" to 467 or above, th program won't run. It's not like that not more than 466 pixels will light up. The whole program won't do a thing in this case. All LEDs stay off. When I change to 466, those 466 LEDs light up, when I change to 467, nothing lights up at all.

My arduino IDE doesn't say anything critical. after compilation and upload, it says the sketch needs 2686 Bytes of space and 40 Bytes of RAM.

Why is this? Does anybody know?

Thank you for your help.

Exterior
 
Posts: 12
Joined: Sun Mar 17, 2019 5:41 pm

Re: Run two strips in different layouts with arduino uno

by oesterle on Tue Jul 16, 2019 6:24 am

Hi, Exterior!

If you want to have the same sequences running on both 300-pixel strips, I'd try connecting just one pin, like pin 6 to both strips DIN data pins. I'd modify the code to just deal with one 300-pixel strip logically, as the data goes to both identical strips. Since there's no data coming back from NeoPixel strips, this should work. (For bidirectional devices on I2C or SPI, this approach would not work.)

If you'd like to try keeping the strips on separate pins, I'd try reducing NUM_LEDS in your code to, say, 50, as a conservative test. Then the first 50 pixels on both strips should work, barring any issues with specific GPIO pins.

What you're probably running into is limited memory on the UNO. Beyond your program code and included libraries, each pixel requires 3 bytes of SRAM (memory). 466 pixels take 1398 bytes of SRAM. The Arduino UNO and the Adafruit METRO 328 have about 2KB or about 2000 bytes of SRAM.

If you were to upload your project to an Adafruit METRO M0 Express, it would likely have no problem; that board has 32KB of SRAM.

And with the newer Adafruit Metro M4 Express AirLift (WiFi) - Lite, you'd have 192KB of SRAM, plus WiFi.

(While the M0 and M4 are 3.3V logic boards, they have worked well for me controlling strips powered by 5V in recent projects. A logic level shifter may be necessary in some projects.)

I'm happy that you're using external power for the strips – for both strips full on, you'll need about 36A (via Estimating Power Requirements). I'd be sure to add a capacitor and resistor to protect your strips from voltage spikes, as detailed in the Basic Connections section of the Adafruit NeoPixel Überguide.

Cheers,

Eric
Last edited by oesterle on Tue Jul 16, 2019 6:36 am, edited 1 time in total.

oesterle
 
Posts: 656
Joined: Tue Sep 17, 2013 11:32 pm

Re: Run two strips in different layouts with arduino uno

by adafruit_support_bill on Tue Jul 16, 2019 6:35 am

I agree with Eric there. You are running out of memory on your UNO. 400-500 pixels is typically the limit depending on the complexity of your code. You have the gamma table in there also which will consume a chunk of SRAM. So 466 as an upper limit sounds about right.

To get to 600, you could go with one of the 32U4 based processors. These have an extra 512 bytes of SRAM. But that would be just barely squeaking by. Better to go with something like the M0 or M4.

https://learn.adafruit.com/memories-of- ... ot-dot-dot

adafruit_support_bill
 
Posts: 74659
Joined: Sat Feb 07, 2009 10:11 am

Re: Run two strips in different layouts with arduino uno

by Exterior on Tue Jul 16, 2019 10:42 am

Hey, thank you for your help, I will try these tips soon.

I also thought about the memory, but I thought the IDE would have said something. Well...

My problem now is: Ive got a strip installation with around 700 pixels. I will run these eventually on a Teensy 3.6, so RAM would be no problem. But I have to test this installation today, because after tomorrow, it will be difficult to make changes on the strips and the power input on the run. It won't be impossible though, but I would prefer to have this strip working before they hang the cabinets on the wall (which will make it more difficult to reach to the strip).

But I don't have the time to adapt my code to the Teensy and the Teensy itself isn't final yet (it needs Pins and the OctoWS-Module ore something to lift the voltage-output up to 5V) but I don't have the time for these things (the guys building my furniture gave me a date for the build up a lot earlier than expected). And I can't buy a board with more RAM in my location.
So what can I do to test not only the first 400 or so pixels but also the remainig 300? Can I add an offset for the lighting up? So first, light up the first 400 pixels and then put them off, add an offset of 400 and light up the pixels after the first 400? Would that work?

Exterior
 
Posts: 12
Joined: Sun Mar 17, 2019 5:41 pm

Re: Run two strips in different layouts with arduino uno

by adafruit_support_bill on Tue Jul 16, 2019 11:04 am

Testing the first 400 is easy enough. Just declare your strip as 400 pixels.

Testing the remaining 300 without additional memory is more difficult.

The simplest way is to declare a strip of 300, then jumper your signal wire to the input pin of pixel #401.

Other than that, you would need to do some low-level library hacking. And the Neopixel library is some pretty low level assembly code. Not an easy hack.

adafruit_support_bill
 
Posts: 74659
Joined: Sat Feb 07, 2009 10:11 am

Re: Run two strips in different layouts with arduino uno

by Exterior on Tue Jul 16, 2019 11:25 am

How am I supposed to do that?

I tried something like this:

Code: Select all | TOGGLE FULL SIZE
strip.setPixelColor(400+i, strip.Color(0,0,0, 255 ) );


But that didn't work. And I don't have additional data inputs on the run, only additional power inputs.

Exterior
 
Posts: 12
Joined: Sun Mar 17, 2019 5:41 pm

Re: Run two strips in different layouts with arduino uno

by adafruit_support_bill on Tue Jul 16, 2019 11:51 am

How am I supposed to do that?

it is not a software thing. You would need to physically jumper your signal wire to the input pin of pixel #401.

adafruit_support_bill
 
Posts: 74659
Joined: Sat Feb 07, 2009 10:11 am

Re: Run two strips in different layouts with arduino uno

by oesterle on Tue Jul 16, 2019 2:36 pm

And by that, Bill means that you'd skip the first 400 pixels in your test, and connect to pixel 401, as if it were the beginning of the strip. (Or whatever convenient point there is around 401.) Pixel 401 would be the beginning of your strip, for the test; it would be pixel number 0 in code, running through the end of your strip, at pixel 700ish.

So, pin 6 of your Arduino would connect to DIN way down the strip. Power and ground could be wired to as you expect to in your final composition for all parts of the strip.

Then, after testing, you could move your data wire to DIN at the beginning of the strip.

Wishing you the best! You can do this! Hope this is clear!

oesterle
 
Posts: 656
Joined: Tue Sep 17, 2013 11:32 pm

Re: Run two strips in different layouts with arduino uno

by Exterior on Sun Jul 28, 2019 7:09 pm

Thank you guys.

I connected my arduino and my power supply to the end of the string and it worked.
But now, I'm stuck at a different problem (which allowed me to test while connecting to the end of the strip in the first place...), maybe you can take a look there, too?

But I couldn't manage to test in the middle of the string. I soldered a 3-pin-connector at the middle of the string, connected my arduino and nothing happened, not lighting up at all.

Now I have a small strip for testing. When I solder my connector to the beginnig of the string, every lights up, everything is fine.

Then I soldered the exact same connector to the middle of the strip and expected that half of the strip following the connector would light up. But nothing happened, nothing lights up at all. Do you know, why nothing hapens?

Thank you very much for your help.

Exterior
 
Posts: 12
Joined: Sun Mar 17, 2019 5:41 pm

Please be positive and constructive with your questions and comments.