9 Replies Latest reply on May 16, 2015 9:26 AM by MWROTHBE

    Edison\Breakout SPI LPD8806 problem

    MWROTHBE

      Hi.

       

      I'm struggling a bit driving a LPD8806 LED strip with an Edison w/ breakout board and I'm curious if anyone else had been successful and if there are some tips.  I'm using Eclipse\C and there is a LPD8806 library in UPM and I've been able to compile and publish it to the Edison with no errors, but nothing happens on the LED strip.  Console messages reporting the state of each step in the SPI initialization process seem to be OK.  I have J17 pin12 (TX) connected to DI on the strip and J17 pin11 (SClk) connected to clk.  Edison and strip share a common ground.  I've tried a voltage level converter to 3.3v and 5v on the Sclk and TX lines with no results.  The strip does not use a CS signal so that is left unconnected.  I've written code for a FTDI cable attached to a PC which drives the strip just fine, so I'm sure the LED strip is good.

       

      I'm using MRAA v0.6.2.  In attempts to troubleshoot I've created a new project from scratch and shorted MOSI and MISO pins to see what is being sent.  I found that when running mraa_spi_write_buf with a uint8_t*, the first word received is always different than what was sent to the function with the remaining words received as expected.  I'm thinking that might be my issue.  Any thoughts or ideas?

       

      Thanks!

        • 1. Re: Edison\Breakout SPI LPD8806 problem
          CMata_Intel

          Hi MWROTHBE

           

          Your configuration seems to be fine. Could you post the test-code you are using to replicate your issue with SPI-MOSI-MISO-MRAA. I'm assuming you are using the latest image, right? (Run configure_edison --version, you should get 120 as result)

          About your last test. If you write something repeatedly, are you getting the same result always? or are you always receiving different data?

          There are some threads related to the lpd8806:

          Re: SPI Pins on Mini Breakout

          Chip Select

           

          Regards;

          CMata

          • 2. Re: Edison\Breakout SPI LPD8806 problem
            MWROTHBE

            Thanks for the fast reply CMata!

             

            I had seen those links already.  Running the command line you mention I do appear to be on 120.

             

            Here is the code:

             

            #include <unistd.h>
            #include <iostream>
            #include <signal.h>
            #include "mraa.h"
            #include <stdint.h>
            #include <cstring>
            int
            main(int argc, char** argv)
            {
             uint16_t meters = 5;
             uint16_t pixelCount = meters * 32;
             mraa_init();
             printf("MRAA Version: %s\n\n", mraa_get_version() );
                mraa_spi_context SPI;
                SPI = mraa_spi_init(0);
                if (SPI == NULL) {
                    printf("Initialization of spi failed, check syslog for details, exit...\n");
                }
                mraa_spi_frequency(SPI, 1000000);
                mraa_spi_lsbmode(SPI,false);
             mraa_spi_mode(SPI, MRAA_SPI_MODE0);
             usleep(1000);
             uint8_t* recv;
             uint8_t zeros[3 * meters];
             for (uint8_t i = (3 * meters); i > 0; i--) {
               zeros[i] = 0;
               printf("ZerosOut-0x%02x\n", zeros[i]);
              }
             recv = mraa_spi_write_buf(SPI,zeros,3 * meters);
             for(int i=0; i < (5 * meters); i++) {
              printf("ZerosIn-0x%02x\n", recv[i]);
             }
             //uint8_t data[3 * pixelCount];
             uint8_t data[3 * meters];
             for (uint8_t i = (3 * meters); i > 0; i--) {
              data[i] = 128;
              printf("DataOut-0x%02x\n", data[i]);
             }
            

            ...

             

            And here are the results.  Note that the first word in the In are corrupt.  ...I just now noticed that the Zeros array is too long.  Not sure what is up with that.

             

             

            MRAA Version: v0.6.2

             

             

             

            ZerosOut-0x00

             

            ZerosOut-0x00

             

            ZerosOut-0x00

             

            ZerosOut-0x00

             

            ZerosOut-0x00

             

            ZerosOut-0x00

             

            ZerosOut-0x00

             

            ZerosOut-0x00

             

            ZerosOut-0x00

             

            ZerosOut-0x00

             

            ZerosOut-0x00

             

            ZerosOut-0x00

             

            ZerosOut-0x00

             

            ZerosOut-0x00

             

            ZerosOut-0x00

             

            ZerosIn-0xeb

             

            ZerosIn-0x00

             

            ZerosIn-0x00

             

            ZerosIn-0x00

             

            ZerosIn-0x00

             

            ZerosIn-0x00

             

            ZerosIn-0x00

             

            ZerosIn-0x00

             

            ZerosIn-0x00

             

            ZerosIn-0x00

             

            ZerosIn-0x00

             

            ZerosIn-0x00

             

            ZerosIn-0x00

             

            ZerosIn-0x00

             

            ZerosIn-0x00

             

            ZerosIn-0x00

             

            ZerosIn-0x00

             

            ZerosIn-0x00

             

            ZerosIn-0x00

             

            ZerosIn-0x00

             

            ZerosIn-0xb9

             

            ZerosIn-0x00

             

            ZerosIn-0x00

             

            ZerosIn-0x00

             

            ZerosIn-0x30

             

            DataOut-0x80

             

            DataOut-0x80

             

            DataOut-0x80

             

            DataOut-0x80

             

            DataOut-0x80

             

            DataOut-0x80

             

            DataOut-0x80

             

            DataOut-0x80

             

            DataOut-0x80

             

            DataOut-0x80

             

            DataOut-0x80

             

            DataOut-0x80

             

            DataOut-0x80

             

            DataOut-0x80

             

            DataOut-0x80

             

            DataIn-0xc4

             

            DataIn-0x80

             

            DataIn-0x80

             

            DataIn-0x80

             

            DataIn-0x80

             

            DataIn-0x80

             

            DataIn-0x80

             

            DataIn-0x80

             

            DataIn-0x80

             

            DataIn-0x80

             

            DataIn-0x80

             

            DataIn-0x80

             

            DataIn-0x80

             

            DataIn-0x80

             

            DataIn-0x80

             

            DataIn-0x80

            • 3. Re: Edison\Breakout SPI LPD8806 problem
              MWROTHBE

              Changed the '5' to '3' in line 30.  Now the ZeroIn count matches.  First word is always corrupt.

               

               

              MRAA Version: v0.6.2

               

               

               

              ZerosOut-0x00

               

              ZerosOut-0x00

               

              ZerosOut-0x00

               

              ZerosOut-0x00

               

              ZerosOut-0x00

               

              ZerosOut-0x00

               

              ZerosOut-0x00

               

              ZerosOut-0x00

               

              ZerosOut-0x00

               

              ZerosOut-0x00

               

              ZerosOut-0x00

               

              ZerosOut-0x00

               

              ZerosOut-0x00

               

              ZerosOut-0x00

               

              ZerosOut-0x00

               

              ZerosIn-0xeb

               

              ZerosIn-0x00

               

              ZerosIn-0x00

               

              ZerosIn-0x00

               

              ZerosIn-0x00

               

              ZerosIn-0x00

               

              ZerosIn-0x00

               

              ZerosIn-0x00

               

              ZerosIn-0x00

               

              ZerosIn-0x00

               

              ZerosIn-0x00

               

              ZerosIn-0x00

               

              ZerosIn-0x00

               

              ZerosIn-0x00

               

              ZerosIn-0x00

               

              DataOut-0x80

               

              DataOut-0x80

               

              DataOut-0x80

               

              DataOut-0x80

               

              DataOut-0x80

               

              DataOut-0x80

               

              DataOut-0x80

               

              DataOut-0x80

               

              DataOut-0x80

               

              DataOut-0x80

               

              DataOut-0x80

               

              DataOut-0x80

               

              DataOut-0x80

               

              DataOut-0x80

               

              DataOut-0x80

               

              DataIn-0xc4

               

              DataIn-0x80

               

              DataIn-0x80

               

              DataIn-0x80

               

              DataIn-0x80

               

              DataIn-0x80

               

              DataIn-0x80

               

              DataIn-0x80

               

              DataIn-0x80

               

              DataIn-0x80

               

              DataIn-0x80

               

              DataIn-0x80

               

              DataIn-0x80

               

              DataIn-0x80

               

              DataIn-0x80

               

              DataIn-0x80

               

              Initial reset: done

              • 4. Re: Edison\Breakout SPI LPD8806 problem
                CMata_Intel

                Hi MWROTHBE

                 

                I will try this but I just found this so take a look at it you may find it useful. Intro to LED Strips

                 

                Regards.

                CMata

                • 5. Re: Edison\Breakout SPI LPD8806 problem
                  MWROTHBE

                  Thanks!

                   

                  That's a nice link for those getting started.  My take way from it is:

                  1) Someone has gotten a LPD8806 strip to work on Edison.  So that's good to know.  Only difference I can see is the link is using an ino file of some sort (I don't actually see the LPD8806 code posted,) so I wonder if my problem is mraa related.

                  2) They show a direct connection between the Edison arduino outputs and the strip, so I take it a voltage converter is not needed if that actually worked.  I read another post that was pondering if the 1.8V output of the breakout board may not be enough to drive the strip.  The link seems to be saying that it's not needed via the connection diagrams (assuming the Edison arduino outputs the same voltage levels as the breakout.)

                   

                  I'd appreciate investigating the first word response problem I posted above.  I don't know if it's the cause of my problems (it could be a problem with the read buffer as opposed to the transmit function for instance) but it's the only indication I have that something is not right and may be related to my problem.

                   

                  Thanks,

                  Mike

                  • 6. Re: Edison\Breakout SPI LPD8806 problem
                    CMata_Intel

                    Hi MWROTHBE

                     

                    Did you try to run the .ino files to test this?

                    http://www.instructables.com/files/orig/F04/A6QX/I85QP8S9/F04A6QXI85QP8S9.ino

                    http://www.instructables.com/files/orig/F65/FO03/I85QP8SC/F65FO03I85QP8SC.ino

                     

                    In the link it is used the Arduino Expansion board so that is the reason of why the voltage converter is not needed.

                    In the examples the SPI interface it's not being used, the examples use the analogWrite function. Take a look at it maybe this alternative could work for you too.

                     

                    Regards;

                    CMata

                    • 7. Re: Edison\Breakout SPI LPD8806 problem
                      MWROTHBE

                      Hi.  Yes, I did look at those.  Those example are for the other LED examples on that page and use digital out and PWM.  Not SPI required by the LPD8806.

                       

                      Have you had a chance to try the above code with MISO\MOSI shorted?  Any other thoughts?

                       

                      Thanks!

                      • 8. Re: Edison\Breakout SPI LPD8806 problem
                        CMata_Intel

                        Hi MWROTHBE

                         

                        I've already tested the code. I'm using a mini-breakout board with MRAA 0.6.2 version. When I ran the code in the Edison the output was the same as yours. So I tested the pins using a Logic Analyzer and I saw that actually the pins(MOSI-MISO) were receiving the same thing always, it's supposed to be like this but I wanted to be sure that there is nothing else could be affecting the signals

                        Take a look of what I received in the Logic Analyzer.

                        SPItests.JPG

                        Take a look at this code, mraa/spi_mcp4261.c at master · intel-iot-devkit/mraa · GitHub I ran it and were able to receive in the output the same thing that I was writing.

                         

                        Regards;

                        CMata

                        • 9. Re: Edison\Breakout SPI LPD8806 problem
                          MWROTHBE

                          Thank you CMata!

                           

                          I'm sorry to say that I think I've wasted your time.  The "first word corruption" that I was seeing was a dumb programing error on my part.  I was assigning the byte array values starting at position 1 instead of 0, so the first word was undefined in the array.  With a code change I now see exactly what I'm sending.

                           

                          The strip still isn't working, but when I crank the spi freq all the way down to 1000, I can get random activity on the first 10 or so LED clusters with the level converter (BOB-11978 from Sparkfun) and no response at all w/o the converter.  I'm now thinking the converter isn't providing a clean amplified signal.

                           

                          I'll continue to work on this, but all indications I have is that the Edison is doing what it is meant to, so I'll mark this thread as answered.  Thanks for your help!