11 Replies Latest reply on May 8, 2015 2:48 PM by peepo

    Arduino Library for SparkFun Block 9 Degrees of Freedom

    Weishan

      All,

       

      I got the following block from SparkFun but didn't find any library for Arduino IDE.

       

      SparkFun Block for Intel® Edison - 9 Degrees of Freedom

       

      https://www.sparkfun.com/products/13033

       

      So I downloaded the arduino library for the following breakout. I compiled and uploaded LSM9DS0_Simple.ino to Edison and it read data back. The problem is the data doesn't change, always the same values. Any code change is needed? Any input is welcome, thanks a lot!

       

      SparkFun 9 Degrees of Freedom IMU Breakout - LSM9DS0

       

      SparkFun 9 Degrees of Freedom IMU Breakout - LSM9DS0 - SEN-12636 - SparkFun Electronics

        • 1. Re: Arduino Library for SparkFun Block 9 Degrees of Freedom
          CMata_Intel

          Hi Weishan ;

           

          The SFE_LSM9DS0 libraries were made for the Arduino board so you may have issues while using it in the Edison board.

          Did you have problems while compiling the code? Have you test the signals to see if the writing signals are working as expected?

           

          Regards;

          CMata

          • 2. Re: Arduino Library for SparkFun Block 9 Degrees of Freedom
            Weishan

            CMata,

             

            Thanks for the quick reply! Yes, I was able to import the library and compile the code (LSM9DS0_Simple.ino) with Arduion 1.5.3-Intel.1.0.4 without any error. It reads data back but the data never changes. It did report that the gyro and accelerometers WHO_AM_I response was incorrect. Any ideas? Thanks again!

             

             

            LSM9DS0 WHO_AM_I's returned: 0xFFFF

            Should be 0x49D4

             

            G: -123.11, -105.35, 15.34

            A: -1.00, -1.66, 0.13

            M: -1.00, -1.65, 0.13

            Heading: -31.31

            Pitch, Roll: -30.90, -58.47

             

             

            G: -123.11, -105.35, 15.34

            A: -1.00, -1.66, 0.13

            M: -1.00, -1.65, 0.13

            Heading: -31.31

            Pitch, Roll: -30.90, -58.47

            • 3. Re: Arduino Library for SparkFun Block 9 Degrees of Freedom
              intel_jassowski

              I've used the Edison 9DOF board, so I know it works fine... but I used the RTIMULIB software, not the Arduino code.

              A couple of things to keep in mind: Both boards have SPI and I2C.  By default, it appears that the Arduino code chooses I2C.

              The Edison 9DOF board does not pullup the I2C lines by default, but there are solderable jumpers to enable pullups.  You might be just missing these pullups?

              • 4. Re: Arduino Library for SparkFun Block 9 Degrees of Freedom
                Weishan

                Jassowski,

                 

                Thanks for the input! I tried both I2C and SPI by modifying the Arduino code but neither of them worked. Regarding to the solderable jumpers, are they on the 9DOF block? How can I enable the pullups? Any input is welcome! Thanks again.

                • 5. Re: Arduino Library for SparkFun Block 9 Degrees of Freedom
                  intel_jassowski

                  Yes, the resistor pullups are on the 9DOF block, labled "I2C-PUs".

                  I have been able to reproduce your results with the Arduino code (even with pullups enabled), and I'll try to get some time this weekend to grab some I2C traces to see what's going on... but it appears that the I2C communication in this code is not playing nice with Edison.

                   

                  At first, I was not able to get the WHO_AM_I strings to display, but after adding a delay(2000); after the Serial.begin() in the setup() code, the WHO_AM_I returns 0xFFFF just like yours.  Not sure why I need the 2 second delay (1 won't do).  Did you also need to add some sort of delay to get the WHO_AM_I string to print?

                   

                  There is a couple of layers of wrappers around the read/write Wire calls to handle hiding the SPI/I2C protocol differences... there might be something amiss there.

                   

                  I'm sure that the I2C is working in general with Edison, because the RTIMULIB C code has no problems accessing the IMU.

                  • 6. Re: Arduino Library for SparkFun Block 9 Degrees of Freedom
                    Weishan

                    Thank you Jassowski for looking into this!


                    No, I didn't change any of the code (BTW, I am using the LSM9DS0_Simple.ino sketch).


                    It's easy for me to comment/uncomment code to switch between I2C and SPI. But I assume I also need to change something on the block as well, right? Any instructions on how to do that? Thanks again!




                    • 7. Re: Arduino Library for SparkFun Block 9 Degrees of Freedom
                      intel_jassowski

                      I used the same sketch, and never see the WHO_AM_I string unless I delay.  Very strange.

                      The solder jumper for I2C pullups are simple to do on the block.  Look for the 3 pads labeled "I2C-PUs" on the front of the board (in the extreme +X, -Y corner).  Just lay a big solder blob over all three pads.

                      The board does seem to work without the pullups, which is strange: I've scoured the schematics for pullups somewhere else (it's not ideal to have multiple pullups on I2C lines, which is probably why the Sparkfun people leave the pullups as an option: so you can combine this board with multiple I2C boards -- only one needs to have the pullups enabled). 

                       

                      But I doubt that's what is holding you back (since I've got the pullups enabled, and it doesn't work for me -- but stranger things have happened).

                       

                      However, as I mentioned, I have compiled the RTIMULib from richards-tech/RTIMULib · GitHub

                       

                      I think the only package I had to install to get the software to compile was coreutils-dev (for the 'install' command), and to get the python modules to compile: fix the missing comma in setup.py (the error message makes it pretty obvious to find).

                       

                      It has a utility to calibrate the sensors and store that data in an .ini file, then a pretty simple python script to fuse the data into Roll/Pitch/Yaw angles.

                       

                      # python Fusion.py

                      Using settings file RTIMULib.ini

                      IMU Name: LSM9DS0

                      IMU Init Succeeded

                      Recommended Poll Interval: 4mS

                       

                       

                      r: -16.263141 p: -49.627574 y: 38.002028

                      r: -17.442111 p: -49.199902 y: 37.463721

                      r: -19.262479 p: -48.264914 y: 36.819863

                      r: -21.112974 p: -47.252826 y: 36.370969

                      r: -22.764529 p: -46.242942 y: 36.121916

                      r: -24.250739 p: -45.250386 y: 35.918073

                      r: -25.183196 p: -44.687896 y: 36.184730

                      r: -25.958323 p: -43.998798 y: 36.364726

                      r: -26.273096 p: -43.441069 y: 36.876912

                      r: -25.873042 p: -43.039160 y: 37.009588

                      r: -25.107169 p: -42.442393 y: 35.565796

                      r: -23.607883 p: -42.539371 y: 33.768394

                      r: -21.266438 p: -43.111423 y: 31.719846

                      r: -18.306550 p: -43.852758 y: 29.261879

                      r: -14.622373 p: -44.945442 y: 26.365229

                      r: -9.935647 p: -46.165269 y: 22.393945

                      r: -4.165922 p: -47.305474 y: 16.945192

                      r: 3.530674 p: -48.664384 y: 9.806714

                      r: 12.738584 p: -49.456338 y: 1.274081

                      r: 23.139434 p: -49.614200 y: -8.259667

                      r: 34.147391 p: -48.817554 y: -17.951257

                      r: 44.763038 p: -47.230324 y: -27.007552

                      r: 56.055509 p: -44.297803 y: -35.664994

                      r: 65.808374 p: -40.494836 y: -42.800240

                      r: 75.264368 p: -34.436513 y: -48.910189

                      • 8. Re: Arduino Library for SparkFun Block 9 Degrees of Freedom
                        Weishan

                        Jassowski,


                        Thanks again for the replies! I think I pressed the reset button on the Edison board to get the WHO_AM_I information, otherwise I won't see it either without a delay.


                        My project involves multiple sensors to be attached to the Edison. Most of them are working with sketch examples I found online. So I'd rather make this sensor work with sketch code as well. I will see Sparkfun support team has any working sketch for this sensor.


                         


                        • 9. Re: Arduino Library for SparkFun Block 9 Degrees of Freedom
                          intel_jassowski

                          OK... So I think I'm getting closer to understanding why Arduino code doesn't work for the 9DOF Sparkfun block.  According to https://communities.intel.com/message/253536,

                          the Arduino expander board is hard-coded to I2C6, while the Sparkfun board in on I2C1.

                          However, both I2C6 and I2C1 are present on the breakout board.  I did discover a way to make the Arduino IDE use I2C1 here:Re: I2C controllers

                          Just edit the hardware\intel\i686\variants\edison_fab_c\variant.h file and change

                          #define LINUX_I2C_ADAPTER

                          6

                          to

                          #define LINUX_I2C_ADAPTER1

                           

                          I now get changes to the values displayed when I move the 9DOF board around:

                          G: 79.28, 16.57, 5.62

                          A: -0.38, -0.62, -0.71

                          M: -0.05, 0.24, 0.12

                          Heading: 101.34

                          Pitch, Roll: -18.65, -35.03

                           

                           

                          G: 42.51, 21.59, 6.03

                          A: -0.55, -0.78, 0.05

                          M: 0.05, 0.13, 0.32

                          Heading: 69.17

                          Pitch, Roll: -35.39, -54.38

                           

                           

                          G: -132.87, -2.74, -82.21

                          A: 0.09, -0.78, -0.71

                          M: -0.13, 0.24, 0.07

                          Heading: 117.79

                          Pitch, Roll: 4.11, -52.84

                           

                           

                          G: 38.86, -47.63, 17.18

                          A: 0.17, 0.36, -1.04

                          M: -0.18, 0.01, -0.13

                          Heading: 176.83

                          Pitch, Roll: 6.77, 16.28

                          • 10. Re: Arduino Library for SparkFun Block 9 Degrees of Freedom
                            Weishan

                            Jassowski,


                            It works! Thanks a lot for the big help! Will send you a kudo


                            Weishan

                            • 11. Re: Arduino Library for SparkFun Block 9 Degrees of Freedom
                              peepo

                              well as I've been waiting around 4 months for sparkfun to release beta code, I may take this up...

                               

                              no one points to an example using OLED block display...

                               

                              you have to laugh..

                               

                              ~:"