cmd_test_main_relay

This commit is contained in:
rusefillc 2021-01-10 23:46:50 -05:00
parent b2f715ef32
commit 4416d1c7dc
5 changed files with 27 additions and 12 deletions

View File

@ -524,7 +524,7 @@ void Engine::watchdog() {
efitick_t nowNt = getTimeNowNt();
// note that we are ignoring the number of tooth here - we
// check for duration between tooth as if we only have one tooth per revolution which is not the case
#define REVOLUTION_TIME_HIGH_THRESHOLD (60 * 1000000LL / RPM_LOW_THRESHOLD)
#define REVOLUTION_TIME_HIGH_THRESHOLD (60 * US_PER_SECOND_LL / RPM_LOW_THRESHOLD)
/**
* todo: better watch dog implementation should be implemented - see
* http://sourceforge.net/p/rusefi/tickets/96/
@ -575,6 +575,13 @@ void Engine::checkShutdown(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
#endif /* EFI_MAIN_RELAY_CONTROL */
}
bool Engine::isInMainRelayBench(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
if (mainRelayBenchStartNt == 0) {
return false;
}
return (getTimeNowNt() - mainRelayBenchStartNt) < NT_PER_SECOND;
}
bool Engine::isInShutdownMode(DECLARE_ENGINE_PARAMETER_SIGNATURE) const {
#if EFI_MAIN_RELAY_CONTROL
// if we are in "ignition_on" mode and not in shutdown mode
@ -591,21 +598,21 @@ bool Engine::isInShutdownMode(DECLARE_ENGINE_PARAMETER_SIGNATURE) const {
return false;
}
const efitick_t turnOffWaitTimeoutUs = 1LL * 1000000LL;
const efitick_t turnOffWaitTimeoutNt = NT_PER_SECOND;
// We don't want any transients to step in, so we wait at least 1 second whatever happens.
// Also it's good to give the stepper motor some time to start moving to the initial position (or parking)
if ((getTimeNowNt() - stopEngineRequestTimeNt) < US2NT(turnOffWaitTimeoutUs))
if ((getTimeNowNt() - stopEngineRequestTimeNt) < turnOffWaitTimeoutNt)
return true;
const efitick_t engineSpinningWaitTimeoutUs = 5LL * 1000000LL;
const efitick_t engineSpinningWaitTimeoutNt = 5 * NT_PER_SECOND;
// The engine is still spinning! Give it some time to stop (but wait no more than 5 secs)
if (isSpinning && (getTimeNowNt() - stopEngineRequestTimeNt) < US2NT(engineSpinningWaitTimeoutUs))
if (isSpinning && (getTimeNowNt() - stopEngineRequestTimeNt) < engineSpinningWaitTimeoutNt)
return true;
// The idle motor valve is still moving! Give it some time to park (but wait no more than 10 secs)
// Usually it can move to the initial 'cranking' position or zero 'parking' position.
const efitick_t idleMotorWaitTimeoutUs = 10LL * 1000000LL;
if (isIdleMotorBusy(PASS_ENGINE_PARAMETER_SIGNATURE) && (getTimeNowNt() - stopEngineRequestTimeNt) < US2NT(idleMotorWaitTimeoutUs))
const efitick_t idleMotorWaitTimeoutNt = 10 * NT_PER_SECOND;
if (isIdleMotorBusy(PASS_ENGINE_PARAMETER_SIGNATURE) && (getTimeNowNt() - stopEngineRequestTimeNt) < idleMotorWaitTimeoutNt)
return true;
#endif /* EFI_MAIN_RELAY_CONTROL */
return false;

View File

@ -321,6 +321,7 @@ public:
EngineState engineState;
SensorsState sensors;
efitick_t lastTriggerToothEventTimeNt = 0;
efitick_t mainRelayBenchStartNt = 0;
/**
@ -358,6 +359,8 @@ public:
*/
bool isInShutdownMode(DECLARE_ENGINE_PARAMETER_SIGNATURE) const;
bool isInMainRelayBench(DECLARE_ENGINE_PARAMETER_SIGNATURE);
/**
* The stepper does not work if the main relay is turned off (it requires +12V).
* Needed by the stepper motor code to detect if it works.

View File

@ -198,7 +198,8 @@ void acRelayBench(void) {
}
void mainRelayBench(void) {
pinbench("0", "1000", "100", "1", &enginePins.mainRelay, CONFIG(mainRelayPin));
// main relay is usually "ON" via FSIO thus bench testing that one is pretty unusual
engine->mainRelayBenchStartNt = getTimeNowNt();
}
void hpfpValveBench(void) {

View File

@ -71,7 +71,7 @@ static LENameOrdinalPair leExhaustVVT(LE_METHOD_EXHAUST_VVT, "evvt");
static LENameOrdinalPair leCrankingRpm(LE_METHOD_CRANKING_RPM, "cranking_rpm");
static LENameOrdinalPair leStartupFuelPumpDuration(LE_METHOD_STARTUP_FUEL_PUMP_DURATION, "startup_fuel_pump_duration");
static LENameOrdinalPair leInShutdown(LE_METHOD_IN_SHUTDOWN, "in_shutdown");
static LENameOrdinalPair leInMrBench(LE_METHOD_IN_SHUTDOWN, "in_mr_bench");
static LENameOrdinalPair leInMrBench(LE_METHOD_IN_MR_BENCH, "in_mr_bench");
static LENameOrdinalPair leTimeSinceTrigger(LE_METHOD_TIME_SINCE_TRIGGER_EVENT, "time_since_trigger");
#include "fsio_names.def"
@ -158,6 +158,8 @@ FsioResult getEngineValue(le_action_e action DECLARE_ENGINE_PARAMETER_SUFFIX) {
return engineConfiguration->cranking.rpm;
case LE_METHOD_IN_SHUTDOWN:
return engine->isInShutdownMode();
case LE_METHOD_IN_MR_BENCH:
return engine->isInMainRelayBench();
case LE_METHOD_VBATT:
return getVBatt(PASS_ENGINE_PARAMETER_SIGNATURE);
case LE_METHOD_TPS:
@ -377,9 +379,11 @@ static const char * action2String(le_action_e action) {
case LE_METHOD_FAN:
return "fan";
case LE_METHOD_STARTUP_FUEL_PUMP_DURATION:
return "startup_fuel_pump_duration";
return leStartupFuelPumpDuration.name;
case LE_METHOD_IN_SHUTDOWN:
return "in_shutdown";
return leInShutdown.name;
case LE_METHOD_IN_MR_BENCH:
return leInMrBench.name;
#include "fsio_strings.def"
default: {

View File

@ -3285,7 +3285,7 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
dialog = testMisc, "Misc"
; commandButton = "Come To Pit", cmd_call_from_pit
commandButton = "Main Relay", cmd_test_main_relay
commandButton = "Main Relay", cmd_test_main_relay@@if_ts_show_main_relay
commandButton = "Fuel Pump", cmd_test_fuel_pump
commandButton = "Radiator Fan", cmd_test_radiator_fan
commandButton = "Check Engine", cmd_test_check_engine_light