Skip to content

Commit 3492d9f

Browse files
committed
Made it possible to set the FIFO rate divisor with a (non-mandatory) #define. jrowberg#233
Usage: #define MPU6050_DMP_FIFO_RATE_DIVISOR 99 // bring down FIFO rate to 2Hz (200/(99+1)) #include "MPU6050_6Axis_MotionApps20.h"
1 parent 27bb8b5 commit 3492d9f

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

Arduino/MPU6050/MPU6050_6Axis_MotionApps20.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,10 @@ const unsigned char dmpMemory[MPU6050_DMP_CODE_SIZE] PROGMEM = {
269269
0xB9, 0xA7, 0xF1, 0x26, 0x26, 0x26, 0xD8, 0xD8, 0xFF
270270
};
271271

272+
#ifndef MPU6050_DMP_FIFO_RATE_DIVISOR
273+
#define MPU6050_DMP_FIFO_RATE_DIVISOR 0x01
274+
#endif
275+
272276
// thanks to Noah Zerkin for piecing this stuff together!
273277
const unsigned char dmpConfig[MPU6050_DMP_CONFIG_SIZE] PROGMEM = {
274278
// BANK OFFSET LENGTH [DATA]
@@ -302,7 +306,7 @@ const unsigned char dmpConfig[MPU6050_DMP_CONFIG_SIZE] PROGMEM = {
302306
0x07, 0x46, 0x01, 0x9A, // CFG_GYRO_SOURCE inv_send_gyro
303307
0x07, 0x47, 0x04, 0xF1, 0x28, 0x30, 0x38, // CFG_9 inv_send_gyro -> inv_construct3_fifo
304308
0x07, 0x6C, 0x04, 0xF1, 0x28, 0x30, 0x38, // CFG_12 inv_send_accel -> inv_construct3_fifo
305-
0x02, 0x16, 0x02, 0x00, 0x01 // D_0_22 inv_set_fifo_rate
309+
0x02, 0x16, 0x02, 0x00, MPU6050_DMP_FIFO_RATE_DIVISOR // D_0_22 inv_set_fifo_rate
306310

307311
// This very last 0x01 WAS a 0x09, which drops the FIFO rate down to 20 Hz. 0x07 is 25 Hz,
308312
// 0x01 is 100Hz. Going faster than 100Hz (0x00=200Hz) tends to result in very noisy data.

Arduino/MPU6050/MPU6050_9Axis_MotionApps41.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,10 @@ const unsigned char dmpMemory[MPU6050_DMP_CODE_SIZE] PROGMEM = {
262262
0xDC, 0xB9, 0xA7, 0xF1, 0x26, 0x26, 0x26, 0xD8, 0xD8, 0xFF
263263
};
264264

265+
#ifndef MPU6050_DMP_FIFO_RATE_DIVISOR
266+
#define MPU6050_DMP_FIFO_RATE_DIVISOR 0x03
267+
#endif
268+
265269
const unsigned char dmpConfig[MPU6050_DMP_CONFIG_SIZE] PROGMEM = {
266270
// BANK OFFSET LENGTH [DATA]
267271
0x02, 0xEC, 0x04, 0x00, 0x47, 0x7D, 0x1A, // ?
@@ -302,9 +306,9 @@ const unsigned char dmpConfig[MPU6050_DMP_CONFIG_SIZE] PROGMEM = {
302306
0x07, 0x67, 0x01, 0x9A, // ?
303307
0x07, 0x68, 0x04, 0xF1, 0x28, 0x30, 0x38, // CFG_12 inv_send_accel -> inv_construct3_fifo
304308
0x07, 0x8D, 0x04, 0xF1, 0x28, 0x30, 0x38, // ??? CFG_12 inv_send_mag -> inv_construct3_fifo
305-
0x02, 0x16, 0x02, 0x00, 0x03 // D_0_22 inv_set_fifo_rate
309+
0x02, 0x16, 0x02, 0x00, MPU6050_DMP_FIFO_RATE_DIVISOR // D_0_22 inv_set_fifo_rate
306310

307-
// This very last 0x01 WAS a 0x09, which drops the FIFO rate down to 20 Hz. 0x07 is 25 Hz,
311+
// This very last 0x03 WAS a 0x09, which drops the FIFO rate down to 20 Hz. 0x07 is 25 Hz,
308312
// 0x01 is 100Hz. Going faster than 100Hz (0x00=200Hz) tends to result in very noisy data.
309313
// DMP output frequency is calculated easily using this equation: (200Hz / (1 + value))
310314

0 commit comments

Comments
 (0)