-
Notifications
You must be signed in to change notification settings - Fork 16.8k
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
Conversation
This seems reasonable to me.. |
433f032
to
2402a92
Compare
@@ -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 |
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.
interesting that this time out is different vs copters timeout.
2402a92
to
f2aa2dd
Compare
@@ -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; |
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.
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.
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.
LIMIT
is kind of inferred by MIN
:-)
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.
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) { |
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.
I'd just like to point out here that we are arguably mixing up pwm inputs with output...
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.
need comment on button options explaining what happens above and below thresholds
f2aa2dd
to
6ca1829
Compare
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.