Sign In

Difficulty Processing The Raw Data From Mpu6050

rupesh jha jharupesh440@gmail.com India

Hardware: Pic18f4520 With 11.0529 Mhz Software: C Project Using Mplab X Ide With Xc8 Compiler

while reading the raw data frrom mpu6050 i am confused how o processed that data , also that data is a 16 bit and in a 2s compliment form .. so how to process the usful data in a c proggram

Images

Program

/*
 * File:   mpu.c
 * Author: zharupesh
 *
 * Created on 4 April, 2017, 1:03 PM
 */


#include <xc.h>
#include "mpu.h"
#include <stdio.h>
#include <stdlib.h>
#include <pic18f4520.h>
#include<I2C.h>
#include<float.h>

void main(void)
{
   unsigned int whoami ; 
    
    OpenI2C (MASTER,SLEW_OFF);
   SSPADD=27;
   IdleI2C();
    StartI2C ();
   IdleI2C();
   WriteI2C (0x68);
   IdleI2C();
   WriteI2C (0x6B);
   IdleI2C ();
   WriteI2C (0b00000000);
   IdleI2C ();
   StopI2C (); // till here we have writeen to power management 1 register
   
      StartI2C ();
   IdleI2C();
   WriteI2C (0x68);
   IdleI2C();
   WriteI2C (0x1B);
   IdleI2C ();
   WriteI2C (0b00000000);
   IdleI2C ();
   StopI2C ();// till here we have writeen to gyro congiguration register
   
  StartI2C ();
   IdleI2C();
   WriteI2C (0x68);
   IdleI2C();
   WriteI2C (0x1C);
   IdleI2C ();
   WriteI2C (0b00000000);
   IdleI2C ();
   StopI2C ();// till here we have writeen to accel congiguration register
   
   // now read the valuses of "who am i " register  and use it to glow a led  to confirm that mpu is working
    StartI2C ();
   IdleI2C();
   WriteI2C (0x69);
   IdleI2C();
   WriteI2C (0x75); // address of who am i register
   IdleI2C ();
   whoami = ReadI2C( void );
   IdleI2C ();
   StopI2C ();
   
   TRISB=0
   PORTB = whoami;
   __delay_ms(100);
   PORTB =0;
   __delay_ms(100);
   if(whoami==68)
   {
    PORTBbits.RB7=1;
   }
    
  
   
}

Post a reply to rupesh jha

Think you can help rupesh jha ? Then post your thoughts that might help rupesh jha. You will earn a lot of reputation in the technical community.

If your program is in multiple files, then ZIP the entire folder and attach below

Images and Screenshots

These helps other better understand your suggestion.