0
\$\begingroup\$

I would like to apologize before I start this question as I don't have the code to put down here as it is in my work pc. BUT.. 1)I have figured out that my GY521 Module (for MPU6050) has been correctly interfaced with the CPU ATMEGA32 that I am using.

SDA -> SDA

SCL -> SCL

Vcc for CPU as well as GY521 is being powered up at 3.3V

2)TWI interface works perfectly. I am using 6 functions for TWI Library.

TWI_START for generating start conditon

TWI_STOP for generating stop condition

TWI_READ and TWI_WRITE for reading and writing.

TWI_DEVICE_READ for generating a frame for reading data from register of the slave address provide.

TWI_DEVICE_WRITE for generating a frame for writing data to register of the slave address provide.

3)When I read WHOAMI register, it returns me the correct value ie 104d or 68h. I am able to write to registers , but when I read them back for conforming all I get 0.

4)After a lil working around I found out that the default state of bit 6 of PWR_MGMT_1 happens to be high ie in the sleep mode. I tried to write new vale to PWR_MGMT_1 but when I read back , I get the same default value ie 40h or 64d.

Now here I would like to believe that I have given almost all the description I could think of, if anything is left out do let me know please.

and I would appreciate any efforts made in order to solve my problem of initializing the mpu6050, reading and writing the registers and turning off the sleep mode.

THANKS :)

\$\endgroup\$
  • 1
    \$\begingroup\$ The MPU6050 is notoriously tricky to set up. Your best bet is to first use an Arduino library and then reverse engineer it. \$\endgroup\$ – vini_i Oct 21 '16 at 19:17
  • 1
    \$\begingroup\$ It is clear that you are using I2C interface to communicate between your devices, what exactly happens is difficult to figure out. It would help to answer your question if you provided more information how your blocks are interconnected, the specksheets for the parts. And what is TWI? how do you know it works correctly? \$\endgroup\$ – Nazar Oct 21 '16 at 19:18
  • \$\begingroup\$ @Naz When you say how your blocks are interconnected , do you mean a schematic? and y specksheets do you mean electrical characteristics of the module or IC? \$\endgroup\$ – Shreel Chhatbar Oct 21 '16 at 19:28
  • \$\begingroup\$ @Naz TWI is two wire interface AKA i2c only \$\endgroup\$ – Shreel Chhatbar Oct 21 '16 at 19:29
  • \$\begingroup\$ Yes, the schematic would help to see if the hardware is properly interfaced. And the documentation on the hardware could be helpful if someone wanted to verify the specific details, etc. \$\endgroup\$ – Nazar Oct 21 '16 at 20:14
2
\$\begingroup\$

It seems that you are saying that your hardware is OK (but you haven't supplied a schematic and a photo of your prototype) and saying that your software is OK (but you haven't supplied any code). They can't both be OK, if you are having a problem! However you have not supplied enough information for sensible analysis. :-(

I suggest you start to solve your problem this way:

  • Stop using your own software.
  • Find a "known working" software example for accessing the MPU6050 using Google - lots of people have published tutorials etc.
  • Use that software example (unchanged) on your hardware.
  • If that software works, then the problem was your original software.
  • If that software does not work, then your hardware has a problem (your software might also have a problem, but you cannot know at this stage).

Using that "flowchart", you will discover where to start looking for your problem.

If you have an oscilloscope or logic analyser, then you can view the I/O on the I2C bus, to confirm what is actually happening. It seems possible that you have a problem with your I2C writing, since the data in registers seems unchanged after you think you have written to them.

\$\endgroup\$
  • \$\begingroup\$ Would definitely \$\endgroup\$ – Shreel Chhatbar Oct 21 '16 at 19:25
  • \$\begingroup\$ Would definitely try what you proposed and get back to you tomorrow. \$\endgroup\$ – Shreel Chhatbar Oct 21 '16 at 19:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.