imu drivers: do not set on-chip filter based on driver filter setting

The description of IMU_GYRO_CUTOFF was incorrectly saying that it only
affects the driver filtering, but in fact it also set the on-chip filter
to the next higher supported value. This patch fixes that.

And because the IMU_GYRO_CUTOFF and not the IMU_ACCEL_CUTOFF was used for
the on-chip filter, after #9070 which sets the default gyro filter to 80,
we were effectively using a dlpf of 98 Hz.
For this reason this patch changes the on-chip cutoff frequency to 98 as
well, so that the overall default behavior is unchanged.
This commit is contained in:
Beat Küng 2018-04-24 10:51:43 +02:00 committed by Lorenz Meier
parent fbbe1f5288
commit 4ef3d258eb
5 changed files with 9 additions and 26 deletions

View File

@ -655,14 +655,12 @@ BMI160::ioctl(struct file *filp, int cmd, unsigned long arg)
// adjust filters
float cutoff_freq_hz = _accel_filter_x.get_cutoff_freq();
float sample_rate = 1.0e6f / ticks;
_set_dlpf_filter(cutoff_freq_hz);
_accel_filter_x.set_cutoff_frequency(sample_rate, cutoff_freq_hz);
_accel_filter_y.set_cutoff_frequency(sample_rate, cutoff_freq_hz);
_accel_filter_z.set_cutoff_frequency(sample_rate, cutoff_freq_hz);
float cutoff_freq_hz_gyro = _gyro_filter_x.get_cutoff_freq();
_set_dlpf_filter(cutoff_freq_hz_gyro);
_gyro_filter_x.set_cutoff_frequency(sample_rate, cutoff_freq_hz_gyro);
_gyro_filter_y.set_cutoff_frequency(sample_rate, cutoff_freq_hz_gyro);
_gyro_filter_z.set_cutoff_frequency(sample_rate, cutoff_freq_hz_gyro);

View File

@ -815,9 +815,6 @@ int MPU6000::reset()
_set_sample_rate(_sample_rate);
usleep(1000);
// FS & DLPF FS=2000 deg/s, DLPF = 20Hz (low pass filter)
// was 90 Hz, but this ruins quality and does not improve the
// system response
_set_dlpf_filter(MPU6000_DEFAULT_ONCHIP_FILTER_FREQ);
if (is_icm_device()) {
@ -1409,19 +1406,12 @@ MPU6000::ioctl(struct file *filp, int cmd, unsigned long arg)
// adjust filters
float cutoff_freq_hz = _accel_filter_x.get_cutoff_freq();
float sample_rate = 1.0e6f / ticks;
_set_dlpf_filter(cutoff_freq_hz);
if (is_icm_device()) {
_set_icm_acc_dlpf_filter(cutoff_freq_hz);
}
_accel_filter_x.set_cutoff_frequency(sample_rate, cutoff_freq_hz);
_accel_filter_y.set_cutoff_frequency(sample_rate, cutoff_freq_hz);
_accel_filter_z.set_cutoff_frequency(sample_rate, cutoff_freq_hz);
float cutoff_freq_hz_gyro = _gyro_filter_x.get_cutoff_freq();
_set_dlpf_filter(cutoff_freq_hz_gyro);
_gyro_filter_x.set_cutoff_frequency(sample_rate, cutoff_freq_hz_gyro);
_gyro_filter_y.set_cutoff_frequency(sample_rate, cutoff_freq_hz_gyro);
_gyro_filter_z.set_cutoff_frequency(sample_rate, cutoff_freq_hz_gyro);

View File

@ -114,13 +114,13 @@
#define MPUREG_TRIM2 0x0E
#define MPUREG_TRIM3 0x0F
#define MPUREG_TRIM4 0x10
#define MPU_GYRO_DLPF_CFG_256HZ_NOLPF2 0x00
#define MPU_GYRO_DLPF_CFG_188HZ 0x01
#define MPU_GYRO_DLPF_CFG_98HZ 0x02
#define MPU_GYRO_DLPF_CFG_42HZ 0x03
#define MPU_GYRO_DLPF_CFG_20HZ 0x04
#define MPU_GYRO_DLPF_CFG_10HZ 0x05
#define MPU_GYRO_DLPF_CFG_5HZ 0x06
#define MPU_GYRO_DLPF_CFG_256HZ_NOLPF2 0x00 // delay: 0.98ms
#define MPU_GYRO_DLPF_CFG_188HZ 0x01 // delay: 1.9ms
#define MPU_GYRO_DLPF_CFG_98HZ 0x02 // delay: 2.8ms
#define MPU_GYRO_DLPF_CFG_42HZ 0x03 // delay: 4.8ms
#define MPU_GYRO_DLPF_CFG_20HZ 0x04 // delay: 8.3ms
#define MPU_GYRO_DLPF_CFG_10HZ 0x05 // delay: 13.4ms
#define MPU_GYRO_DLPF_CFG_5HZ 0x06 // delay: 18.6ms
#define MPU_GYRO_DLPF_CFG_2100HZ_NOLPF 0x07
#define MPU_DLPF_CFG_MASK 0x07
@ -210,7 +210,7 @@
#define MPU6000_GYRO_MAX_OUTPUT_RATE MPU6000_ACCEL_MAX_OUTPUT_RATE
#define MPU6000_GYRO_DEFAULT_DRIVER_FILTER_FREQ 30
#define MPU6000_DEFAULT_ONCHIP_FILTER_FREQ 42
#define MPU6000_DEFAULT_ONCHIP_FILTER_FREQ 98
#ifdef PX4_SPI_BUS_EXT
#define EXTERNAL_BUS PX4_SPI_BUS_EXT

View File

@ -462,9 +462,6 @@ int MPU9250::reset_mpu()
// SAMPLE RATE
_set_sample_rate(_sample_rate);
// FS & DLPF FS=2000 deg/s, DLPF = 20Hz (low pass filter)
// was 90 Hz, but this ruins quality and does not improve the
// system response
_set_dlpf_filter(MPU9250_DEFAULT_ONCHIP_FILTER_FREQ);
// Gyro scale 2000 deg/s ()
@ -830,14 +827,12 @@ MPU9250::ioctl(struct file *filp, int cmd, unsigned long arg)
// adjust filters
float cutoff_freq_hz = _accel_filter_x.get_cutoff_freq();
float sample_rate = 1.0e6f / ticks;
_set_dlpf_filter(cutoff_freq_hz);
_accel_filter_x.set_cutoff_frequency(sample_rate, cutoff_freq_hz);
_accel_filter_y.set_cutoff_frequency(sample_rate, cutoff_freq_hz);
_accel_filter_z.set_cutoff_frequency(sample_rate, cutoff_freq_hz);
float cutoff_freq_hz_gyro = _gyro_filter_x.get_cutoff_freq();
_set_dlpf_filter(cutoff_freq_hz_gyro);
_gyro_filter_x.set_cutoff_frequency(sample_rate, cutoff_freq_hz_gyro);
_gyro_filter_y.set_cutoff_frequency(sample_rate, cutoff_freq_hz_gyro);
_gyro_filter_z.set_cutoff_frequency(sample_rate, cutoff_freq_hz_gyro);

View File

@ -188,7 +188,7 @@
#define MPU9250_GYRO_MAX_OUTPUT_RATE MPU9250_ACCEL_MAX_OUTPUT_RATE
#define MPU9250_GYRO_DEFAULT_DRIVER_FILTER_FREQ 30
#define MPU9250_DEFAULT_ONCHIP_FILTER_FREQ 41
#define MPU9250_DEFAULT_ONCHIP_FILTER_FREQ 92
#define MPUIOCGIS_I2C (unsigned)(DEVIOCGDEVICEID+100)