Jump to content
I2Cdevlib Forums

Electrumpet

Members
  • Posts

    3
  • Joined

  • Last visited

Electrumpet's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Dear Jeff, Thanks for all the good work you did on this sensor. Without your work it would probably be worthless to me. I am posting in this forum although I have a MPU-9150 but this topic seems most fitting to my question. By using the faster I2C clock I am now sampling at 11ms per measurement (the 10 ms is in between measurements tells my osciloscoop). I made adjustments in the code as suggested changing the line: 02, 0x16, 0x02, 0x00, 0x01 // D_0_22 inv_set_fifo_rate into 02, 0x16, 0x02, 0x00, 0x00 // D_0_22 inv_set_fifo_rate I changed it in both the MPU6050_6Axis_MotionApps20.h and the MPU6050_9Axis_MotionApps41.h but I don't see the sample rate go down to 6 ms or change at all. Maybe it is set to 100 Hz somewhere else when I initialize the sensor? This is my arduino code: // I2C device class (I2Cdev) demonstration Arduino sketch for MPU9150 // 1/4/2013 original by Jeff Rowberg <jeff@rowberg.net> at https://github.com/jrowberg/i2cdevlib // modified by Aaron Weiss <aaron@sparkfun.com> // // Changelog: // 2011-10-07 - initial release // 2013-1-4 - added raw magnetometer output /* ============================================ I2Cdev device library code is placed under the MIT license Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. =============================================== */ // Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation // is used in I2Cdev.h #include "Wire.h" // I2Cdev and MPU6050 must be installed as libraries, or else the .cpp/.h files // for both classes must be in the include path of your project #include "I2Cdev.h" #include "AK8975.h" #include "MPU6050.h" // class default I2C address is 0x68 // specific I2C addresses may be passed as a parameter here // AD0 low = 0x68 (default for InvenSense evaluation board) // AD0 high = 0x69 AK8975 mag(0x0C); MPU6050 accelgyro; // address = 0x68, the default, on MPU6050 EVB MPU6050 mpu; int16_t ax, ay, az; int16_t gx, gy, gz; int16_t mx, my, mz; int16_t mpuData [9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; byte mpuDataSend [21] = { 127, 128, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; byte metingLSB = 0; byte metingMSB = 0; uint8_t mpuIntStatus; #define LED_PIN 11 // teensy ledpin bool blinkState = false; void setup() { // join I2C bus (I2Cdev library doesn't do this automatically) Wire.begin(); TWBR = 12; // set 400kHz mode @ 16MHz CPU or 200kHz mode @ 8MHz CPU // initialize serial communication // (38400 chosen because it works as well at 8MHz as it does at 16MHz, but // it's really up to you depending on your project) Serial.begin(115200); // initialize device Serial.println("Initializing I2C devices..."); accelgyro.initialize(); accelgyro.setI2CBypassEnabled(true); mag.initialize(); // verify connection Serial.println("Testing device connections..."); Serial.println(mag.testConnection() ? "AK8975 connection successful" : "AK8975 connection failed"); // configure Arduino LED for pinMode(LED_PIN, OUTPUT); } void loop() { // read raw accel/gyro measurements from device accelgyro.getMotion6(&mpuData[0], &mpuData[1], &mpuData[2], &mpuData[3], &mpuData[4], &mpuData[5]); // read raw heading measurements from device mag.getHeading(&mpuData[6], &mpuData[7], &mpuData[8]); for (byte i = 0; i <= 8; i++){ metingMSB = mpuData[i] >> 8; metingLSB = mpuData[i] & 255; mpuDataSend[3 + (i << 1)] = metingMSB; mpuDataSend[4 + (i << 1)] = metingLSB; } Serial.write (mpuDataSend, 21); // blink LED to indicate activity blinkState = !blinkState; digitalWrite(LED_PIN, blinkState); } I am looking for this high sample rate because of using it in a musical instrument. A latency under 10 ms is preferable. I hope someone (Jeff) can help me. Best, Hans.
  2. Dear Jfenwick, I found the answer in the forum in a post from Jeff. It seems that the I2C address you use for the AK8975 does not work. In his example he uses 0x0C instead of the 0x0E. If you change that it should work. It works with my MPU-9150 at least. https://github.com/jrowberg/i2cdevlib/blob/master/Arduino/AK8975/Examples/AK8975_MPUEVB_heading/AK8975_MPUEVB_heading.ino Best, Hans.
  3. Hi Jfenwick, Did you get any further yet? I am interested as well.... The accelgyro.getMotion9 which is in the original example for the mpu9150 does not show up the required result either. Best, Hans.
×
×
  • Create New...