Shop OBEX P1 Docs P2 Docs Learn Events
MPU-6050 Gyro + Accelerometer — Parallax Forums

MPU-6050 Gyro + Accelerometer

JBWolfJBWolf Posts: 405
edited 2015-02-02 08:25 in Propeller 1
There was a deal I just couldnt turn down for an MPU-6050 Gyro + Accel.
I have never used a Gyro or Accelerometer and couldnt find anything for this specific chip in the OBEX.
Can anyone offer advice and possibly a starting point for getting gyro/accel data from this chip?

Thanks!

Comments

  • JBWolfJBWolf Posts: 405
    edited 2013-02-21 03:09
    BTW here is the deal, looks like he just re-listed some more and it is a bargain!
    Just promise me one thing... if u use this link to purchase, you have to help me with getting it going on the propeller wink.png
    http://www.ebay.com/itm/MPU-6050-3-Axis-Accelerometer-3-Axis-Gyro-module-3-3V-5V-For-Arduino-/221184727986?pt=LH_DefaultDomain_0&hash=item337fa31bb2



    DataSheet:
    http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Components/General IC/PS-MPU-6000A.pdf

    Pics:
    IMG_2727.jpg
    IMG_2729.jpg
    1024 x 768 - 150K
    1024 x 1083 - 187K
  • SRLMSRLM Posts: 5,045
    edited 2013-02-21 11:56
  • StephenMooreStephenMoore Posts: 188
    edited 2013-02-21 18:12
    There is also this piece of code but I never got it to work right. I wound up buying an Arduino Uno ($30) and it works fantastic with the MPU-6050 (FreeIMU).

    Anyway, if you have success please let me know how it goes, this is great stuff.

    sm
  • JBWolfJBWolf Posts: 405
    edited 2013-09-01 19:10
    ok I havent been able to get the 6050 to work... can anyone recommend a good gyroscope + accelerometer to purchase? Either from sparkfun or parallax.
    Is there one that is most popular for quadcopter & persistence of vision projects?
    Thanks
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-09-01 19:28
    I just received a few of these on Saturday. I'll give them a look and see if I can get information from them.

    If you buy something else, I'd make sure and check out the sensors Jason Dorie is using in his projects. He has some quadcopter code for the Propeller.

    @sm, Do you have a link to the Arduino code?
  • dgatelydgately Posts: 1,630
    edited 2013-09-01 19:50
    Duane Degn wrote: »
    @sm, Do you have a link to the Arduino code?

    http://playground.arduino.cc/Main/MPU-6050

    I'm interested in how far this goes :-)

    dgately
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-09-01 21:01
    dgately wrote: »
    http://playground.arduino.cc/Main/MPU-6050

    I'm interested in how far this goes :-)

    dgately

    Thanks for the link.

    It may be few days (or a week) before I have anything to report. I have some new optical encoders I need to play with before trying to use these MPU-6050 sensors.
  • JBWolfJBWolf Posts: 405
    edited 2013-09-01 23:02
    I found this, its an arduino program to get raw dumps.
    http://www.i2cdevlib.com/devices/mpu6050#source

    The method used there is surpsringly simple.
    The call to MPU6050 registers are like this:
    void loop() {
        // read raw accel/gyro measurements from device
        accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
    
    
        // these methods (and a few others) are also available
        //accelgyro.getAcceleration(&ax, &ay, &az);
        //accelgyro.getRotation(&gx, &gy, &gz);
    
    
        // display tab-separated accel/gyro x/y/z values
        Serial.print("a/g:\t");
        Serial.print(ax); Serial.print("\t");
        Serial.print(ay); Serial.print("\t");
        Serial.print(az); Serial.print("\t");
        Serial.print(gx); Serial.print("\t");
        Serial.print(gy); Serial.print("\t");
        Serial.println(gz);
    
    

    Here is the main program:
    https://github.com/jrowberg/i2cdevlib/blob/master/Arduino/MPU6050/Examples/MPU6050_raw/MPU6050_raw.ino
    The MPU6050 library file:
    https://github.com/jrowberg/i2cdevlib/blob/master/Arduino/MPU6050/MPU6050.h

    Can anyone help translate these to spin?
  • JBWolfJBWolf Posts: 405
    edited 2013-09-02 06:13
    I guess what I do not understand is how to communicate with the MPU chip.
    Here is the pdf with all of the registers: RM-MPU-6000A.pdf
    But how do I utilize spin to request any one of these values? i.e. what command/function do I call in spin to request & store one of these?
    Say I want the X-axis gyro value:
    Hex:   Dec:   Register Name:    Serial I/F:            Bits 7-0:
     43     67     GYRO_XOUT_H           R              GYRO_XOUT[15:8]
     44     68     GYRO_XOUT_L           R               GYRO_XOUT[7:0]
    

    All of the example code I have that attempts to work with the 6050 is primarily in ASM, which I unfortunately cannot follow.
    Is there just a basic SPIN language command to make a request for the X-axis gyro data and store it?
    Thanks
  • StephenMooreStephenMoore Posts: 188
    edited 2013-09-02 10:04
    Hi guys,

    I have used the FreeIMU very successfully with the Arduino UNO. If you load up Arduino Processing there is a great demo with a cube on the PC screen that matches the position of the sensor in your hand.

    I recently checked the website and was most dismayed to find out that Fabio Varesano has passed away.

    It appears that some of his family (and others) are continuing his work as he was doing a fantastic job of making this technology available to everyone.

    The link I have is:


    www.varesano.net/projects/hardware/FreeIMU#v0.4

    The world has lost a great pioneer... check out some of his videos he posted.

    Regards,

    sm
  • FernandFernand Posts: 83
    edited 2013-09-03 00:42
    Given the 6050 bashing, how about not beating your head against the wall and use a $8 Arduino Mini or one of the Nanos (with USB on-board) and all the existing & working 6050 Arduino code as a Front End Processor, add any smoothing/filtering code you need, and pass whatever you want, over e.g. a Serial Link, to your Prop?

    If price is a concern, you can get Minis for under $5 in tens. If you require especially small and light (e.g. for a flying app), the Minis are also hard to beat. For development these are especially well made boards, and ship with an FTDI. I haven't figured out all the "ramifications", but there's no question the Arduino libraries work with those little GY-521, and I just got several of them for under $5 shipped, cheaper from China. And there are other chips/boards Arduinos interface with. "Love the one you're with ..."
  • teganburnsteganburns Posts: 134
    edited 2013-09-03 17:15
    I wrote a driver for the MPU-9150 its based off of Jayson's ITG-3200 Driver.

    http://obex.parallax.com/object/704

    A
    ll you would need to do is replace some of the register values.
  • coderbadcoderbad Posts: 29
    edited 2015-01-29 21:04
    teganburns wrote: »
    I wrote a driver for the MPU-9150 its based off of Jayson's ITG-3200 Driver.

    http://obex.parallax.com/object/704

    A
    ll you would need to do is replace some of the register values.
    Hi teganburns
    I see your code and I want to change to mpu-6050, but I don´t know where is the register values that I have to replace, could you help me ?
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2015-01-31 11:22
    Can you understand what the MPU-6050 does not have that the MPU-9150 provides?

    You will have to just eliminate the code that is not required. And then verify that you have not broken the code while doing so.

    Don't get hung up on looking for registers. The Propeller's memory is 32K of registers. You need to understand the code itself AND the Propeller architecture.
  • Heater.Heater. Posts: 21,230
    edited 2015-01-31 11:38
    Let's not confuse "registers" with "resisters".

    I presume teganburns suggestion is that his drive could be used with a different device if someone tweaked with the device registers his code uses.

    That is nothing to do with registers in the Propeller chip.

    It's also nothing to do with the 32K of RAM in the Propeller that is not normally referred to as resisters (Although on some low hardware design level they might be)

    Sadly I have no idea about either chip in question here or teganburns driver so I'm not much help. But let's not pour confusion on top of confusion.

    Seems to me that one is a six axis device whilst the other is nine. It's quite likely that the same driver can be used for both with a bit of tweaking and the acceptance that 3 axes are missing in one case.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2015-02-01 02:07
    I think we have a multi-cultural language problem with the referenece to 'registers'.

    Without getting too technical, I am trying to say that sticking witht the written code and looking at how the configuration needs to be modified will make progress.

    Debating what is a register and where are they in the Propeller is a huge distraction.

    +++++++++++
    The MCP-6050 is a good product... if the seller did indeed send you a working device. A lot of the cheap IMUs sold on EBay have complaints that they are not working right. They appear to be rejects that are flawed in manufacture.

    So rather than switch, the first thing to do is to verify your device is healthy. Even if you switch to another device, it still requires that you test in the device is healthy.

    Face reality, you can't skip this step. You may have to create your own test code that simply reads each sensor and sends the output through the USB to be read on a laptop or home computer. If you are rushed, you might find someone has already done this for the Propeller. If not, it seems it has been done for the Raspberry Pi and the Arduino.

    Dealing with mystery parts can waste weeks or months. Always start with a product 'sanity check'.

    Meanwhile, I have downloaded Teganburns code and am examing it. Changing 6DOF is not just about modify the hardware configuration. It uses a shorter, simpler algorhytm to combine the Gyros and Accellerometers.

    You MUST switch to the 6DOF algorhytm for best performance. I have no idea what might happen the 9DOF algorhytm is used with X, Y, and Z magnentic readings remaining all zeros.

    Jasons ITG-3200 driver is really more than just the ITG-3200. It is a 9DOF driver that works nicely with the HoverFly GIMBAL board -- gyros, accellerometers, and magnetic bearing on the X, Y, and Z.

    You have to compare the HoverFly GIMBAL sensors (all of them both in techincal output and their position on the board) to the MCP-6050. I believe at least one sensor needs to sway the X and Y axis reading due to different construction.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2015-02-02 08:25
    9DOH uses Madgwick's filters, 6DOH uses Mahoney's filters. Here is a background link.

    https://code.google.com/p/uav-helicoptor-ece4007/wiki/MadgwickAHRS

    Note the link near the bottom of the page to Madgwick's original publication.

    http://www.x-io.co.uk/res/doc/madgwick_internal_report.pdf

    That publication has example code (in C) for Mahoney and Madjwick in Appendices A and B. This is the core reference for getting the MCP6050 to work on the Propeller.

    One has to change the C code to SPIN and PASM. Jason Dorie optimized the math for the Propeller and followed Madjwick in Appendixe B. The challenge is to replace Jason's work with a SPIN and PASM version of Appendix A.
Sign In or Register to comment.