GithubHelp home page GithubHelp logo

zy015240 / mpu6050 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from leech001/mpu6050

0.0 1.0 0.0 1.37 MB

STM32 HAL library for GY-521 (MPU6050) with Kalman filter

License: GNU General Public License v3.0

C 100.00%

mpu6050's Introduction

STM32 HAL library for GY-521 (MPU6050) with Kalman filter

English note

A simple C library (STM32 HAL) for working with the GY-521 module (MPU6050) https://www.aliexpress.com/af/gy%25252d521.html?trafficChannel=af&d=y&CatId=0&SearchText=gy-521&ltype=affiliate&SortType= total_tranpro_desc & groupsort = 1 & page = 1

Start and initialize the I2C bus using the STM32CubeMX.

I2C

Configure STM32CubeMX by setting "General peripheral Initalizion as a pair of '.c / .h' file per peripheral" in the project settings.

Copy the library header and source file to the appropriate project directories (Inc, Src).

In the head file of your project (main.c), include the header file

/ * USER CODE BEGIN Includes * /
#include "mpu6050.h"
/ * USER CODE END Includes * /

add structure to the section

/ * USER CODE BEGIN PV * /
MPU6050_t MPU6050;
/ * USER CODE END PV * /

add int main (void) to the function section

/ * USER CODE BEGIN 2 * /

while (MPU6050_Init(&hi2c1) == 1);

/ * USER CODE END 2 * /

for initial initialization of the GY-521 (MPU6050).

add int main (void) to the function section

/ * USER CODE BEGIN WHILE * /
while (1)
{
/ * USER CODE END WHILE * /

/ * USER CODE BEGIN 3 * /
  MPU6050_Read_All(&hi2c1, &MPU6050);
  HAL_Delay (100);
}
/ * USER CODE END 3 * /

On this project setup is ready. After starting the program, information from the GY-521 (MPU6050) will be available through the MPU6050 structure

MPU6050.KalmanAngleX

The Kalman filter algorithm for calculating angles is taken from the project https://github.com/TKJElectronics/KalmanFilter

Russian note

Простая библиотека на Си (STM32 HAL) для работы с модулем GY-521 (MPU6050) https://www.aliexpress.com/af/gy%25252d521.html?trafficChannel=af&d=y&CatId=0&SearchText=gy-521&ltype=affiliate&SortType=total_tranpro_desc&groupsort=1&page=1

Запустите и инициализируйте шину I2C c помощью STM32CubeMX.

I2C

Сконфигурируйте STM32CubeMX установив "General peripheral Initalizion as a pair of '.c/.h' file per peripheral" в настройках проекта.

Скопируйте заголовочный и исходный файл библиотеки в соотвесвтующие директории проекта (Inc, Src).

В головном файл вашего проекта (main.c) подключите заголовочный файл

/* USER CODE BEGIN Includes */
#include "mpu6050.h"
/* USER CODE END Includes */

в секцию добавьте структуру

/* USER CODE BEGIN PV */
MPU6050_t MPU6050;
/* USER CODE END PV */

добавьте в секцию функции int main(void)

/* USER CODE BEGIN 2 */

while (MPU6050_Init(&hi2c1) == 1);

/* USER CODE END 2 */

для начальной инициализации GY-521 (MPU6050).

добавьте в секцию функции int main(void)

/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */

/* USER CODE BEGIN 3 */
  MPU6050_Read_All(&hi2c1, &MPU6050);
  HAL_Delay(100);
}
/* USER CODE END 3 */

На этом настройка проекта готова. После запуска программы информация от GY-521 (MPU6050) будет доступна через структуру MPU6050

MPU6050.KalmanAngleX

Алгоритм фильтра Калмана для расчета углов взят из проекта https://github.com/TKJElectronics/KalmanFilter

mpu6050's People

Contributors

leech001 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.