Low Pass Filter with MPU6500 on Due

Hello Guys,

I need you help with implementing a LPF on the MPU6500. I know there are 6 modes for the filter but I do not know how to implement it in the code. What line to add to activate it

Can you please help me with the right line to place in my sketch to make it work?

Thanks,
Yossi

The two left columns refer to possible values you can write to part of register 29 - ACCEL_CONFIG_2. Within this register, there are fields by the name of ACCEL_FCOICE_B and A_DLPF_CFG (1 and 3 bits wide - respectively). What you do is this:

  1. Pick the values you want for each of these fields
  2. Write those values to the accelerometer using the standard I2C protocol with Wire.h.

The address for the data you are writing to the MPU will be 0x1D (in hex). This corresponds to register 29 since 29 = 0x1D. Also, remember to account for the 4 bits in ACCEL_CONFIG_2 that come before the two fields ACCEL_FCOICE_B and A_DLPF_CFG.

On how to pick the LPF values: You’ll have to ask more specific questions to get the right answers.

P.S. Posting your code wouldn’t hurt either.

Thanks PB,

I am still waiting for the MPU6500 to arrive by mail but the code I wanted to cannibalize it here
http://www.cs.cmu.edu/~cga/arduino/mpu6500-spi.ino

I need to talk to the SPU6500 in SPI protocol since I already use that to talk with the SD card.

I need to use the values ACCEL_FCOICE_B = 0 & A_DLPF_CFG = 3.

I have seen this phrase used
"#define ACCEL_CONFIG_2 0x1D "

But how do place the value into the ACCEL_CONFIG_2 ?

4 first bits 0000
ACCEL_FCOICE_B 0
A_DLPF_CFG 0011

is the value I need to use is 000000011 ??

Thanks for the help, as you can see I am not a programmer, my job is to activate IO on the input from the accelerometer and I used an analog one so it was easy. now I need a more accurate one and I need to move to the MPU6500.

Thanks for the help,
Yossi

pcyossi:
I need to talk to the SPU6500 in SPI protocol since I already use that to talk with the SD card.

Ok, cool. For now, use I2C and the Wire.h library to update the register contents and then use SPI to read the data registers. Know what I mean?

There is a way to doing it with the library SPI.h, but I’ve never used SPI on Arduinos (used it on a PIC32 once, though :wink: ).

IMPORTANT: You will also need to “wake up” the accelerometer by updating the power management register in the same manner as the registers this post is about. You can read about it in the datasheet.

pcyossi:
4 first bits 0000
ACCEL_FCOICE_B 0
A_DLPF_CFG 0011

is the value I need to use is 000000011 ??

Close, but no, A_DLPF_CFG is only 3 bits wide. Your final value has to be 8 bits, since all registers are 8 bits wide.

Your REAL value: 00000011

pcyossi:
I have seen this phrase used
"#define ACCEL_CONFIG_2 0x1D "

But how do place the value into the ACCEL_CONFIG_2 ?

The #define phrase makes a permanent variable named “ACCEL_CONFIG_2” with a read only value of 0x1D. This allows you to use the register name “ACCEL_CONFIG_2” instead of having to use the actual address (0xD1). In short, it makes your code easier to understand.

How you do it in I2C with the Wire.h library:

  #define MPU6500_ADDRESS (insert I2C device address here)
  #define ACCEL_CONFIG_2 0x1D

  Wire.beginTransmission(MPU6500_ADDRESS);
  Wire.write(ACCEL_CONFIG_2);
  Wire.write(0x3);                      //00000011 = 0x3 (binary to hex)
  Wire.endTransmission();