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

AP_Button: range check PWM input #20070

Merged
merged 4 commits into from
Feb 28, 2022
Merged

Conversation

IamPete1
Copy link
Member

Checks a for a valid value before triggering aux function. Stops miss triggering, this is a change in behavior.

We might want a option to trigger high or low on invalid signal in the future. We might also want to add some HAL functionality to check how recent the last PWM reading is. Currently we cannot tell if the signal stops dead, it needs a full cycle to trigger and will just repeat the last reading forever if that stops.

@rmackay9
Copy link
Contributor

This seems reasonable to me..

tridge
tridge previously requested changes Feb 15, 2022
libraries/AP_Button/AP_Button.cpp Outdated Show resolved Hide resolved
@@ -7,8 +7,6 @@
*/

// motor test definitions
#define MOTOR_TEST_PWM_MIN 800 // min pwm value accepted by the test
#define MOTOR_TEST_PWM_MAX 2200 // max pwm value accepted by the test
#define MOTOR_TEST_TIMEOUT_MS_MAX 30000 // max timeout is 30 seconds
Copy link
Member Author

Choose a reason for hiding this comment

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

interesting that this time out is different vs copters timeout.

@@ -281,7 +281,7 @@ class RC_Channel {
const char *string_for_aux_function(AUX_FUNC function) const;
#endif
// pwm value under which we consider that Radio value is invalid
static const uint16_t RC_MIN_LIMIT_PWM = 900;
static const uint16_t RC_MIN_LIMIT_PWM = 800;
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks OK but I can't resist saying that this constant's name should really be, "RC_PWM_LIMIT_MIN". Wouldn't that be better? Anyway, no need to change it I just want to pass on my naming wisdom.

Copy link
Contributor

Choose a reason for hiding this comment

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

LIMIT is kind of inferred by MIN :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, removing the LIMIT part would also be a fine change.. but not today I'm sure..

@@ -68,7 +66,7 @@ void QuadPlane::motor_test_output()
}

// sanity check throttle values
if (pwm >= MOTOR_TEST_PWM_MIN && pwm <= MOTOR_TEST_PWM_MAX ) {
if (pwm >= RC_Channel::RC_MIN_LIMIT_PWM && pwm <= RC_Channel::RC_MAX_LIMIT_PWM) {
Copy link
Contributor

@rmackay9 rmackay9 Feb 15, 2022

Choose a reason for hiding this comment

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

I'd just like to point out here that we are arguably mixing up pwm inputs with output...

@rmackay9 rmackay9 added the WikiNeeded needs wiki update label Feb 22, 2022
Copy link
Contributor

@tridge tridge left a comment

Choose a reason for hiding this comment

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

need comment on button options explaining what happens above and below thresholds

libraries/AP_Button/AP_Button.cpp Outdated Show resolved Hide resolved
@tridge tridge merged commit a47445b into ArduPilot:master Feb 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WikiNeeded needs wiki update
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants