Jump to content
I2Cdevlib Forums


  • Posts

  • Joined

  • Last visited

Everything posted by theonetruthseer

  1. Hi, We are trying to create an Inertial Navigation System . For this, we wish to use a HB100 doppler as DVL to reduce error and an IMU for orientation and cross checking of data. So far, we have not integrated the HB100, and have only used the IMU. We would like some help with how to use the HB100 for speed sensing, with respect to ground. The datasheet of the HB100 is given below http://www.limpkin.fr/public/HB100/HB100_Microwave_Sensor_Module_Datasheet.pdf On the other hand, we have used the IMU to at least get a general view of the distance traveled and orientation. For this, we have used the code below, but the results are unsatisfactory // 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 "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 MPU6050 accelgyro; unsigned long prev=0; int16_t ax, ay, az; int16_t gx, gy, gz; int16_t mx, my, mz; float gyy=0; float bx,by,bz; float cx,cy,cz; float dx,dy,dz; float s, lv; float sy, lvy, sz, lvz; float ac, chax=0; float chay=0; float chaz=0; float cherror; int count=0; float inv=0, invy=0, invz=0; #define LED_PIN 13 bool blinkState = false; unsigned long previousMillis = 0; void setup() { // join I2C bus (I2Cdev library doesn't do this automatically) Wire.begin(); // 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(); // verify connection Serial.println("Testing device connections..."); Serial.println(accelgyro.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed"); for(int i=0;i<20;i++) { accelgyro.getMotion9(&ax, &ay, &az, &gx, &gy, &gz, &mx, &my, &mz); chax=chax+ax; chay=chay+ay; chaz=chaz+az; } chax=(float)chax/32768; chay=(float)chay/32768; chaz=(float)chaz/32768; Serial.println("New Chax"); Serial.print(chax); // configure Arduino LED for pinMode(LED_PIN, OUTPUT); } void loop() { // read raw accel/gyro measurements from device count=count+1; accelgyro.getMotion9(&ax, &ay, &az, &gx, &gy, &gz, &mx, &my, &mz); bx=(float)ax/(1638.4); by=(float)ay/(1638.4); bz=(float)az/(1638.4); float pitch = atan(bx/sqrt(pow(by,2) + pow(bz,2))); float roll = atan(by/sqrt(pow(bx,2) + pow(bz,2))); pitch = pitch * (180.0/PI); roll = roll * (180.0/PI); float yawRaw=atan2( (-my*cos(roll) + mz*sin(roll) ) , (mx*cos(pitch) + my*sin(pitch)*sin(roll)+ mz*sin(pitch)*cos(roll)) ) *180/PI; float YawU=atan2(-my, mx) *180/PI; bx=bx-chax; by=by-chay; bz=bz-chaz; cx=gx/65.5; cy=gy/65.5; cz=gz/65.5; //Motion in one simple direction, let y=0. unsigned long currentMillis = millis(); //record time of new reading float interval = float((float(currentMillis) - float(previousMillis))/1000) ; //Time of previous reading-Time of Current reading= Interval if(bx>0.03||bx<(-0.03)) { ac=bx*interval; //acceleration x time=velocity lv=inv; // initial velocity=lv, final velocity=inv inv=inv+ac; // vf =vi+1t; s=s+(lv*interval)+0.5*ac*interval; // Distance= Previous Distance + Vit + 1/2 x a x t^2 } if(by>0.02||by<(-0.02)){ ac=by*interval; lvy=invy; invy=invy+ac; sy=sy+(lvy*interval)+0.5*ac*interval; } if(bz>0.03||bz<(-0.03)) { ac=bz*interval; lvz=invz; invz=invz+ac; sz=sz+(lvz*interval)+0.5*ac*interval; } Serial.print("\n"); Serial.print((s*100)); //PRINT Serial.print(" "); Serial.print((sy*100)); Serial.print(" "); Serial.print((sz*100)); Serial.print(" "); Serial.print(interval); Serial.print(" "); Serial.print(pitch); Serial.print(" "); Serial.print(YawU); Serial.print(" "); Serial.println(roll); //Serial.print(" "); // Serial.print(interval,10); previousMillis=millis(); //record current time // blink LED to indicate activity blinkState = !blinkState; digitalWrite(LED_PIN, blinkState); } Can anyone help us with integrating the DVL, and also finding a more error free way of finding the orientation of the IMU quickly, as we wish to complete it in the next week? We are also having problems with running and accessing the DMP? Could you please help us with this as well. ANY GUIDANCE WILL BE APPRECIATED!
  • Create New...