Read IMU raw data

Read IMU raw data1.IMU Introduction2.IMU principle3.Brief analysis of IMU driver codeExperimental effect

1.IMU Introduction

The IMU used on the board is the ICM-40607 model, which is the upgraded version of MPU6050. However, compared with MPU6050, it lacks the function of four-element conversion of Euler angle. You need to write this part of function yourself. This tutorial does not provide the functions of this part. Interested students can learn from CSDN by themselves. ICM-40607: gyroscope included in it is used to measure angular velocity; Accelerometer, used to measure linear velocity.

2.IMU principle

According to the manual and schematic diagram

001

 

The following results can be obtained:

  1. IMU can be controlled by I2C protocol or SPI protocol, but the schematic diagram shows that it can only be controlled by I2C, and this experiment uses the communication mode of software I2C.
  2. The accelerometers and gyroscopes of the IMU on board are set with corresponding ranges through register configuration.
  3. The I2C address of IMU is related to the level of AD0 pin. The address of AD0=0: I2C is 0x68, and the address of AD0=1: I2C is 0x69

3.Brief analysis of IMU driver code

Initialize I2C communication

I2C read and write function

Initialize ICM40607 chip

Read raw data from the ICM40607 register.

Read data cycles and print to the serial assistant and display.

 

Experimental effect

1.When it is detected that the IMU is not online, please press the reset key and power off to restart. The effect is as shown in the figure:image-2023022700002

2.When the IMU is detected online and communication is performed, the LCD screen will display the accelerometer data, as shown in the figure:image-2023022700003 At this time, shake the development board and you can

 

Note: The program defaults to display the accelerometer value. If you need to display the gyroscope value, please find GYRO_DATA in the main.c file of the program and modify the macro definition value to 1.

image-2023022700005

Since there is an error in each IMU component, in a static state, all values will not be zero, as long as the stability and feedback are accurate.