How to power up MPU 6050 gyro sensor accelarometer device?

IMU - Inertial Measurement Unit.
Gowrishankar
Posts: 2
Joined: Tue Jul 24, 2012 6:27 pm

How to power up MPU 6050 gyro sensor accelarometer device?

Postby Gowrishankar » Tue Jul 24, 2012 7:29 pm

I'm using Atmega32A, to communicate with MPU6050 device. I dumped the code in the microcontroller, powered up the device and tried communicating we the device and there is no response. I'm pretty sure that my code is correct, because i tried communication with another Atmega 16A microcontroller and the data transfer is proper. I'm not sure whether the way i powered it is right. Can you please go through and suggest me..? I have attached the circuit diagram of the connections i made.

Photo0142.jpg
Circuit diagram
Photo0142.jpg (201.28 KiB) Viewed 4841 times


To get the response for address call from the device that i used the following code:

#ifndef F_CPU
#define F_CPU 8000000UL
#endif

#include<avr/io.h>
#include<util/delay.h>
#include<inttypes.h>

void TWI_start(void);
void TWI_init_master(void);
void TWI_write_address(unsigned char);
void TWI_write_data(unsigned char);
void TWI_stop(void);
unsigned char address=0x68, read=1, write=0;
unsigned char write_data=0x3B, recv_data;

int main(void)
{
DDRA = 0xFF;
TWI_init_master();
TWI_start();
TWI_write_address(address+write);
TWI_write_data(write_data);
TWI_stop();
}

void TWI_init_master(void) // Function to initialize master
{
TWBR=0x08; // Bit rate
TWSR=(0<<TWPS1)|(0<<TWPS0); // Setting prescalar bits
// SCL freq= F_CPU/(16+2(TWBR).4^TWPS)
PORTA = 0x01;
}

void TWI_start(void)
{
// Clear TWI interrupt flag, Put start condition on SDA, Enable TWI
TWCR= (1<<TWINT)|(1<<TWSTA)|(1<<TWEN);
while(!(TWCR & (1<<TWINT))); // Wait till start condition is transmitted
while((TWSR & 0xF8)!= 0x08); // Check for the acknowledgement
PORTA=0b00000011;// start is passed this is on
}

void TWI_write_address(unsigned char data)
{
TWDR=data; // Address and write instruction
TWCR=(1<<TWINT)|(1<<TWEN); // Clear TWI interrupt flag,Enable TWI
while (!(TWCR & (1<<TWINT))); // Wait till complete TWDR byte transmitted
PORTA = 0b00000111;// this is on
while((TWSR & 0xF8)!= 0x18); // Check for the acknoledgement
PORTA = 0b00001111;// confirm the acknowledgements to us this is off
}

void TWI_write_data(unsigned char data)
{
TWDR=data; // put data in TWDR
TWCR=(1<<TWINT)|(1<<TWEN); // Clear TWI interrupt flag,Enable TWI
while (!(TWCR & (1<<TWINT))); // Wait till complete TWDR byte transmitted
PORTA = 0b00011111;// this is on
while((TWSR & 0xF8) != 0x28); // Check for the acknoledgement
PORTA = 0b00111111;// confirm the acknowledgements to us this is off
}

void TWI_stop(void)
{
// Clear TWI interrupt flag, Put stop condition on SDA, Enable TWI
TWCR= (1<<TWINT)|(1<<TWEN)|(1<<TWSTO);
while(!(TWCR & (1<<TWSTO))); // Wait till stop condition is transmitted
PORTA = 0b01111111;
}

On the whole there is no response from the device. :(
abhimanyu
Posts: 94
Joined: Tue Oct 18, 2011 9:49 pm

Re: How to power up MPU 6050 gyro sensor accelarometer devic

Postby abhimanyu » Wed Jul 25, 2012 7:32 am

What is the state of the I2C Selection Jumper (SJ1) on the Device.
For Address 0x68, it must be connected to GND (By default).

And, take care to not power up the device with anything greater than 3.46V.
What is your source for the 3.3V Supply?

Also, there are 10K Pull-up resistors on the Device already.
See the SparkFun Schematic.
You may remove the 2.2K resistors from your setup.
Gowrishankar
Posts: 2
Joined: Tue Jul 24, 2012 6:27 pm

Re: How to power up MPU 6050 gyro sensor accelarometer devic

Postby Gowrishankar » Wed Jul 25, 2012 8:19 am

Sir i don't understand where is SJ1 jumper, i saw the schematic of the board i could not find any of those ten pins related to this. Other than what i have shown in the circuit diagram i did not make any hardware connections. AD0 led in the board is off, That means the the last bit is zero and the address is 0x68 is that right??? How to connect the SJ1 to GND? Is it a hardware connection? This is the first time i'm trying to communicate with board, so no chance for me to change the faults before.

I'm using LM317T regulator for powering up the device.

I'l remove the pull up resistors.
abhimanyu
Posts: 94
Joined: Tue Oct 18, 2011 9:49 pm

Re: How to power up MPU 6050 gyro sensor accelarometer devic

Postby abhimanyu » Wed Jul 25, 2012 10:02 am

The ten pins are on the left most side of the page labelled as JP6 - M10".
The AD0 Jumper is shown below marked with an arrow (attachment):
There is no LED On-Board. You may have mistaken it for this shining jumper.

These jumpers can be switched to other states by using a hot Soldering Iron. there are in all three pads at the bottom from which you can see only one and the remaining two are covered with a blob of solder.

In the schematic, at the bottom, you will see this line: SJ1 is used for connecting Two MPUs together.
Better let it be in the default state. There are two SJs at the back of the board for additional options.

Measure the voltage with a Multimeter on the Pin 10 - Vdd as well as Pin 4 Vio. It must be no more than 3.3V.
Also, check that your Power Supply has all the required ByPass Capacitors for proper filtering.
Attachments
11028-02.jpg
SFE Front Pic of MPU-6050 showing AD0 Jumper
11028-02.jpg (80.9 KiB) Viewed 4833 times
abhimanyu
Posts: 94
Joined: Tue Oct 18, 2011 9:49 pm

Re: How to power up MPU 6050 gyro sensor accelarometer devic

Postby abhimanyu » Wed Jul 25, 2012 3:06 pm

Here are some Code Samples for you to try on your MPU 6050.
Note that these are created for Arduino Boards but you may get an idea on how to proceed.

I2C Scanners:
Nick Gammons
todbot
Another one.

Code Samples:
Arduino Playground
DMP Code by jRowberg on github

Return to “IMU”

Who is online

Users browsing this forum: No registered users and 1 guest