HANcoder/Training Material/MPU6500

From OpenMBD
Jump to: navigation, search

MPU6500 3 Axis gyro and 3 axis accelerometer

The MPU6500 has a programmable scale for both the gyroscope and the accelerometer. It can measure angular rates up to 2000°/sec and up to 16G of acceleration. The sensor can be configured and read by using the SPI bus.

Connecting the MPU6500

First the MPU6500 must be soldered on the prototype PCB. It is wise to solder some female headers onto the PCB and male headers onto the MPU6500 so it can be replaced when broken. Make sure it is mounted ruggedly to make sure the sensor won't measure movements of the sensor relative to the board. Next the pins must be connected to the E407 pins, see the connection diagram below.

File:ConnectionDiagram.png


SPI control in Simulink

As mentioned before the communication with the sensor is done via SPI. First the SPI Master Init block is used to initialize the SPI system. Channel 1 is chosen with a baud rate of 656.25kHz because the datasheet states that the maximum SPI clock frequency is 1Mhz. The polarity is chosen to be 'Idle low' and phase 'Sample bit on 1st clock edge', these settings also come from the datasheet of the MPU6500.
MPU6500 SPIsettings.png