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

Airspeed: Sanity check MS4525DO data, and utilize a double read #5950

Merged
merged 1 commit into from
Apr 1, 2017

Conversation

WickedShell
Copy link
Contributor

It is possible to get a really incorrect data read off the I2C bus, that will come out with either wildly different numbers or a maximum value. Given that this is an incredibly illogical input for airspeed data, we are better off rejecting the data.

To do this we double read the sensor data, the measurements will drift slightly between two readings, but not enough that the upper byte will undergo a change. We also check that no reading was the maximum or minimum value possible.

This needs to be flight tested to ensure that we don't reject to many valid reasons, but given the required rate of change that should be fine.

The image below shows a rejected bad double read. Channel 0 is SDA, Channel 1 is SCL. Notice that the second read gets really bad data off the SCL line, which results in an erroneous read on the Pixhawk. The double pulse on channel 2 indicates that the check on line 143 failed. In this case our second reading was bad, but it can easily be the other way around as well.

rejected-bad-double-read

@tridge
Copy link
Contributor

tridge commented Mar 29, 2017

looks good to me, thanks michael!
just needs a flight test

Copy link
Member

@OXINARF OXINARF left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WickedShell Nitpicking your words again, sorry 😄

Other than my small comments, LGTM.

dT_raw2 = (data2[2] << 8) + data2[3];
dT_raw2 = (0xFFE0 & dT_raw2) >> 5;

// reject any values that are the absolute minum or maximums
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minum -> minimum

dT_raw2 = (0xFFE0 & dT_raw2) >> 5;

// reject any values that are the absolute minum or maximums
// these can happen due to gnd lifts or communication erros on the bus
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

erros -> errors

return;
}

// reject any double reads where the value has shifted in the upper more then a byte as corrupted
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sentence looks like a mix of two. I would change it to:

reject any double reads where the values have a difference bigger than 255 (one lower byte)

}

// reject any double reads where the value has shifted in the upper more then a byte as corrupted
if (abs(dp_raw - dp_raw2) >= 0xFF || abs(dT_raw - dT_raw2) > 0xFF) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why one uses >= and the other >? In my opinion should be only >

@WickedShell
Copy link
Contributor Author

@OXINARF you might convince me to find a spell checking plugin for vim... :)

@WickedShell WickedShell force-pushed the wickedshell/ms4525do-bad-data branch from 69c9ac0 to b312d50 Compare March 30, 2017 06:54
@WickedShell
Copy link
Contributor Author

WickedShell commented Mar 31, 2017

Flight tested to 20 m/s, worked quite well no periods of data outages, or visible anomalous readings.

EDIT: Was also flight tested with the I2C DNF patch.

@tridge tridge merged commit 4932a8b into ArduPilot:master Apr 1, 2017
@tridge
Copy link
Contributor

tridge commented Apr 1, 2017

applied, thanks Michael!

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