now we use alternatorVoltageTargetTable instead of targetVBatt #6523

This commit is contained in:
kifir 2024-07-15 23:41:29 +03:00 committed by rusefillc
parent d4a2304ec1
commit 4ccf40d477
8 changed files with 19 additions and 9 deletions

View File

@ -61,6 +61,7 @@ Release template (copy/paste this for new release):
- critical error in case of unneeded second channel #6419
- Open Loop Boost vertical axis needs to be configured #4778
- Cranking Cycle Multiplier is now a Map with Coolant Temp as the additional axis. #6584
- Now we use "Alternator Voltage Target Table" instead of "Target(Volts)" setting on "Alternator Settings" area to calculate alternator voltage target. #6523
## Unreleased

View File

@ -152,7 +152,7 @@ void setDodgeNeonNGCEngineConfiguration() {
setAlgorithm(LM_SPEED_DENSITY);
//temp engineConfiguration->alternatorControlPin = Gpio::D5;
engineConfiguration->targetVBatt = 14.0;
setTable(config->alternatorVoltageTargetTable, 14.0);
engineConfiguration->alternatorControl.offset = 20;
engineConfiguration->alternatorControl.pFactor = 20;
engineConfiguration->alternatorControl.iFactor = 0.2;

View File

@ -12,6 +12,7 @@
#include "mazda_miata_na8.h"
#include "custom_engine.h"
#include "mazda_miata_1_6.h"
#include "table_helper.h"
void setMazdaMiata96() {
miataNAcommonEngineSettings();
@ -42,7 +43,7 @@ void setMazdaMiata96() {
engineConfiguration->useIdleTimingPidControl = true;
engineConfiguration->wwaeTau = 0.1;
engineConfiguration->targetVBatt = 14.2;
setTable(config->alternatorVoltageTargetTable, 14.2);
engineConfiguration->crankingIACposition = 36;
engineConfiguration->afterCrankingIACtaperDuration = 189;

View File

@ -292,7 +292,7 @@ static void setCommonMazdaNB() {
// Alternator
engineConfiguration->isAlternatorControlEnabled = true;
engineConfiguration->targetVBatt = 14.0f;
setTable(config->alternatorVoltageTargetTable, 14.0f);
engineConfiguration->alternatorControl.offset = 20;
engineConfiguration->alternatorControl.pFactor = 16;
engineConfiguration->alternatorControl.iFactor = 8;

View File

@ -38,14 +38,21 @@ expected<float> AlternatorController::observePlant() {
}
expected<float> AlternatorController::getSetpoint() {
const float rpm = Sensor::getOrZero(SensorType::Rpm);
// check if the engine is not running
bool alternatorShouldBeEnabledAtCurrentRpm = Sensor::getOrZero(SensorType::Rpm) > engineConfiguration->cranking.rpm;
bool alternatorShouldBeEnabledAtCurrentRpm = rpm > engineConfiguration->cranking.rpm;
if (!engineConfiguration->isAlternatorControlEnabled || !alternatorShouldBeEnabledAtCurrentRpm) {
return unexpected;
}
return engineConfiguration->targetVBatt;
const float load = getEngineState()->fuelingLoad;
return interpolate3d(
config->alternatorVoltageTargetTable,
config->alternatorVoltageTargetLoadBins, load,
config->alternatorVoltageTargetRpmBins, rpm
);;
}
expected<percent_t> AlternatorController::getOpenLoop(float target) {

View File

@ -10,7 +10,7 @@
#if EFI_ALTERNATOR_CONTROL
static void setDefaultAlternatorParameters() {
engineConfiguration->targetVBatt = 14;
setTable(config->alternatorVoltageTargetTable, 14);
engineConfiguration->alternatorControl.offset = 0;
engineConfiguration->alternatorControl.pFactor = 30;

View File

@ -756,7 +756,7 @@ static void setValue(const char *paramStr, const char *valueStr) {
setVssPin(valueStr);
#endif // EFI_PROD_CODE
} else if (strEqualCaseInsensitive(paramStr, "targetvbatt")) {
engineConfiguration->targetVBatt = valueF;
setTable(config->alternatorVoltageTargetTable, valueF);
} else if (strEqualCaseInsensitive(paramStr, CMD_DATE)) {
// rusEfi console invokes this method with timestamp in local timezone
setDateTime(valueStr);

View File

@ -8,7 +8,8 @@ using ::testing::Return;
TEST(Alternator, TestSetPoint) {
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
engineConfiguration->targetVBatt = 14.2f;
const float TEST_ALTERNATOR_VOLTAGE_TARGET = 14.2f;
setTable(config->alternatorVoltageTargetTable, TEST_ALTERNATOR_VOLTAGE_TARGET);
engineConfiguration->cranking.rpm = 500;
engineConfiguration->isAlternatorControlEnabled = true;
@ -20,7 +21,7 @@ TEST(Alternator, TestSetPoint) {
Sensor::setMockValue(SensorType::Rpm, 501);
// enabled!
EXPECT_EQ(engineConfiguration->targetVBatt, dut.getSetpoint().value_or(-1));
EXPECT_EQ(TEST_ALTERNATOR_VOLTAGE_TARGET, dut.getSetpoint().value_or(-1));
engineConfiguration->isAlternatorControlEnabled = false;
// disabled manually