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

Backport: Tools: autotest: test ICE max starter retry limit #198

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ ICE_START_CHAN,6
ICE_START_DELAY,3
ICE_STARTCHN_MIN,950
ICE_STARTER_TIME,5
ICE_STRT_MX_RTRY,5
INS_ACCEL_FILTER,10
INS_GYRO_FILTER,22
INS_HNTC2_ATT,60
Expand Down
19 changes: 17 additions & 2 deletions libraries/AP_ICEngine/AP_ICEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,13 @@ const AP_Param::GroupInfo AP_ICEngine::var_info[] = {
// @Values: 0:Forward,1:Reverse
AP_GROUPINFO("CRANK_DIR", 19, AP_ICEngine, crank_direction, 0),

// @Param: STRT_MX_RTRY
// @DisplayName: Maximum number of retries
// @Description: If set 0 then there is no limit to retrials. If set to a value greater than 0 then the engine will retry starting the engine this many times before giving up.
// @User: Standard
// @Range: 0 127
AP_GROUPINFO("STRT_MX_RTRY", 20, AP_ICEngine, max_crank_retry, 0),

AP_GROUPEND
};

Expand Down Expand Up @@ -260,6 +267,7 @@ void AP_ICEngine::update(void)
if (should_run) {
state = ICE_START_DELAY;
}
crank_retry_ct = 0;
break;

case ICE_START_HEIGHT_DELAY: {
Expand All @@ -283,8 +291,15 @@ void AP_ICEngine::update(void)
if (!should_run) {
state = ICE_OFF;
} else if (now - starter_last_run_ms >= starter_delay*1000) {
gcs().send_text(MAV_SEVERITY_INFO, "Starting engine");
state = ICE_STARTING;
// check if we should retry starting the engine
if (max_crank_retry <= 0 || crank_retry_ct < max_crank_retry) {
gcs().send_text(MAV_SEVERITY_INFO, "Starting engine");
state = ICE_STARTING;
crank_retry_ct++;
} else {
gcs().send_text(MAV_SEVERITY_INFO, "Engine max crank attempts reached");
starter_last_run_ms = now;
}
}
break;

Expand Down
6 changes: 5 additions & 1 deletion libraries/AP_ICEngine/AP_ICEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ class AP_ICEngine {
AP_Int16 pwm_ignition_off;
AP_Int16 pwm_starter_on;
AP_Int16 pwm_starter_off;


// max crank retry
AP_Int8 max_crank_retry;
int8_t crank_retry_ct;

// RPM above which engine is considered to be running
AP_Int32 rpm_threshold;

Expand Down
Loading