MPU6050
MotionDriver v5.1
5 Hz sampling rate
100 kHz I2C
Hi,
I've noticed that the MPU6050 *always* generates interrupts at 200 Hz despite calling mpu_set_sample_rate and dmp_set_fifo_rate with a value of 5.
Is this normal behaviour?
mpu_set_sample_rate(...) sets the variable st.chip_cfg.sample_rate
dmp_set_fifo_rate sets(...) the variable dmp.fifo_rate
but mpu_set_dmp_state(...) uses variable st.chip_cfg.dmp_sample_rate to control the MPU sample rate, and this variable is always set to 200.
st.chip_cfg.dmp_sample_rate is initialized in function mpu_load_firmware(...), which is called with 200 for the samplerate in function dmp_load_motion_driver_firmware(...) with DMP_SAMPLE_RATE = 200.
I don't need/want an interrupt every 5 ms (200 Hz) when all I need is a sample every 200 ms (5 Hz).
Is this a bug or by design, and if by design; why?
- Log in to post comments
phpbb Topic ID
15147
Re: Re: MPU6050 interrupts always at 200 Hz?
Looking at the code in more detail I think it is a bug:
In my opinion the code in inv_mpu.c, function mpu_set_dmp_state(...) should call:
/* Keep constant sample rate, FIFO rate controlled by DMP. */
mpu_set_sample_rate(st.chip_cfg.sample_rate);
instead of:
/* Keep constant sample rate, FIFO rate controlled by DMP. */
mpu_set_sample_rate(st.chip_cfg.dmp_sample_rate);
For the simple reason that mpu_get_sample_rate(...) is returning st.chip_cfg.sample_rate and NOT st.chip_cfg.dmp_sample_rate.
Please confirm.
Re: Re: MPU6050 interrupts always at 200 Hz?
Unfortunately, the change above makes the quaternion data change very slowly (it takes about a minute to get to the correct pitch/roll/yaw values when sampling at 5 Hz). I guess the DMP needs to be run at 200 Hz at all times...
What I don't understand is why interrupts are generated at 200 Hz when this is not requested by the user. If you need to keep the DMP running internally at 200 Hz then by all means, do so, but don't burden the user with 200 Hz interrupts if a much lower rate is requested.
This is a design issue, and I don't think this can be solved in the MotionDriver code (only in the firmware that is downloaded to the MPU).
Please confirm.
Re: Re: MPU6050 interrupts always at 200 Hz?
The 200 Hz interrupt you see is the Data Read HW interrupt which occurs when sensor conversion is complete. The DMP firmware image provided in the MotionDriver operates at 200 Hz, and does not override this functionality.
Re: Re: MPU6050 interrupts always at 200 Hz?
So, you're saying there is no way to lower the interrupt rate even if a (DMP) sample is needed only every 200 ms (5 Hz)?
If yes; this is a design flaw (IMHO). Will something be done to remedy this in firmware?
Re: Re: MPU6050 interrupts always at 200 Hz?
The DMP can configure a software based interrupt, but this is not used for the purpose of DMP interrupts downsampling within the MotionDriver project.
Re: Re: MPU6050 interrupts always at 200 Hz?
@sectionsbest wrote:
I have searched the forum for this question. DMP configures MPU with a sample rate of 200 (DMP_SAMPLE_RATE in dmp_load_motion_driver_firmware()). I set my DMP FIFO rate to 2 (dmp_set_fifo_rate()). My ISR is called with a rate of 200 anyway.
Is it the case that the FIFO buffer is the working memory for DMP from MPU (i.e. where DMP retrieves its values), so the FIFO-ready signal will be triggered at 200Hz, to notify DMP? But this also causing my ISR to be called each time?
Similar to the user 'developer', I only want the processed data (from DMP). Hence be only be notified when DMP data is ready. How is the proper way to retrieve each completed DMP data? Should I for example call 'dmp_read_fifo()', each ISR call (which is fired at 200Hz), and check for a return value of zero?
I use a MPU-9150, by the way...