1 2 Previous Next 25 Replies Latest reply on May 15, 2015 1:29 PM by intel_jassowski

    SparkFun Block 9 Degrees of Freedom SPI setup

    Weishan

      Did anybody try to use SPI interface for the following SparkFun block?

       

      SparkFun Block for Intel® Edison - 9 Degrees of Freedom - DEV-13033 - SparkFun Electronics

       

      I am using LSM9DS0_Simple.ino sketch. I commented out the following code,

       

      /*

      #define LSM9DS0_XM  0x1D // Would be 0x1E if SDO_XM is LOW

      #define LSM9DS0_G   0x6B // Would be 0x6A if SDO_G is LOW

      LSM9DS0 dof(MODE_I2C, LSM9DS0_G, LSM9DS0_XM);

      */

       

      And uncommented the follwoing code,

       

      #define LSM9DS0_CSG  9  // CSG connected to Arduino pin 9

      #define LSM9DS0_CSXM 10 // CSXM connected to Arduino pin 10

      LSM9DS0 dof(MODE_SPI, LSM9DS0_CSG, LSM9DS0_CSXM);

       

      It always returns 0 values. Do I need to do configuration on Edison? Any input is welcome!

        • 1. Re: SparkFun Block 9 Degrees of Freedom SPI setup
          Weishan

          I already configured IO10 to IO13 for SPI connection on Edison by following this (section 11.7),

           

          http://download.intel.com/support/edison/sb/edisonarduino_hg_331191007.pdf

           

          I did this for another SPI sensor and I have disconnected that sensor from the arduino expansion board. Not sure if this is related to the issue or not.

           

          I also noticed the code assumes CSG connected to Arduino pin 9 and CSXM connected to Arduino pin 10. I think this is because the code is for the (DOF breakout, not the block,

           

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

           

          I am using the 9DOF block. How can I make sure CSG connected to Arduino pin 9 and CSXM connected to Arduino pin 10?

           

          Thanks!

          • 2. Re: SparkFun Block 9 Degrees of Freedom SPI setup
            Intel_Peter

            Hello Weishan,

             

            As you can see in Re: Sparkfun boards help, the Arduino code for Sparkfun 9 DOF is not currently working. However in that same post you can find that there is a software that's actually working from the Linux side. Why don't you take a look at it?

             

            Peter.

            • 3. Re: SparkFun Block 9 Degrees of Freedom SPI setup
              Weishan

              Peter,

               

              Thanks for the reply!

               

              I did make arduino code work with I2C interface by editing the hardware\intel\i686\variants\edison_fab_c\variant.h file and changing

              #define LINUX_I2C_ADAPTER

              6

              to

              #define LINUX_I2C_ADAPTER1

               

              You can find the discussion here: Re: Arduino Library for SparkFun Block 9 Degrees of Freedom

               

              Now I want to try the SPI interface of the block. The arduino code seems to support both I2C and SPI, but I haven't figured out how to make SPI work.

              • 4. Re: SparkFun Block 9 Degrees of Freedom SPI setup
                intel_jassowski

                Did you modify SJ8 and SJ9 on the 9DOF board?  By default the board is hardwired to I2C.  I think you need to cut both traces and add solder blobs to connect to SPI -- in addition to the code changes.  I haven't actually tried this, but looking at the schematics, it seems like modifying the jumpers is required for SPI.

                • 5. Re: SparkFun Block 9 Degrees of Freedom SPI setup
                  Weishan

                  Jassowski,

                   

                  Thanks for the input! No, I didn't do that. I will try it after i get a hobby knife (hope that's the right tool to cut the traces). I will also ask Sparkfun support team to see if SJ8 and SJ9 are the only jumpers needs to be modified to switch between I2C and SPI.

                   

                  Thanks again for the help!

                  • 6. Re: SparkFun Block 9 Degrees of Freedom SPI setup
                    Weishan

                    Jassowski,


                    I modified SJ8 and SJ9 on the 9DOF board by cutting both traces and add solder blobs to connect to SPI. I also did code change for LSM9DS0_Simple.ino sketch. I still get all the 0 values. Anything else should I check? BTW, I sent email to sparkfun support last week but haven't got any reply yet. Any input is highly appreciated!

                     

                    G: 0.00, 0.00, 0.00

                    A: 0.00, 0.00, 0.00

                    M: 0.00, 0.00, 0.00

                    Heading: 0.00

                    Pitch, Roll: 0.00, 0.00

                    • 7. Re: SparkFun Block 9 Degrees of Freedom SPI setup
                      Weishan

                      Here is the output from setup(),

                       

                      LSM9DS0 WHO_AM_I's returned: 0x0

                      Should be 0x49D4

                      • 8. Re: SparkFun Block 9 Degrees of Freedom SPI setup
                        Weishan

                        Just got the following reply from Sparkfun (see below) and it looks like SJ8 and SJ9 are the right jumpers to modify.

                        ===========

                        Yeah, that sounds right. Just briefly looking at the silkscreen and Eagle schematic it says something about the MOSI and SCK pins. This matches what the description is talking about with the SPI connection on the 9DOF block:

                        "By default, the IMU is connected to the Edison through the I2C bus but it can be configured to use the SPI bus. "

                        Just cut the default trace with an XActo knife and add a solder blob from the center pad to the side of the SPI pads.

                        • 9. Re: SparkFun Block 9 Degrees of Freedom SPI setup
                          intel_jassowski

                          In perusing the forums, others have had problems getting SPI going at first, but there are definitely people who have had success.

                          Here's an example: Intel Edison Arduino Breakout SPI

                          where adding

                          pinMode(SS, OUTPUT);

                          after initializing the SPI library seemed to help.  But I'm guessing here, having not used SPI on Edison myself.

                           

                          • 10. Re: SparkFun Block 9 Degrees of Freedom SPI setup
                            Weishan

                            FYI - Added pinMode(SS, OUTPUT); in setup() but still getting 0 values after that

                             

                            void setup()

                            {

                              Serial.begin(115200);

                             

                              uint16_t status = dof.begin();

                             

                              pinMode(SS, OUTPUT);

                            }

                            • 11. Re: SparkFun Block 9 Degrees of Freedom SPI setup
                              Weishan

                              I realized that I configured IO10 to IO13 for SPI connection on Edison by following this (section 11.7) for another SPI sensor which I don't want to use anymore,

                               

                              http://download.intel.com/support/edison/sb/edisonarduino_hg_331191007.pdf

                               

                              Should I undo this configuration change to make the 9DOF block SPI work? If yes, any idea how to undo the change? Any input is welcome!

                               

                              11.7 Configure IO10 through IO13 for SPI connectivity

                              To configure IO10 through IO13 for SPI connectivity, do the following:

                              enter the following commands in Linux:

                              # echo 111 > /sys/class/gpio/export

                              # echo 115 > /sys/class/gpio/export

                              # echo 114 > /sys/class/gpio/export

                              # echo 109 > /sys/class/gpio/export

                              # echo 263 > /sys/class/gpio/export

                              # echo 240 > /sys/class/gpio/export

                              # echo 262 > /sys/class/gpio/export

                              # echo 241 > /sys/class/gpio/export

                              # echo 242 > /sys/class/gpio/export

                              # echo 243 > /sys/class/gpio/export

                              # echo 258 > /sys/class/gpio/export

                              # echo 259 > /sys/class/gpio/export

                              # echo 260 > /sys/class/gpio/export

                              # echo 261 > /sys/class/gpio/export

                              # echo 226 > /sys/class/gpio/export

                              # echo 227 > /sys/class/gpio/export

                              # echo 228 > /sys/class/gpio/export

                              # echo 229 > /sys/class/gpio/export

                              # echo 214 > /sys/class/gpio/export

                              # echo low > /sys/class/gpio/gpio214/direction

                              # echo high > /sys/class/gpio/gpio263/direction

                              # echo high > /sys/class/gpio/gpio240/direction

                              # echo high > /sys/class/gpio/gpio262/direction

                              # echo high > /sys/class/gpio/gpio241/direction

                              # echo high > /sys/class/gpio/gpio242/direction

                              # echo high > /sys/class/gpio/gpio243/direction

                              # echo high > /sys/class/gpio/gpio258/direction

                              # echo high > /sys/class/gpio/gpio259/direction

                              # echo low > /sys/class/gpio/gpio260/direction

                              # echo high > /sys/class/gpio/gpio261/direction

                              # echo in > /sys/class/gpio/gpio226/direction

                              # echo in > /sys/class/gpio/gpio227/direction

                              # echo in > /sys/class/gpio/gpio228/direction

                              # echo in > /sys/class/gpio/gpio229/direction

                              # echo mode1 > /sys/kernel/debug/gpio_debug/gpio111/current_pinmux

                              # echo mode1 > /sys/kernel/debug/gpio_debug/gpio115/current_pinmux

                              # echo mode1 > /sys/kernel/debug/gpio_debug/gpio114/current_pinmux

                              # echo mode1 > /sys/kernel/debug/gpio_debug/gpio109/current_pinmux

                              # echo high > /sys/class/gpio/gpio214/direction

                              • 12. Re: SparkFun Block 9 Degrees of Freedom SPI setup
                                intel_jassowski

                                Are you using the Arduino BOB or the mini BOB?  A lot of these commands are for setting up mux directions on the Arduino board which may not affect the Sparkfun signals (but some changes you make on the Arduino BOB do affect the signals going to the Sparkfun block (like, for example, you can mux I2C2 and 12C6 together).

                                 

                                That being said, since you are using Arduino code, dof.begin() is likely setting some of these for you, anyway.

                                • 13. Re: SparkFun Block 9 Degrees of Freedom SPI setup
                                  Weishan

                                  Jassowski,


                                  Thanks for the reply! I am using Arduino BOB, not the mini BOB.

                                  • 14. Re: SparkFun Block 9 Degrees of Freedom SPI setup
                                    Weishan

                                    FYI - I have reinstalled the image on Edison to make sure IO10 to 13 won’t be set for SPI, but still couldn’t make the 9DOF block work with SPI

                                    1 2 Previous Next