3228

MPU6050 attitude sensing module

 
Overview

figure 1:

Picture 2:

Needless to say, the MPU6050 communication code

The three angles calculated from the posture can be passed to the Data_Send_Status function.

The attitude calculation code of the anonymous host computer is as follows. It is used with the anonymous host computer V7 and is written in TM4:

EBMCUSR1ztQ3bSTGsMxuXlsRZR3LWy338KeEmO4m.png

void usart_send_char(uint8_t c)
{
    UARTCharPutNonBlocking(UART0_BASE, c);
    while (UARTBusy(UART0_BASE))
        ;
}


void Data_Send_Status(float Pitch, float Roll, float Yaw)
{
    unsigned char i = 0;
    unsigned char _cnt = 0, sum = 0, add = 0;
    unsigned int _temp;
    unsigned char data_to_send[50];


    data_to_send[_cnt++] = 0xAA;
    data_to_send[_cnt++] = 0xFF;
    data_to_send[_cnt++] = 0x03;
    data_to_send[_cnt++] = 0x07;


    _temp = (int)(Roll * 100);
    data_to_send[_cnt++] = BYTE0(_temp);
    data_to_send[_cnt++] = BYTE1(_temp);
    _temp = 0 - (int)(Pitch * 100);
    data_to_send[_cnt++] = BYTE0(_temp);
    data_to_send[_cnt++] = BYTE1(_temp);
    _temp = (int)(Yaw * 100);
    data_to_send[_cnt++] = BYTE0(_temp);
    data_to_send[_cnt++] = BYTE1(_temp);
    data_to_send[_cnt++] = 0x00;


    //sum check
    for (i = 0; i < data_to_send[3] + 4; i++)
    {
        sum += data_to_send[i];
        add += sum;
    }
    data_to_send[_cnt++] = sum;
    data_to_send[_cnt++] = add;


    //serial port sends data
    for (i = 0; i < _cnt; i++)
        usart_send_char(data_to_send[i]);
}

 

 

 

参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-06-24 09:37:45

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号