-
Notifications
You must be signed in to change notification settings - Fork 13.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix temperature readout for Invensense IMUs #9054
Conversation
TODO : other drivers also seem to have incorrect parameters. |
Generally a great initiative, but we need to take into consideration what the side effect will be to boards that are already calibrated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mhkabir : I think your temp sensitivity changes aren't correct. Please see my individual line comments.
src/drivers/imu/mpu9250/mpu9250.cpp
Outdated
// | ||
// Sensitivity (in degC/LSB) is from the Invensense datasheet for the specific sensor | ||
// Zero offset (in degC) varies from part to part, and this value is a good default | ||
_last_temperature = (report.temp) / 340.0f + 21.0f; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, you're right. Thanks!
src/drivers/imu/mpu6000/mpu6000.cpp
Outdated
if (is_icm_device()) { // if it is an ICM20608 | ||
_last_temperature = (report.temp) / 326.8f + 25.0f; | ||
|
||
} else { // If it is an MPU6000 | ||
_last_temperature = (report.temp) / 361.0f + 35.0f; | ||
_last_temperature = (report.temp) / 340.0f + 36.0f; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, you are indeed right. I believe I had been looking at an older version of the datasheet. Will fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know whether this sensitivity is related to a particular MPU6000 silicon revision (as in we will have to handle the temp conversion based on the silicon revision)? Or is it that there was a typo in the previous data sheets and they corrected it in the later version.
I am also not sure if I have the latest datasheets. These were the ones that I downloaded from the Invensense website, so as long as those are the most recent, then it should be alright.
src/drivers/imu/mpu6000/mpu6000.cpp
Outdated
// We calculate sensor temperature as : | ||
// temperature_real = temperature_raw * temperature_sensitivity + zero_offset | ||
// | ||
// Sensitivity (in degC/LSB) is from the Invensense datasheet for the specific sensor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the units of sensitivity not be LSB/degC?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the datasheet, yes. However, I defined it here as 1/(LSB/degC). Will make it clearer. Thanks.
b0a4b57
to
7f0becb
Compare
@ksschwabe All addressed! Thanks for the corrections! |
@LorenzMeier @dagar Options for merging this? People with current tempcal will need to recalibrate. Wish we had some form of parameter versioning so that we could reset the |
This is a tough one, especially because of how annoying it will be to redo. I suppose we could explain the correction to apply per param with release notes. I'm not sure that anyone would actually do that, but somehow it still seems better than force resetting these valuable parameters. |
This isn't great, but I have 2 ideas for making the transition acceptable.
Typically I don't think we should be trying to handle every migration, but in this case performing TC yet again is time consuming and becomes an expensive mistake. Thoughts? |
Is the effect on temperature an offset only or offset plus scale factor? If only an offset then only the *_TREF parameters for that sensor need to be adjusted by the amount of the temperature shift. |
It's both scale factor and offset. How do we identify which IMU model each
calibration is for though? Device ID?
…On Mar 15, 2018 4:40 PM, "Paul Riseborough" ***@***.***> wrote:
Is the effect on temperature an offset only or offset plus scale factor?
If only an offset then only the *_TREF parameters for that sensor need to
be adjusted by the amount of the temperature shift.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#9054 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AFTNrCeYj0hIRT_Rdvt-dQDnLz7lMB_4ks5tetGfgaJpZM4Slcsx>
.
|
@dagar Any updates here? |
At an absolute minimum we'd need to ensure incorrect temperature calibrations aren't used. Changing the device id might be an option. |
@bkueng, @priseborough, Thanks! -Mark |
My view in the short term is that we give it a new device ID and and provide users with a python script they can run that reads in the polynomial coefficients and recalculates them so that the correction is the same as suggested by @dagar However something to consider is that if the user is calibrating the sensor, then it makes more sense to apply the calibration to the data before the manufacturers compensation is applied. This is because the compensation curve provided by the manufacturer has steps in the slope which makes curve fitting harder and is likely responsible for the higher order polynomial required. I would like to see a comparison of the fit achieved with and without the manufacturers compensation. |
Device ID and Bus? |
Do the IMUs even have a manufacturer compensation? |
The manufacturer's don't provide compensation, they only provide the conversion for the ADC counts LSB to deg C... Unfortunately, the initial implementation of the driver was incorrect because the data sheet was incorrect, (@mhkabir wasn't the only one affected by data sheet revisions. :) ). In this case, I know the bug fix has a negative impact, but it feels like the bug should still simply be squashed and that it somehow feels wrong to correct the driver bug by giving it the device a new ID. Is there any way to quantify how many users this would impact and if there is a way to coordinate a fix with them? |
Not that I've seen in our currently supported IMUs, but it wouldn't surprise me. I believe Paul's referring to the ms5611 (applies to the ms5525 as well). #9267 |
As far as I can see reading through the temp calibration code, each routine is querying the respective (correct) temperature sensor for the sensor being calibrated, so although the mpu9250 accel/gyro would require recal, for factory calibrated baro/dynamic pressure sensors this pull request would have no impact. (Are there any imu's or magnetometers similar to the mpu9250/mpu6500 that have a factory cal?) |
5 days enough to resolve this issue? Let's set a goal. :) |
@mcsauder That's fair - we are better off setting expectations and timelines. |
Hi Everyone, I think I have a proposal. The 2.0.0 release appears to be coming soon, and the implication for Major version increments in the Major.Minor.Patch version methodology is the suggestion that Major version increments may/will cause backward compatibility breakage... (e.g. Python2 to Python3.) Can we introduce this fix into the 2.0.0 release understanding that it causes breakage, (and perhaps other changes will cause breakage), and everyone can understand the implications? Also, are there other backward compatibility issues that could be slated for 2.0.0? Let me know your thoughts. -Mark |
7f0becb
to
2b241de
Compare
thanks @dakejahl ! |
@dakejahl, it looks like the mpu6000 fix from this PR hasn't been applied yet. (https://github.com/PX4/Firmware/blob/29a0950753854223d144de0b7335bbcbe40ea1d4/src/drivers/imu/mpu6000/mpu6000.cpp#L1804) @mhkabir, would you be interested in rebasing/updating this PR? Let me know if I can help. |
On master. |
This fixes the temperature readout for the MPU/ICM IMUs. The sensitivity parameters were originally incorrect. This is needed for enabling the Pixhawk 2.1 IMU heater and holding a temperature set-point.