niru-5 / imusensor

Python library for communication between raspberry pi and MPU9250 imu
MIT License
103 stars 32 forks source link

Couple questions and issues... #6

Closed Prometheus2508 closed 3 years ago

Prometheus2508 commented 4 years ago

Line 93: Is there a reason for running self.caliberateGyro() on every begin()?

Lines 44, 52, 89: PowerManagement1 is written with ClockPLL three times. Is there a reason this is necessary that isn't evident to me?

niru-5 commented 4 years ago

Hi,

Q1) caliberateGyro() is called at the end of begin() Ans) Yes, it does. The main reason for doing this because, most of the times the gyro has an initial offset. The initial caliberation takes care of the zero offset. I do know that it won't make sense to calibrate the gyro every time whenever the application starts. So, I have given the option of loading your own calibration file after calling the begin function. See the checkingSavingAndLoadingCalibInfo.py in examples. if you don't want to load with a file but only assign gyro calib, then you can do that by assigning GyroBias variable of the imu object you have created.

Q2) Why is ClockPLL being written 3 times to PowerManagement1 register? A) The link to the register sheet of MPU9250 -> link Have a look at the register 107 in the sheet. The clock select(ClockPLL) bits in PowerManagement1 register are used for selecting the best available clock source. The PowerManagement1 register was set in the following times First time -> At the start of sensor Second time -> after setting the I2C master clock Third time -> after setting the communication with magnetometer sensor This is more like clock syncronisation after the second and third time.

I hope these answer your questions. Do let me know if you want to know more

Thanks Niru