DFRobot / DFRobot_BMI160

MIT License
25 stars 22 forks source link

Another minor correction: sampling frequency bottleneck #2

Open renr3 opened 6 years ago

renr3 commented 6 years ago

Hello guys. While playing with the sensor and this library, I noticed that changing the ODR settings did not have any impact in the overall behaviour of the sensor: I was able to only get a maximum sampling frequency around 50 Hz (or around it, can't remember the correct value). Going back to the .cpp file, I tracked down the methods used to get the acceleration values from the sensors. Ultimately, we arrive at the method getRegs, which I assume assess the sensor registers containing the acceleration values. There, I noticed a couple of delays (10 milliseconds and 1 milliseconds), which would be repeated each reading. I considered this as the bottleneck for the sampling frequency I was experiencing. From another sensor library, I recall reading a discussion about reducing delays needed for registers reading. I proceeded to change all delay() fucntions to delayMicrosseconds(). I adjusted all of them to 1 microseconds and observed consistent behaviour in the measured accelerations. Therefore, I proposed to each one assess the best values if experiencing insufficient sampling frequency values. I don't know all the implications of changing such values, so if anyone knows a counterpoint to that, please share with us!

tuandle commented 5 years ago

@renr3 Thanks for the tip. I follow your suggestion. However, I can only get the output rate at 200Hz, not 100Hz or other legal ODR values. Do you know what might cause this?