rusefi/firmware/controllers/actuators/harley_acr.cpp

71 lines
2.1 KiB
C++
Raw Normal View History

// Controller for Harley Davidson Automatic Compression Release
//
// To make the starter's job easier, these bike engines have a solenoid
// that dumps cylinder pressure to atmosphere until the engine is spinning
// fast enough to actually have a chance at starting.
// We open the valve the instant the engine starts moving, then close it
2023-11-11 14:36:42 -08:00
// once the specified number of revolutions have occurred, plus some engine phase.
// This allows the valve to close at just the right moment that you don't get a
// weird half-charge if it closed mid way up on a compression stroke.
#include "pch.h"
2023-10-31 05:56:16 -07:00
#if EFI_HD_ACR
static bool getAcrState() {
2023-11-13 14:23:32 -08:00
bool engineMovedRecently = getTriggerCentral()->engineMovedRecently();
engine->engineState.acrEngineMovedRecently = engineMovedRecently;
auto currentPhase = getTriggerCentral()->getCurrentEnginePhase(getTimeNowNt());
if (!currentPhase) {
2023-11-13 14:23:32 -08:00
return engineMovedRecently;
}
// Turn off the valve if the engine isn't moving - no sense wasting power on a stopped engine
2023-11-13 14:23:32 -08:00
if (!engineMovedRecently) {
return false;
}
int revCount = getTriggerCentral()->triggerState.getCrankSynchronizationCounter();
if (revCount > engineConfiguration->acrRevolutions) {
// Enough revs have elapsed that we're done with ACR
return false;
} else if (revCount == engineConfiguration->acrRevolutions) {
float wrappedPhase = currentPhase.Value > 360 ? currentPhase.Value - 360 : currentPhase.Value;
// We're on the rev where ACR should be disabled part way through
if (wrappedPhase > engineConfiguration->acrDisablePhase) {
return false;
} else {
// Not enough phase elapsed, ACR still active
return true;
}
} else {
// ACR active - not enough revs completed
return true;
}
}
void HarleyAcr::onSlowCallback() {
// skip if no pin
if (!isBrainPinValid(engineConfiguration->acrPin)) {
m_active = false;
return;
}
bool acrState = getAcrState();
engine->engineState.acrActive = acrState;
enginePins.harleyAcr.setValue(acrState);
2023-03-05 18:19:57 -08:00
enginePins.harleyAcr2.setValue(acrState);
m_active = acrState;
}
2023-11-13 14:23:32 -08:00
void HarleyAcr::updateAcr() {
onSlowCallback();
}
bool HarleyAcr::isActive() const {
return m_active;
}
2023-10-31 05:56:16 -07:00
#endif // EFI_HD_ACR