1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

RPi + OSMC More than 255 leds?

Discussion in 'Hardware Support' started by themorb, 17 November 2016.

  1. themorb

    themorb New Member

    Messages:
    2
    Hardware:
    RPi3, +Arduino
    I am using an Arduino Uno to control my LEDs and if I go past 256, they do all turn on for a few seconds when the sketch starts, but I can't turn on a solid colour via Hyperion remote. 256 or fewer works fine.

    The top of the sketch has the following:

    #define LEDCOUNT 256 // Number of LEDs used in your system
    #define SHOWDELAY 20 // Delay in micro seconds before showing
    #define BAUDRATE 1000000 // Serial port speed

    #define BRIGHTNESS 100 // Max. brightness in %

    const char prefix[] = {0x41, 0x64, 0x61, 0x00, 0xff, 0xaa}; // Prefix at the start of the transmission
    char buffer[sizeof(prefix)]; // Temporary buffer for receiving the prefix data
    I think the issue may be because the prefix array final 2 values go to 2 bytes. For example 258 would give 0x101 and 0x154. I am very rusty at coding...

    Can I make this work? With 60/m strips it works out to 266 LEDs in total. I could order 30/m strips and end up with around 134. I have already added a few thicker power wires to each corner and I seem to be able to run all of them at full white without any problems.
     
  2. penfold42

    penfold42 Moderator Developer

    Messages:
    742
    Hardware:
    RPi1/Zero, RPi2, RPi3, 32/64bit, +Arduino, +nodeMCU/ESP8266
    • Informative Informative x 1
  3. themorb

    themorb New Member

    Messages:
    2
    Hardware:
    RPi3, +Arduino
    Wow, solved in less than 2 hours. Amazing, thank you very much! Makes perfect sense now that I see there is that empty byte sitting there... wonder how long it would have taken me to figure that out on my own?!
     
  4. crowLight

    crowLight New Member

    Messages:
    2
    Hardware:
    RPi3
    Hey there, I am in the same situation and wondering how I get 0x185 and 0x1d0 to only 2 digits? I'm trying to use 390 LEDs and ran into the same problem as themorb where I can get more than 256 LEDs operational... Line in my Arduino sketch the same.

    Tried to reverse engineer your numbers for 266 but not sure I understand where the extra byte is that themorb mentioned.... Would the first digit not be 109?

    For 390 LEDs I get 0x185 and 0x1d0

    Any help would be greatly appreciated
     
  5. penfold42

    penfold42 Moderator Developer

    Messages:
    742
    Hardware:
    RPi1/Zero, RPi2, RPi3, 32/64bit, +Arduino, +nodeMCU/ESP8266
    If the alternate sketch that doesn't care for the header checksum isn't working, try:

    390 leds:
    const char prefix[] = {0x41, 0x64, 0x61, 0x01, 0x85, 0xd1};

    First 3 bytes are Ada and always fixed.

    Next 2 bytes:
    390-1 is 0x01 0x85 in hex

    Last byte is a check "sum"
    Hi XOR Lo XOR 0x55
    0x01 XOR 0x85 XOR 0x55 = 0xD1
     
  6. crowLight

    crowLight New Member

    Messages:
    2
    Hardware:
    RPi3
  7. Mackwhyte

    Mackwhyte New Member

    Messages:
    14
    Hardware:
    RPi1/Zero, RPi3, +Arduino
    Hi there, first post and it appears the solution to my problems may be here!

    I have set up an Ambilight system running from RPI3 with Libreelec OS, WS2812B Leds and a UTV007 Grabber/Splitter from Lightberry
    i initially set up the system with an arduino Uno R3 to control the LED's, it would communicate via USB (RX would flash in sequence with info) but no Lights would come on, only boot sequence would repeat whenever i SSH'd hyperion.

    Switched to using the GPIO pins and initially had success running Openelec (latest release) but then out of nowhere the system developed serious lag. it would take 15-20 minutes for the Pi to boot but once it did it would work fine. Tried 2 different SD cards and re-installs, the first reinstall appeared to solve it but upon reboot hyperion wouldn't start. The issue only appeared on first boot though, if i restarted via SSH it would work fine. Same when i tried Libreelec, wouldn't start first time but with none of the "green" issues from the grabber that people seemed to have. Tried OSMC and it wouldn't work at all. Read about the issues with recent versions of OSMC so I got a version from 2015 (30th August) but it wouldn't even boot.

    Reinstalled Libreelec again recently and all seemed well, but then i noticed on the second boot, only 255 of the LEDs lit (out of 392). However, the LED's were still in the right place relative to the screen and effects worked as you'd expect, dissappearing when they would be above LED 255. It appears to be the issue with all my installs that the LED count exceeds 255 so i thought I'd switch back to the Arduino (Although i now have the Mega, incase the Uno is not up to the Job)

    I think my initial failure with Arduino is the same as CrowLight;

    the prefix, mine ending 0X187 0X1D2 (for 392 LEDs)

    Am i right in thinking i need to change this to 3, 2 digit numbers?
    0x01 then ignore the 1 so 0x87 then add 1 to the last value 0xD3?
    or is that totally wrong? (i assume it is!)
    I tried XORing all 3 but there seems to be a lot of debate on which is the correct way to do it.
    I tried 0x01 XOR 0x87 and got 0x89 then XOR'ed again with 0x55 and got 0xDC, that seems more likely!

    So long story short could you confirm how you managed to work out the prefix as i am planning on making another system and will probably again exceed 255 LED's

    Thank you very much for the help and sorry for the Novel, just wanted to make sure al info was there if necessary!
     
    Last edited: 18 November 2017
  8. Mackwhyte

    Mackwhyte New Member

    Messages:
    14
    Hardware:
    RPi1/Zero, RPi3, +Arduino
    Ok, please tell me the prefix is wrong!

    I tried with the new prefix and still couldn't get it working, tried so many different arduino scripts too, none of them worked. Triple checked Baud rates matched and tried multiple different ones. Tried changing number of LEDS below 256 and got matching prefixes, still won't work. Tried both the Uno and Mega, same thing every time, Rx flashing but no lights.

    Any advice at all? I have now sank 100+ Hours into this, the system doesn't cope through GPIO so I need to something else to do the processing, i was wondering about USBASP but is it limited to 256 Leds?

    Would really appreciate the help, I'm totally out of ideas, don't wan't to buy anything else if i can't even get it working on Uno!
     
  9. Akriss

    Akriss Active Member

    Messages:
    330
    Hardware:
    RPi1/Zero, RPi2, RPi3, 32/64bit, +Arduino, +nodeMCU/ESP8266
  10. Mackwhyte

    Mackwhyte New Member

    Messages:
    14
    Hardware:
    RPi1/Zero, RPi3, +Arduino
    Yeah, Unfortunately I didn't have much luck with it either! Thanks anyway!
     
  11. TPmodding

    TPmodding Administrator Staff Member Administrator

    Messages:
    918
    Hardware:
    RPi1/Zero, RPi2, RPi3, +Arduino
    did you try a strand test sketch? without hyperion...i like to test my stripes with n-1 leds, to see if the stripe works, after that i use them...
     
  12. Mackwhyte

    Mackwhyte New Member

    Messages:
    14
    Hardware:
    RPi1/Zero, RPi3, +Arduino
    Yeah the strand tests are all fine. The ambilight works perfectly through GPIO and a logic converter, its just after the reboot that i get issues hence changing back to Arduino.
    The Arduino plays it's initial opening sequence then no response from there.

    To clarify the strand tests were obviously done with just the arduino, read that back and it sounded wrong haha
     
  13. TPmodding

    TPmodding Administrator Staff Member Administrator

    Messages:
    918
    Hardware:
    RPi1/Zero, RPi2, RPi3, +Arduino
    can you post your hyperion config
     
  14. Mackwhyte

    Mackwhyte New Member

    Messages:
    14
    Hardware:
    RPi1/Zero, RPi3, +Arduino
    This should be the right config, i have a few now with the amount of swapping back and forth from GPIO to Arduino

    in the GPIO config i've manually added;
    gpio" : 18
    "dmanum" : 5,
    "freq" : 800000

    don't think thats relevant for the arduino config though
     

    Attached Files:

  15. TPmodding

    TPmodding Administrator Staff Member Administrator

    Messages:
    918
    Hardware:
    RPi1/Zero, RPi2, RPi3, +Arduino
    "delayAfterConnect" : 0,
    pls change this to
    "delayAfterConnect" : 15,

    and try this one on your arduino mega ->use pin 51 please
     
    • Like Like x 1
  16. Mackwhyte

    Mackwhyte New Member

    Messages:
    14
    Hardware:
    RPi1/Zero, RPi3, +Arduino
    I will do, the setup is at my parents house, i should be there tomorrow so I will keep you posted!

    I did originally have a delay after connect of 20, then i set it higher in the hopes it would help, is there a reason 15 was chosen or is it just a good value?

    Thanks very much for the help!
     
  17. Akriss

    Akriss Active Member

    Messages:
    330
    Hardware:
    RPi1/Zero, RPi2, RPi3, 32/64bit, +Arduino, +nodeMCU/ESP8266
    Hi,

    I remembered a link that may help with calculating the correct prefix. There is a processing script in that post that works well for the calculation. Post is here.

    It might be of help.
     
  18. Mackwhyte

    Mackwhyte New Member

    Messages:
    14
    Hardware:
    RPi1/Zero, RPi3, +Arduino
    Thanks Akriss! At least that confirms I went wrong somewhere with my prefix! i actually had D3 in the script but like i said in post #7 i thought it was totally wrong! If TPModdings script doesn't work i'll have to go back and give that prefix another shot, maybe it didn't like the baudrate or Datapin? I've tried so many combo's now i could have easily missed one!

    Thanks again for that!
     
  19. Mackwhyte

    Mackwhyte New Member

    Messages:
    14
    Hardware:
    RPi1/Zero, RPi3, +Arduino
    Tried the new sketch today and still no luck, Runs through the Initial startup then nothing
    Also tried a couple of the prefix sketches i have with the prefix provided by Akriss and no luck either
     
  20. TPmodding

    TPmodding Administrator Staff Member Administrator

    Messages:
    918
    Hardware:
    RPi1/Zero, RPi2, RPi3, +Arduino
    thats strange...