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.
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
Tada ... seems to be spitting out plausible data now ...
I'd like to ask a follow up question on this ... can anyone help, or is there a better place to post detaied hardware/software level questions?
The above solution (setting pin #40 to high) works for me. But no where in the ArduPlane code can I find this being done -- only in their library example code. So how are they making this work? I'd like to start reading the barometer and the mpu6000 -- what do I need to know, what do I need to watch out for, what do I need to do in order to make these two devices work properly together?
What magic is the ArduPlane code doing to make this happen properly? I can't see how it's happening.
Long shot as it was some time ago, how did you get on with enabling BOTH the MPU6000 and barometer, in respect of the point you make regarding setting pin 40 in the example, which I have also seen. I am about to start an adventure of my own with a custom sketch for the MPU6000.
It's been too long now, but I think the solution I arrived at was to simply use the arduplane library API and initialize these in the same order as the arduplane source. The library functions I believe work out the picky details under the hood so it all just works ... if you initialize the sensors in the same order as the arduplane code.
Thanks Curt, appreciated.
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