Community
cancel
Showing results for 
Search instead for 
Did you mean: 
SChri11
Beginner
1,028 Views

Arduino library for SparkFun 9DOF Block with edison

Hello,

I had a question regarding using the arduino library for sparkfun 9dof block with edison. This is the library I am using: https://github.com/sparkfun/SparkFun_LSM9DS0_Arduino_Library https://github.com/sparkfun/SparkFun_LSM9DS0_Arduino_Library

I am using Arduino 1.6 and followed and changed the LINUX_I2C_ADAPTER value. I am able to get the sensor values printed when I run the Sparkfun_LSM9DS0_Simple.ino example.

I am now trying to get the sensor values only when new values are available by using the 3 interrupts (INT1XM, INT2XM and DRDYG). I changed the pins to the following:

const byte INT1XM = 48; // INT1XM tells us when accel data is ready

const byte INT2XM = 49; // INT2XM tells us when mag data is ready

const byte DRDYG = 47; // DRDYG tells us when gyro data is ready

But the interrupts are not working properly. When I print the interrupt values, I am getting -1. I did not solder anything on the 9dof block board itself. Should I solder anything?

Can someone tell me what I might be doing wrong?

I have pasted my code below:

# include // Included for SFE_LSM9DS0 library

# include

# include

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

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

// Create an instance of the LSM9DS0 library called `dof` the

// parameters for this constructor are:

// [SPI or I2C Mode declaration],[gyro I2C address],[xm I2C add.]

LSM9DS0 dof(MODE_I2C, LSM9DS0_G, LSM9DS0_XM);

# define INT1XM 48

# define INT2XM 49

# define DRDYG 47

void setup()

{

Serial.begin(115200);

pinMode(INT1XM, INPUT);

pinMode(INT2XM, INPUT);

pinMode(DRDYG, INPUT);

uint16_t status = dof.begin(dof.G_SCALE_245DPS,dof.A_SCALE_2G, dof.M_SCALE_2GS,dof.G_ODR_95_BW_125,dof.A_ODR_100,dof.M_ODR_3125);

Serial.print("LSM9DS0 WHO_AM_I's returned: 0x");

Serial.println(status, HEX);

Serial.println("Should be 0x49D4");

delay(2000);

Serial.println("done");

}

void loop()

{

Serial.print("Magnetometer INT2XM: ");

Serial.println(digitalRead(INT2XM));

Serial.print("Accel INT1XM: ");

Serial.println(digitalRead(INT1XM));

Serial.print("Gyro DRDYG: ");

Serial.println(digitalRead(DRDYG));

}

Output:

LSM9DS0 WHO_AM_I's returned: 0x49D4

Should be 0x49D4

done

Magnetometer INT2XM: -1

Accel INT1XM: -1

Gyro DRDYG: -1

Magnetometer INT2XM: -1

Accel INT1XM: -1

Gyro DRDYG: -1

Magnetometer INT2XM: -1

Accel INT1XM: -1

Gyro DRDYG: -1

Magnetometer INT2XM: -1

Accel INT1XM: -1

Gyro DRDYG: -1

Any help is greatly appreciated!

Thanks!

0 Kudos
9 Replies
idata
Community Manager
74 Views

Hi C2,

 

 

Thanks for your interest in the Intel® Edison platform.

 

 

I would like to know if you are using the mini-breakout board or the Arduino expansion board. In case you are using the mini-breakout board, you must map the pins from the mini-breakout board to the Arduino module.

 

 

For example, if you want to use the Linux pin 48 in your Arduino sketch you should use "INT1XM = 7". According to the http://download.intel.com/support/edison/sb/edisonarduino_hg_331191007.pdf Intel® Edison Arduino Board Hardware Guide, table 2, the first column is the Arduino shield pin and the second one is the Linux pin, so the GP48 pin is the Arduino pin number 7, additionally, looking at the /Intel® Edison Arduino Board Hardware Guide Intel® Edison breakout Board Hardware Guide, table 2, the Linux pin 48 is the J19 – pin 6 on the mini-breakout board, so as a summary you should wired from the INT1XM pin to J19 – pin 6 and used INT1XM = 7 in your Arduino sketch.

 

 

Also, make sure that all the connections are properly done since there may be a faulty contact.

 

 

Hope this information helps.

 

 

Regards,

 

-Yermi A.

 

SChri11
Beginner
74 Views

Hello,

Thanks for your reply. But I am using the sparkfun base board (https://www.sparkfun.com/products/13045 SparkFun Block for Intel® Edison - Base - DEV-13045 - SparkFun Electronics ) and sparkfun 9DOF(https://www.sparkfun.com/products/13033 SparkFun Block for Intel® Edison - 9 Degrees of Freedom - DEV-13033 - SparkFun Electronics ). How do I know which pins to use in this case? Should I solder something on the back of the 9DOF board?

Thanks!

idata
Community Manager
74 Views

Thanks for clarifying that. According to this tutorial https://learn.sparkfun.com/tutorials/sparkfun-blocks-for-intel-edison---9-degrees-of-freedom-block- SparkFun Blocks for Intel® Edison - 9 Degrees of Freedom Block, if you close the jumpers "A (INT2)", "B (INT1)", and "C (DRDYG)" with a solder blob, you will connect theses pins to the corresponding Edison's GPIO. So you should solder those jumpers to have a connection between those interrupt pins on the LSM9S0 and the GPIOs on the Edison.

 

 

Regards,

 

-Yermi A.

 

SChri11
Beginner
74 Views

Thanks. Yes. I had seen that and tried to connect the 2 ends of the jumpers without actually soldering them. But it was not working. I went ahead and soldered the 3 jumpers with solder blob now, but there is no change in the output. I am still getting -1.

I have been trying to get this to work for sometime now. Have anyone had any success?

Any help is appreciated.

Thanks!

idata
Community Manager
74 Views

Unfortunately, I don't have that Sparkfun block to test it and try to replicate the issue. However, I'd suggest to try the SparkFun_LSM9DS0_SerialMenus.ino example code to know if you get the same results as shown here: https://learn.sparkfun.com/tutorials/lsm9ds0-hookup-guide LSM9DS0 Hookup Guide, also be sure to select the correct Arduino pin number.

 

 

Regards,

 

-Yermi A.

 

idata
Community Manager
74 Views

Hi C2,

 

 

Did you try the SparkFun_LSM9DS0_SerialMenus.ino example? Do you have any updates?

 

 

Regards,

 

-Yermi A.

 

SChri11
Beginner
74 Views

That one does not use interrupts. My problem is with interrupts only. Without interrupts, the code is working. How do I find the arduino pins when am using sparkfun board?

Thanks!

idata
Community Manager
74 Views

The SparkFun_LSM9DS0_SerialMenus.ino example demos how to use the interrupts, the LSM9DS0_Simple example does not, so you may try that example to know if you get the same results.

 

 

Regarding the Arduino pins, the INT2, INT1, and DRDYG on the SparkFun block connect to GPIO 49, 48, and 47 on the Edison respectively, and according to the table 2 of the http://download.intel.com/support/edison/sb/edisonarduino_hg_331191007.pdf Intel® Edison Kit for Arduino* Hardware Guide, the Arduino pins should be:
  • GPIO 49 = IO8
  • GPIO 48 = IO7
  • GPIO 47 = IO17

 

So you can change your code to:

 

const byte INT1XM = 7; // INT1XM tells us when accel data is ready

 

const byte INT2XM = 8; // INT2XM tells us when mag data is ready

 

const byte DRDYG = 17; // DRDYG tells us when gyro data is ready

 

Hope this information helps.

 

 

Regards,

 

-Yermi A.
SChri11
Beginner
74 Views

Thanks! Its working now.

PS: SparkFun_LSM9DS0_SerialMenus.ino example is the one I started with. But when I checked the timestamps I realised something was wrong. The code does the following:

if (digitalRead(INT1XM))

{}

And the code inside if gets executed even if INT1XM returns -1. When I changed the code to below, it stopped working.

if (digitalRead(INT1XM)==1)

{}

That's when I just printed the output of digitalRead and realised I was getting -1.

I changed the pins to following and the digitalRead is returning 1 now.

  1. const byte INT1XM = 7; // INT1XM tells us when accel data is ready
  2. const byte INT2XM = 8; // INT2XM tells us when mag data is ready
  3. const byte DRDYG = 17; // DRDYG tells us when gyro data is ready

I did not realize I need to use the arduino pins since I was not using the arduino board.

Thanks a lot!

Reply