From 3d9126ec4ae3c0c179a4b773ad2c75e56731e96b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 18 Jun 2018 18:11:29 +1000 Subject: [PATCH] AP_Compass: run lsm303d at 91Hz, not 100Hz Peter and I have discovered an odd behaviour with the lsm303d mag. If you fetch data a bit too soon then it will give a peridic oscillation in the output. Checking the data ready bit in the status register doesn't help. The only fix I've found is to run the sampling at a bit lower rate --- libraries/AP_Compass/AP_Compass_LSM303D.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/AP_Compass/AP_Compass_LSM303D.cpp b/libraries/AP_Compass/AP_Compass_LSM303D.cpp index 4248b6f963..b6e7375893 100644 --- a/libraries/AP_Compass/AP_Compass_LSM303D.cpp +++ b/libraries/AP_Compass/AP_Compass_LSM303D.cpp @@ -273,8 +273,9 @@ bool AP_Compass_LSM303D::init(enum Rotation rotation) _dev->set_device_type(DEVTYPE_LSM303D); set_dev_id(_compass_instance, _dev->get_bus_id()); - // read at 100Hz - _dev->register_periodic_callback(10000, FUNCTOR_BIND_MEMBER(&AP_Compass_LSM303D::_update, void)); + // read at 91Hz. We don't run at 100Hz as fetching data too fast can cause some very + // odd periodic changes in the output data + _dev->register_periodic_callback(11000, FUNCTOR_BIND_MEMBER(&AP_Compass_LSM303D::_update, void)); return true; }