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

BUG SPI first LED is green

Discussion in 'Bug Reports' started by peter, 23 January 2017.

  1. penfold42

    penfold42 Active Member

    Messages:
    746
    Hardware:
    RPi1/Zero, RPi2, RPi3, 32/64bit, +Arduino, +nodeMCU/ESP8266
    Change:
    uint8_t tx[num_leds*3*4+3];
    To:
    uint8_t tx[num_leds*3*4+6];

    DONT change:
    unsigned spi_ptr=0;
     
  2. peter

    peter Member

    Messages:
    108
    Hardware:
    RPi1/Zero, RPi2, RPi3
    uint8_t tx[num_leds*3*4+6];
    unsigned spi_ptr=0;
    so I tried it but these values have green channel on 1st LED on.
     
  3. penfold42

    penfold42 Active Member

    Messages:
    746
    Hardware:
    RPi1/Zero, RPi2, RPi3, 32/64bit, +Arduino, +nodeMCU/ESP8266
    Thanks - that rules out one theory.

    can you tell us more about the level shifter ? Do you have a schematic/circuit diagram?

    A couple of photos would be helpful.
     
  4. peter

    peter Member

    Messages:
    108
    Hardware:
    RPi1/Zero, RPi2, RPi3
    it should be this diagram [​IMG]

    I found out with and without level shifter effect is the same (on OPi as well as on RPi).
     
    Last edited: 31 January 2017
  5. penfold42

    penfold42 Active Member

    Messages:
    746
    Hardware:
    RPi1/Zero, RPi2, RPi3, 32/64bit, +Arduino, +nodeMCU/ESP8266
    So the level shifter doesn't seem to make any difference ?

    I've had bad experience with those mosfet level shifters with the ws2812 leds and have given up on them.

    The last 3 I made I've used 74HCT series chips and they've been flawless.

    Just about any 74HCTxx chip can be used if you wire it correctly.
     
  6. peter

    peter Member

    Messages:
    108
    Hardware:
    RPi1/Zero, RPi2, RPi3
    I have 74HCT somewhere. I search for it and try it with 74HCT. Then I post back.
     
  7. penfold42

    penfold42 Active Member

    Messages:
    746
    Hardware:
    RPi1/Zero, RPi2, RPi3, 32/64bit, +Arduino, +nodeMCU/ESP8266
    Cool - let me know if you need any help with the parts you have on hand.

    74HC won't work due to the input levels being cmos.
    74LS is probably too slow
    74HCT is juuuuust right
     
  8. peter

    peter Member

    Messages:
    108
    Hardware:
    RPi1/Zero, RPi2, RPi3
    so I used 74HCT and this https://hyperion-project.org/wiki/Supported-hardware wiring scheme. I connected just mosi line (not clk) but result is the same.

    P.S. No Idea why all LEDs flashing crazy when I turn on power source (even when Pi is booting). So I wait for a while until it stopped and then I tried all scenarios with +6,+3,0,3. Only scenario with +6 and 3 worked (as mentioned above). So I don't think it is a question of level shifter.

    btw, can be used these values (uint8_t tx[num_leds*3*4+6]; unsigned spi_ptr=3) for a long time period without problems?
     
    Last edited: 1 February 2017
  9. penfold42

    penfold42 Active Member

    Messages:
    746
    Hardware:
    RPi1/Zero, RPi2, RPi3, 32/64bit, +Arduino, +nodeMCU/ESP8266
    Damn !

    So you have a separate 5v PSU for the leds ?

    A good ground connection between
    - the Pi,
    - the 74hct00
    - The led strip
    - The led power supply

    Is the 74hct00 powered by the pi or the led power supply ?

    Can you tell I'm running out of ideas ?

    I'm beginning to wonder if the 1st led is faulty ?

    I wish I could drop by with oscilloscope and see what's happening on the pins !
     
    • Like Like x 1
  10. peter

    peter Member

    Messages:
    108
    Hardware:
    RPi1/Zero, RPi2, RPi3
    So you have a separate 5v PSU for the leds ? I tried both cases with separate PSU and with one common PSU. (changed nothing)

    A good ground connection between - yes, I rechecked and added two additional wires for ground to cover it twice. (changed nothing)

    Is the 74hct00 powered by the pi or the led power supply ? I tried both ways. (changed nothing)

    I'm beginning to wonder if the 1st led is faulty ? I have more strips and tried with each. (changed nothing) So I think first LED is not faulty.

    I really appreciate your huge effort to help. Thanks again mate!


    P.S. on RPi first led is off - this is interesting, too. So maybe a software issue (?). Btw when uint8_t tx[num_leds*3*4+6]; and unsigned spi_ptr=3 work together, can I use change it somewhere in hyperion files and recompile it with these values? (and can they be used for normal long using of hyperion?)
     
  11. penfold42

    penfold42 Active Member

    Messages:
    746
    Hardware:
    RPi1/Zero, RPi2, RPi3, 32/64bit, +Arduino, +nodeMCU/ESP8266
    I can add it easily.

    Do you want me to patch the classic original Hyperion or do you want to try the fantastic new Hyperion.ng ?
     
  12. peter

    peter Member

    Messages:
    108
    Hardware:
    RPi1/Zero, RPi2, RPi3
    I think have it in both (classic original and fantastic new ng) would be great. But I don't want to bother you, so if you just tell me which file to edit in original version, I do it in my downloaded original version by myself.
    thanks many times again
     
  13. penfold42

    penfold42 Active Member

    Messages:
    746
    Hardware:
    RPi1/Zero, RPi2, RPi3, 32/64bit, +Arduino, +nodeMCU/ESP8266
    Assuming you've cloned the hyperion
    hyperion/libsrc/leddevice/LedDeviceWs2812SPI.cpp

    Line 37: unsigned spi_size = mLedCount * SPI_BYTES_PER_LED + 3;
    Change 3 to 6
    Line 42: unsigned spi_ptr = 0;
    Change 0 to 3

    Thats it .... you'll notice the code is very similar!

    I do have another theory tho..... maybe your leds arent actually ws2812 but one of the many clones around.
    The timing I have for the reset pulse is actually waaaay out of spec, but has worked find for ws2812 and sk6812 leds.
    The alternate fix for this to simply extend the reset pulse is:
    Line 37: unsigned spi_size = mLedCount * SPI_BYTES_PER_LED + 3;
    Change 3 to 80 (yes.... eighty)
     
  14. gebn

    gebn New Member

    Messages:
    26
    Hardware:
    RPi3, +Arduino
    same issue here with anything ive tried, than its an OPI issue,
    @peter what OPI do you have?, mines an Orange Pi Plus v1.1 on Armbian 5.25 Server
    ill be trying this code edit out on the shiny new hyperion-ng and will report back!

    Edit : code is fairly different, not exactly into C++ so much; which one should i modify?
    Code:
    unsigned spi_ptr = 3;
        const int SPI_BYTES_PER_LED = sizeof(ColorRgb) * SPI_BYTES_PER_COLOUR;
    
        for (const ColorRgb& color : ledValues)
        {
            uint32_t colorBits = ((unsigned int)color.red << 16)
                | ((unsigned int)color.green << 8)
                | color.blue;
    
            for (int j=SPI_BYTES_PER_LED - 1; j>=0; j--)
            {
                _ledBuffer[spi_ptr+j] = bitpair_to_byte[ colorBits & 0x3 ];
                colorBits >>= 2;
            }
            spi_ptr += SPI_BYTES_PER_LED;
        }
    
    in the meantime ill try compiling without edits

    Edit 2: Compiling Hyperion-ng, had to modify CMakeLists.txt because it was detecting the OPI as a Raspberry Pi due that the CPU check is not by model but by architecture.
    Modified Lines 73 to 75
    Code:
    elseif ( "${PLATFORM}" STREQUAL "rpi" )
        SET ( DEFAULT_DISPMANX   OFF )
        SET ( DEFAULT_WS281XPWM  OFF )
    Edit 3 4:
    Compile Failed(?) with
    -- Found PythonLibs: /usr/lib/arm-linux-gnueabihf/libpython2.7.so (found version "2.7.9")

    CMake Warning at doc/CMakeLists.txt:31 (message):
    Doxygen not found, unable to generate documenation!

    -- Configuring done

    CMake Warning (dev) at libsrc/hyperion/CMakeLists.txt:48 (add_library):
    Policy CMP0028 is not set: Double colon in target name means ALIAS or
    IMPORTED target. Run "cmake --help-policy CMP0028" for policy details.
    Use the cmake_policy command to set the policy and suppress this warning.
    Target "hyperion" links to target "Qt5::SerialPort" but the target was not
    found. Perhaps a find_package() call is missing for an IMPORTED target, or
    an ALIAS target is missing?

    This warning is for project developers. Use -Wno-dev to suppress it.
    << The red text changes with jsonserver, protoserver, bonjour, boblightserver, etc., . No compiling actually happens, i ahve also tried to >>
    Then i get 3 of these
    CMake Warning (dev) in src/hyperion-remote/CMakeLists.txt: Policy CMP0043 is not set: Ignore COMPILE_DEFINITIONS_<Config> properties. Run "cmake --help-policy CMP0043" for policy details. Use the cmake_policy command to set the policy and suppress this warning.

    -- Generating done
    -- Build files have been written to: /home/orangepi/hyperion/build

    I didnt want to run cmake_policy because i didnt want to suppress warnings and still remain without a compile. Have tried sudo apt-get install qtbase5-dev libqt5serialport5-dev
    Not so experienced to fix this though....

    compiling right now

    Edit 5 : Compile done, will test in about an hour
     
    Last edited: 24 February 2017
  15. penfold42

    penfold42 Active Member

    Messages:
    746
    Hardware:
    RPi1/Zero, RPi2, RPi3, 32/64bit, +Arduino, +nodeMCU/ESP8266
    const int SPI_FRAME_END_LATCH_BYTES = 3;
     
    • Thank you Thank you x 1
  16. peter

    peter Member

    Messages:
    108
    Hardware:
    RPi1/Zero, RPi2, RPi3
     
  17. gebn

    gebn New Member

    Messages:
    26
    Hardware:
    RPi3, +Arduino
    Edit: changed video links to webm

    sorry to rewake an old thread but i didnt want to start another one

    so i tried connecting everything with the SPI with a 74HCT125, ive tried doing the edits on the orangepi and did not have a green led, then i upgraded the orangepi to a devport kernel 4.10 due that video0 was not found on the old 3.4.113 kernel
    now i have some glitches, which i suppose are either from timing, the first led gone bust or i have a clone of the ws2812b
    I have tried editing /libsrc/LedDevices/LedDeviceWS2812SPI.cpp variable SPI_FRAME_END_LATCH_BYTES with 6 and 80 and unsigned_ptr to 3. In all cases i fixed the first green led, but not this (webmshare).

    With the Raspberry Pi 3 and no edits to the , i get something completely different. it works except for this random white flashing, on Dispmanx Grabber , it stays white longer , maybes because theres more white on the first few leds due to the top bar in linux desktop (?)

    So close to fix but i always seem to find something in the way

    Compiled Hyperion-ng as at 10th March

    Currently 43 LEDs Connected like this
    MOSI > 74HCT125 A PIN -///////////- 74HCT125 Y PIN > 470ohm Resistor > DataIN Strip
    SPI0_CS > 74HCT125 OE PIN^

    Ground between Pi, Powersupply, 74HCT, LED Strip
    Capacitor inline with LEDs VCC+ and VDD-
    Also tested connecting OE to Ground, Same Issues
    Also Tested Bypassing Resistor, same issue on Raspberry Pi, untested on OrangePi

    GRB byte order, baudrate left default at 3000000
     
    Last edited: 12 March 2017