SPI Reads of the MPU6000

I'm playing around with writing my own app using the APM2.0 hardware and the associated libraries that come with the ArduPlane open-source code.  Basically I'm replacing the setup() and loop() with my own stuff and trying to do just some really simple sensor reads.

I've been able to read the RC receiver just fine so far.

Next up is the MPU6000 IMU.  I think I've done everything correctly (following along with the ArduPlane code and what it does) but I'm getting a value of -1 for every SPI read from the MPU6000.

I realize this is a nebulous question/problem, but I'm hoping someone can suggestion something to look at or check or try?

I've inserted some Serial.print()'s inside AP_InertialSensor_MPU6000.cpp in places like init() hardware_init() and read().

I can see that the AP_InertialSensor_MPU6000::read() routine is correctly scheduled and being called repeatedly, but when I dump the value of the _sum[] array inside this routine I see that every read is returning a -1 with no variation in the data.

I've called SPI.begin() and SPI.setClockDivider(SPI_CLOCK_DIV16); // 1MHZ SPI rate as per the ArduPlane code.

I've called imu.init(IMU::COLD_START, delay, flash_leds, &timer_scheduler); which triggers the MPU6000 hardware_init() routine and attempts to calibrate the gyros (but with all values of -1).

I have: #  define CONFIG_MPU6000_CHIP_SELECT_PIN 53

I can say that when I pulled this unit out of the box and plugged it in for the first time, it was running some test/debug code from the factory and that seemed to dump out reasonable gyro data -- so my assumption at this point is that I have some sort of config/setup software problem, not a hardware problem.

Can anyone suggest something I may have missed initializing or setting up in order to get the low level SPI communication to the MPU6000 talking correctly and returning valid data registers?  As I mentioned before I'm using all the "library" code as much as possible so I'm avoiding (I hope) writing all the bare level hardware code.

Thanks!

Curt.

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • Hello Sir,

    I am using the APM2.5 board , and i am trying to run the MPU6000's code in an arduino project , some one can sujest me how can i use this code in my any project , 

    i have tried to do it , but the code does not compile and say

    "

    In file included from AP_Common.cpp:16:
    /AP_Common.h:37:34: error: c++.h: No such file or directory

    "

    can some one tell me how can i run the code , i am using windows 7 and arduino 1.0.2

    i am quite new to all of this , so i dont understand much of the things 

    please kindly help me in this , i shall be very thankful

  • Replying to myself -- the answer was in the MPU6000 example/demo code inside the library/

    // we need to stop the barometer from holding the SPI bus

    pinMode(40, OUTPUT);

    digitalWrite(40, HIGH);

    Tada ... seems to be spitting out plausible data now ...

This reply was deleted.