Get 6050 raw Data

Source: Internet
Author: User
MPU6050 Analysis of raw data
Personal experience, if the IIC bus protocol is very familiar with the situation, to get 6050 of the original data is not much of a problem, after all, how complex is just a sensor just like you call the sensor, to its data, and then it returned to you, that's all.

First of all, to understand what 6050 is doing:

MPU-6000 (6050) is the world's first integrated 6-axis motion processing component, which eliminates the problem of the difference between the combined gyroscope and the accelerator timeline compared to the multi-component solution, reducing the amount of package space. (from Baidu Encyclopedia)
simply said that the sensor can obtain the xyz three axis direction angular velocity and acceleration, including 6 16-bit ADC to represent these values, about the measurement principle of the sensor, you can simply imagine the pattern similar to the following diagram, is not very intuitive.

Of course, the child shoes with ad conversion know that this is a precision problem, 6050 is the same, and the impact of more noise, but this time not to discuss this issue, only to discuss how to get the original data

Words don't say much, on the code initialization code implementation

/*--------MPU6050 Address macro definition---------*/#define MPU6050_SLAVEADDR 0xd0//IIC write 6050 address #define MPU6050_ACCADDR 0x3B MPU acceleration Read Address #define MPU6050_GYROADDR 0x43//Gyroscope Read value address #define MPU_REMOVE_SLEEP 0x6b//de-hibernate address #define Mpu_gyro_ Smple_div 0x19//Gyroscope sample rate Register 1Khz #define MPU_LOW_PASS 0x1a//low-pass filter bandwidth 5K #define MPU_ACC_CONFIG 0x1c//    Accelerometer working in 2g mode #define MPU_GYRO_CONFIG 0x1b//Gyroscope self-test and measurement range, Typ.: 0x18 (not self-checking, 2000deg/s) #define MPU_ACC_OUT_ADDR 0x3b Read Acceleration Register #define MPU_GYRO_OUT_ADDR 0x43//Read gyroscope register//mpu6050 initialize void Mpu6050_init (void) {//For IIC initialization iic_
    Init ();
    Make a small delay to prevent the power loss and then the data error mpu_dealy (1000);
    Release sleep state Iic_writedata (Mpu6050_slaveaddr,mpu_remove_sleep, 0x00);
    Gyro sampling rate Iic_writedata (mpu6050_slaveaddr,mpu_gyro_smple_div,0x07);
    Low pass filter setting Iic_writedata (mpu6050_slaveaddr,mpu_low_pass,0x06);
    The accelerometer is configured to operate in 2g mode Iic_writedata (mpu6050_slaveaddr,mpu_acc_config,0x00); Configuring the gyroscope range and self-test range Iic_wriTedata (Mpu6050_slaveaddr,mpu_gyro_config, 0x18);    }

About the configuration of the register there is nothing to say, look at the data sheet a little bit, it is worth noting that the 2g mode, this refers to 6050 of the range is easy to find that the acceleration output range between -16384-->+16384, so the calculated acceleration is (read value)/ 16384 (g) Naturally, the acceleration is the same, however, this does not fall within the scope of the current discussion.
Read the acceleration and angular velocity of the code below, in fact, 6050 can also get a lot of parameters, here not to repeat, query manual can be.

void Mpu6050read_acc (short *accdata)//mpu6050 read acceleration {U8 buf[6];
    Since we read one byte at a time, and 6050 of the ADC is 16 bits, first read, then fetch, or operate, sequentially the XYZ axis iic_readdata (mpu6050_slaveaddr,mpu_acc_out_addr,buf,6); Accdata[0] = (Buf[0] << 8) |
    BUF[1]; ACCDATA[1] = (buf[2] << 8) |
    BUF[3]; ACCDATA[2] = (Buf[4] << 8) |
BUF[5];
    } void Mpu6050read_gyro (short *gyrodata)//mpu6050 read gyroscope {U8 buf[6];
    Iic_readdata (mpu6050_slaveaddr,mpu_gyro_out_addr,buf,6); Gyrodata[0] = (Buf[0] << 8) |
    BUF[1]; GYRODATA[1] = (buf[2] << 8) |
    BUF[3]; GYRODATA[2] = (Buf[4] << 8) |
BUF[5];
    }//Note that since 6050 has a noise signal, it is considered to be a program correct int main () {short accel[3] when 6050 of the acceleration value is read at a level of 16384.
    Short gyro[3];
    All_init ();
        while (1) {MPU6050READ_ACC (Accel);
        printf ("\ r \ n Acceleration:%8d%8d%8d\t", accel[0],accel[1],accel[2]);
        Mpu6050read_gyro (Gyro);
        printf ("Gyroscope:%8d%8d%8d", gyro[0],gyro[1],gyro[2]);
    Delay_ms (1000); }
}
 

(To solve a few problems under the reprint content, infringement please prompt deletion)
What is 1.mpu6050.

The MPU6050 is a 6-axis motion processing component that includes 3-axis acceleration and 3-axis gyroscope.
MPU-6000 is the world's first integrated 6-axis motion processing component, which eliminates the problem of shaft gap between the combined gyroscope and accelerator when compared to multi-component solutions, reducing the amount of packaging space. The MPU-6000 incorporates a 3-axis gyroscope, a 3-axis accelerator, and a Digital motion processing (dmp:digital motion Processor) hardware acceleration engine that can connect other card accelerators, magnetic sensors, or other sensors with a second i²c port. Output a complete 9-axis fusion algorithm to the application side from the primary i²c port in a single data stream
InvenSense's motion processing database, which can handle the complex data of motion sensing, reduces the load on the operating system of motion processing operations and provides an architectural API for application development.
MPU-6000 's angular velocity of the whole lattice sensing range is ±250, ±500, ±1000 and ±2000°/sec (DPS), can accurately follow the hovers fast and slow motion, and the user-programmable accelerator full lattice sensing range of ±2g, ±4g±8g and ±16g. The product can be transmitted via an i²c up to 400kHz or SPI up to 20MHz.
The MPU-6000 can operate at different voltages, the VDD supply voltage is 2.5v±5%, 3.0v±5%, or 3.3v±5%, and the logic interface Vvdio power supply is 1.8v±5%. The MPU-6000 package size 4x4x0.9mm (QFN) is a revolutionary size in the industry. Other features include a built-in temperature sensor, an oscillator that contains only ±1% changes in the operating environment.

2. What are the accelerometer sensors for?

In general, this acceleration sensor is actually a force sensor. It is used to check how many forces (including gravity) are affected by the upper and lower left and right sides, and then calculate the angle.

3. Why is the gyroscope used?
In short, the gyroscope is the angular velocity tester. For example, a board, the axis of the x axis, in a second time to 90 degrees, then its angular velocity on the x-axis is 90 degrees/second (DPS, angular velocity units, degree per second abbreviation °/s, reflecting the speed of rotation)

What is the 4.mpu6050 resolution?

The 3-axis acceleration and the 3-axis gyroscope use 3 16-bit ADCs, which means that there are 3 16-bit ADCs for acceleration, one for each axis. It is also said that each axis output data, is 2^16 that is -32768--+32768. The same is true for gyroscopes. Unit conversions
It says -32768-+32768, so what does this number really mean? For example, the gyroscope 32768 is exactly the angular velocity of how many degrees/second.
This is actually based on the range set by the MPU6050, the range is different, 32768 means the value is different.

The MPU6050 's quantum setting is set in the Mpu6050::initialize () (MPU6050.cpp Library) initialization function:
Setfullscalegyrorange (mpu6050_gyro_fs_250);
Setfullscaleaccelrange (mpu6050_accel_fs_2);
Set to, 250 degrees/sec, 2g, respectively

According to the gyroscope, the MPU6050 has four ranges to choose from:
±250,±500,±1000,±2000 degrees/s
For example, if the setting is ±250, then -32768--+32768 represents the -250--+250. At this time its LSB (pull silly B, least significant bit) is 131 lsb/(degrees/s)

About data fusion, and finally get Euler's angle, is the next content
Simply put, the original data first to solve the calculation, filtering, basically is the process. Source code has been uploaded to Csdn resources (STM32-based serial display MPU6050 raw data)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.