Go Down

Topic: Unable to find datasheet for MPU (Read 470 times) previous topic - next topic

corbax

hello guys
so I am unable to find a datasheet for my mpu. I have "Kingduino 6-DOF IMU Module Attitude Control 6DOF 3205 345" .

here is the code I found to try out my gyro. I think that the code works but my problem is  that I don't know slave address of mpu. This code is for mpu6050
Code: [Select]


/* http://www.youtube.com/c/electronoobs
 *
 * This is an example where we configure te data of the MPU6050
 * and read the gyro data and print it to the serial monitor
 *
 * Arduino pin    |   MPU6050
 * 5V             |   Vcc
 * GND            |   GND
 * A4             |   SDA
 * A5             |   SCL
 */
 
//Includes
#include <Wire.h>


//Variables
float elapsedTime, time, timePrev;        //Variables for time control
int gyro_error=0;                         //We use this variable to only calculate once the gyro data error
int16_t Gyr_rawX, Gyr_rawY, Gyr_rawZ;     //Here we store the raw data read
float Gyro_angle_x, Gyro_angle_y;         //Here we store the angle value obtained with Gyro data
float Gyro_raw_error_x, Gyro_raw_error_y; //Here we store the initial gyro data error



void setup() {
  Wire.begin();                           //begin the wire comunication 
  Wire.beginTransmission(0x68);           //begin, Send the slave adress (in this case 68)             
  Wire.write(0x6B);                       //make the reset (place a 0 into the 6B register)
  Wire.write(0x00);
  Wire.endTransmission(true);             //end the transmission
 
  Wire.beginTransmission(0x68);           //begin, Send the slave adress (in this case 68)
  Wire.write(0x1B);                       //We want to write to the GYRO_CONFIG register (1B hex)
  Wire.write(0x10);                       //Set the register bits as 00010000 (1000dps full scale)
  Wire.endTransmission(true);             //End the transmission with the gyro

  Serial.begin(9600);                     //Remember to set this same baud rate to the serial monitor 
  time = millis();                        //Start counting time in milliseconds



/*Here we calculate the gyro data error before we start the loop
 * I make the mean of 200 values, that should be enough*/
  if(gyro_error==0)
  {
    for(int i=0; i<200; i++)
    {
      Wire.beginTransmission(0x68);            //begin, Send the slave adress (in this case 68)
      Wire.write(0x43);                        //First adress of the Gyro data
      Wire.endTransmission(false);
      Wire.requestFrom(0x68,4,true);           //We ask for just 4 registers
         
      Gyr_rawX=Wire.read()<<8|Wire.read();     //Once again we shif and sum
      Gyr_rawY=Wire.read()<<8|Wire.read();
   
      /*---X---*/
      Gyro_raw_error_x = Gyro_raw_error_x + (Gyr_rawX/32.8);
      /*---Y---*/
      Gyro_raw_error_y = Gyro_raw_error_y + (Gyr_rawY/32.8);
      if(i==199)
      {
        Gyro_raw_error_x = Gyro_raw_error_x/200;
        Gyro_raw_error_y = Gyro_raw_error_y/200;
        gyro_error=1;
      }
    }
  } 
}//end of setup void






void loop() {
    timePrev = time;                        // the previous time is stored before the actual time read
    time = millis();                        // actual time read
    elapsedTime = (time - timePrev) / 1000; //divide by 1000 in order to obtain seconds

   
//////////////////////////////////////Gyro read/////////////////////////////////////

    Wire.beginTransmission(0x68);            //begin, Send the slave adress (in this case 68)
    Wire.write(0x43);                        //First adress of the Gyro data
    Wire.endTransmission(false);
    Wire.requestFrom(0x68,4,true);           //We ask for just 4 registers
       
    Gyr_rawX=Wire.read()<<8|Wire.read();     //Once again we shif and sum
    Gyr_rawY=Wire.read()<<8|Wire.read();
    /*Now in order to obtain the gyro data in degrees/seconds we have to divide first
    the raw value by 32.8 because that's the value that the datasheet gives us for a 1000dps range*/
    /*---X---*/
    Gyr_rawX = (Gyr_rawX/32.8) - Gyro_raw_error_x;
    /*---Y---*/
    Gyr_rawY = (Gyr_rawY/32.8) - Gyro_raw_error_y;
   
    /*Now we integrate the raw value in degrees per seconds in order to obtain the angle
    * If you multiply degrees/seconds by seconds you obtain degrees */
    /*---X---*/
    Gyro_angle_x = Gyro_angle_x  + Gyr_rawX*elapsedTime;
    /*---X---*/
    Gyro_angle_y = Gyro_angle_y  + Gyr_rawY*elapsedTime;

    //Serial.print("GyroX raw: ");
    //Serial.print(Gyr_rawX);
    //Serial.print("   |   ");
    Serial.print("GyroY raw: ");
    Serial.println(Gyr_rawY);
    //Serial.print("   |   ");
    //Serial.print("GyroX angle: ");
    //Serial.print(Gyro_angle_x);
    //Serial.print("   |   ");
    //Serial.print("GyroY angle: ");
    //Serial.println(Gyro_angle_y);

}

AWOL

#1
Apr 05, 2019, 04:59 pm Last Edit: Apr 15, 2019, 05:31 pm by AWOL
Have you tried an I2C scan?

corbax

I dont know what that is but ill research it and give you update

groundFungus

An I2C scanner sketch:

Code: [Select]
// I2C scanner by Nick Gammon.  Thanks Nick.

#include <Wire.h>

void setup() {
  Serial.begin (115200); //*****  make sure serial monitor baud matches *****

  // Leonardo: wait for serial port to connect
  while (!Serial)
    {
    }

  Serial.println ();
  Serial.println ("I2C scanner. Scanning ...");
  byte count = 0;
 
  Wire.begin();
  for (byte i = 1; i < 120; i++)
  {
    Wire.beginTransmission (i);
    if (Wire.endTransmission () == 0)
      {
      Serial.print ("Found address: ");
      Serial.print (i, DEC);
      Serial.print (" (0x");
      Serial.print (i, HEX);
      Serial.println (")");
      count++;
      delay (1);  // maybe unneeded?
      } // end of good response
  } // end of for loop
  Serial.println ("Done.");
  Serial.print ("Found ");
  Serial.print (count, DEC);
  Serial.println (" device(s).");
}  // end of setup

void loop() {}

MAS3

Hi corbax, and welcome.

You should have told this is about a final exam in this thread too.

Did you try searching using google or something like that ?

The description you gave, has partial part numbers in it.
345 is an ADXL345 (quite well known)
3205 is an InvenSense ITG3205 (never heard of either brand or type), and that is what you seem to be looking for.
Google has a link to a datasheet for you if you ask for it.
The datasheet tells about the addresses which can be used for this device, but lots more.
So you really need it.

Lots of success with your exam.
Have a look at "blink without delay".
Did you connect the grounds ?
Je kunt hier ook in het Nederlands terecht: http://arduino.cc/forum/index.php/board,77.0.html

corbax

I was looking on google for a few days without any success. I managed to find the datasheet. Believe me, when I found it I felt so stupid cuz it was the second link... Anyways I got gyro readings but when gyro is on the table
- values are constantly rising
- if I move it, values do not come back to the same number but each time its higher for 3 or 4

groundFungus

Gyros drift.  That is why you rarely see them used alone.  Google "gyro drift" to see more information.

Go Up