my project is a wireless sensor network that wake-up every 10 minutes. At every wake-up, I read IMU data from bmx160 where all the sensors (acc, gyro and mag) are in normal power mode. During the sleep state, I would like to switch these power modes to suspend mode. Reading the datasheet, page 16 tab 8, I cannot perform a diagonal transition but only vertical or horizontal ones between accelerometer power modes and gyroscope power modes. So, I act as follow:
/* switch to normal mode (pwr) */ /* Select the power mode */ sensor.accel_cfg.power = BMX160_ACCEL_NORMAL_MODE; /* Set the Power mode */ rslt = bmx160_set_power_mode(&sensor); sensor.gyro_cfg.power = BMX160_GYRO_NORMAL_MODE; /* Set the Power mode */ rslt = bmx160_set_power_mode(&sensor); sensor.mag_cfg.power = BMX160_MAG_NORMAL_MODE; /* Set the Power mode */ rslt = bmx160_set_power_mode(&sensor);
and, after the acquisition, the opposite from normal to suspend mode. In this way, I get incorrect data or even all zeros.
I also tried to do this change all in one:
sensor.accel_cfg.power = BMX160_ACCEL_NORMAL_MODE; sensor.gyro_cfg.power = BMX160_GYRO_NORMAL_MODE; sensor.mag_cfg.power = BMX160_MAG_NORMAL_MODE; rslt = bmx160_set_power_mode(&sensor);
but I have the same problems as above.
How can I perform this?
Thanks for your inquiry.
Afteryou set BMX160 accel, gyro and mag to normal mode, are you getting the correct data?
After you set BMX160 accel, gyro and mag back to suspend mode, the sensors will not take any measurements. So you are supposed to get all zeros or the last measurements from these sensors' data registers because the data registers will not be updated any more. Please refer to BMI160 + BMM150 API source code examples online at https://github.com/BoschSensortec/BMI160_driver for more information.
after putting BMX160 back to normal mode I get incorrect data (all zeros).
What I want to do is:
Actually, after several tests, I get correct data from accel and gyro switching the power mode but to gain this I must wait a ~60ms after change power mode of gyro otherwise its first data are all 0s.
What I do is:
sensor.accel_cfg.power = BMX160_ACCEL_NORMAL_MODE; sensor.gyro_cfg.power = BMX160_GYRO_NORMAL_MODE; /* Set the Power mode */ rslt = bmx160_set_power_mode(&sensor); CPUdelay(970000);
If I add the power switching for the magnetometer I get 0 from it. For mag power mode I did the same:
sensor.mag_cfg.power = BMX160_MAG_NORMAL_MODE; /* Set the Power mode */ rslt = bmx160_set_power_mode(&sensor);
Is there any particular way to perform it? Moreover is it correct to wait 60ms after the gyroscope power mode changing and why I should wait for it?
On page 90 of BMX160 datasheet the typical and max delay time are defined when switching to normal mode for accel, gyro and mag. To be safe, you can add delay of 5ms for accel when switching from suspend mode to normal mode, 100ms for gyro and 2ms for mag.
The reason why gyro needs longer delay time is gyro has internal oscillating MEMS structure to sense the Coriolis acceleration and it takes time for it to stabilize and get the ADC ready for measurement. If you read gyro data within the delay time, then you may get all zeros back because it is not ready yet. Same to accel and mag.