diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index 69f51b866f..a82b3975bb 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -391,6 +391,7 @@ void setDefaultConfiguration(DECLARE_ENGINE_PARAMETER_F) { engineConfiguration->HD44780width = 20; engineConfiguration->HD44780height = 4; + engineConfiguration->alternatorOffset = 0; engineConfiguration->alternatorControlPFactor = 30; boardConfiguration->alternatorDT = 100; diff --git a/firmware/controllers/algo/engine_configuration_generated_structures.h b/firmware/controllers/algo/engine_configuration_generated_structures.h index 8a573b7389..1d92fc9a87 100644 --- a/firmware/controllers/algo/engine_configuration_generated_structures.h +++ b/firmware/controllers/algo/engine_configuration_generated_structures.h @@ -1,4 +1,4 @@ -// this section was generated by config_definition.jar on Wed May 13 20:30:29 EDT 2015 +// this section was generated by config_definition.jar on Thu May 21 19:13:37 EDT 2015 // begin #include "rusefi_types.h" typedef struct { @@ -896,7 +896,7 @@ typedef struct { /** * offset 604 */ - float unused596; + float alternatorOffset; /** * @see hasBaroSensor * offset 608 @@ -1302,4 +1302,4 @@ typedef struct { } persistent_config_s; // end -// this section was generated by config_definition.jar on Wed May 13 20:30:29 EDT 2015 +// this section was generated by config_definition.jar on Thu May 21 19:13:37 EDT 2015 diff --git a/firmware/controllers/algo/rusefi_generated.h b/firmware/controllers/algo/rusefi_generated.h index 347d43cb45..ead337464c 100644 --- a/firmware/controllers/algo/rusefi_generated.h +++ b/firmware/controllers/algo/rusefi_generated.h @@ -192,7 +192,7 @@ #define afr_v2_offset_hex 254 #define afr_value2_offset 600 #define afr_value2_offset_hex 258 -#define unused596_offset 604 +#define alternatorOffset_offset 604 #define baroSensor_offset 608 #define baroSensor_offset_hex 260 #define baroSensor_valueAt0_offset 608 diff --git a/firmware/controllers/alternatorController.cpp b/firmware/controllers/alternatorController.cpp index 7a408aab4d..d45d721a8f 100644 --- a/firmware/controllers/alternatorController.cpp +++ b/firmware/controllers/alternatorController.cpp @@ -36,7 +36,7 @@ static msg_t AltCtrlThread(int param) { while (true) { chThdSleepMilliseconds(boardConfiguration->alternatorDT); - currentAltDuty = altPid.getValue(boardConfiguration->targetVBatt, getVBatt(engineConfiguration), 1); + currentAltDuty = engineConfiguration->alternatorOffset + altPid.getValue(boardConfiguration->targetVBatt, getVBatt(engineConfiguration), 1); if (boardConfiguration->isVerboseAlternator) { scheduleMsg(logger, "alt duty: %f/vbatt=%f/p=%f/i=%f/d=%f int=%f", currentAltDuty, getVBatt(engineConfiguration), altPid.getP(), altPid.getI(), altPid.getD(), altPid.getIntegration()); @@ -57,8 +57,8 @@ void showAltInfo(void) { scheduleMsg(logger, "alt=%s @%s t=%dms", boolToString(engineConfiguration->isAlternatorControlEnabled), hwPortname(boardConfiguration->alternatorControlPin), boardConfiguration->alternatorDT); - scheduleMsg(logger, "p=%f/i=%f/d=%f", engineConfiguration->alternatorControlPFactor, - 0, 0); // todo: i & d + scheduleMsg(logger, "p=%f/i=%f/d=%f offset=%f", engineConfiguration->alternatorControlPFactor, + 0, 0, engineConfiguration->alternatorOffset); // todo: i & d scheduleMsg(logger, "vbatt=%f/duty=%f/target=%f", getVBatt(engineConfiguration), currentAltDuty, boardConfiguration->targetVBatt); } diff --git a/firmware/controllers/settings.cpp b/firmware/controllers/settings.cpp index 812355cf92..b7b4a9ec06 100644 --- a/firmware/controllers/settings.cpp +++ b/firmware/controllers/settings.cpp @@ -946,6 +946,8 @@ static void setValue(const char *paramStr, const char *valueStr) { boardConfiguration->alternatorDT = valueI; } showAltInfo(); + } else if (strEqualCaseInsensitive(paramStr, "alt_offset")) { + engineConfiguration->alternatorOffset = valueI; } else if (strEqualCaseInsensitive(paramStr, "alt_p")) { setAltPFactor(valueF); #endif diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 8385ff3fc4..39f2c1cdda 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -278,7 +278,7 @@ end_struct afr_sensor_s afr;@see hasAfrSensor - float unused596; + float alternatorOffset; air_pressure_sensor_config_s baroSensor;@see hasBaroSensor