Skip to content
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

mpu9250: fix mag spikes on fmu-v4pro #13353

Merged
merged 1 commit into from
Nov 2, 2019
Merged

mpu9250: fix mag spikes on fmu-v4pro #13353

merged 1 commit into from
Nov 2, 2019

Conversation

julianoes
Copy link
Contributor

This should fix spikes in the mag data on MPU9250 found inside Drotek Pixhawk 3Pro.

The problem turned out to be that we are not checking the DRDY bit before reading the data. We presumably threw away most of the stale data by doing a duplicate check, however, sometimes we might have run into a race where the mag data was already being updated in the chip while
still being read.

Before merging we should make sure this doesn't break other boards or external GPS/mag with MPU9250.

This was the spikes I could see:
Selection_066

I'm not sure if this is related to the mag values seen in this log:
https://review.px4.io/plot_app?log=49829594-e88e-4f85-8740-6b2f7bf87c47&fbclid=IwAR1vs4sYoGntIlDX6kiA_58IYzI2y26o6n-Zo_7NfdaaunZl9lXonkU9zls

@julianoes
Copy link
Contributor Author

@Tony3dr please collect a log just on the bench like done in #13294 (comment) and check if the mag spikes are still happening.

This should fix spikes in the mag data on MPU9250 found inside Drotek
Pixhawk 3Pro.

The problem turned out to be that we are not checking the DRDY bit
before reading the data. We presumably threw away most of the stale data
by doing a duplicate check, however, sometimes we might have run into a
race where the mag data was already being updated in the chip while
still being read.
@dannyfpv
Copy link

dannyfpv commented Nov 1, 2019

Tested on Pixhawk v4pro
Notes
We tested this PR in position mode just let the vehicle hover for a few mins. Did the RTL to see of the vehicle would disarm upon landing. The vehicle did not disarm when landing, had to manually disarm.
log:
https://review.px4.io/plot_app?log=7cfbea02-beef-4007-96c0-9c89849312ee
https://review.px4.io/plot_app?log=8462e502-a4a3-4960-b5eb-05a9b0db6508

@dagar
Copy link
Member

dagar commented Nov 2, 2019

The primary mag on that vehicle (not an mpu9250) is quite bad.

image

@dagar
Copy link
Member

dagar commented Nov 2, 2019

The internal mag (mpu9250) vs external (lis3mdl).

1

2

3

@dagar
Copy link
Member

dagar commented Nov 2, 2019

This PR looks good, but separately I think we need to review that test vehicle.

@dagar dagar merged commit a08abcc into master Nov 2, 2019
@dagar dagar deleted the fix-mag-spikes branch November 2, 2019 16:49
@julianoes
Copy link
Contributor Author

@dagar I could not reproduce the spikes that are plotted above, not sure how to do that.

@LorenzMeier
Copy link
Member

@julianoes These look like real data (the magnetic field actually changing) and affect multiple sensors on multiple buses synchronously. I suspect its the exact wiring / power setup of that vehicle that you need to create that.

@julianoes
Copy link
Contributor Author

@LorenzMeier you're right. We already ruled out ESCs/motors because the noise was still present disarmed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants