diff --git a/firmware/config/engines/dodge_neon.cpp b/firmware/config/engines/dodge_neon.cpp index 94a445cfcd..00383aa252 100644 --- a/firmware/config/engines/dodge_neon.cpp +++ b/firmware/config/engines/dodge_neon.cpp @@ -198,8 +198,8 @@ void setDodgeNeonNGCEngineConfiguration(engine_configuration_s *engineConfigurat engineConfiguration->vbattDividerCoeff = ((float) (8.2 + 33)) / 8.2 * 2; // Frankenso low out #1: PE6 - // Frankenso low out #2: PE5 coolant fan relay - // Frankenso low out #3: PD7 + // Frankenso low out #2: PE5 + // Frankenso low out #3: PD7 coolant fan relay // Frankenso low out #4: PC13 idle valve solenoid // Frankenso low out #5: PE3 fuel pump relay // Frankenso low out #6: PE4 @@ -210,7 +210,7 @@ void setDodgeNeonNGCEngineConfiguration(engine_configuration_s *engineConfigurat // Frankenso low out #11: PB8 injector #1 // Frankenso low out #12: PB7 injector #4 - boardConfiguration->fanPin = GPIOE_6; + boardConfiguration->fanPin = GPIOD_7; boardConfiguration->injectionPins[0] = GPIOB_8; boardConfiguration->injectionPins[1] = GPIOB_9; @@ -246,12 +246,13 @@ void setDodgeNeonNGCEngineConfiguration(engine_configuration_s *engineConfigurat engineConfiguration->map.sensor.hwChannel = EFI_ADC_0; boardConfiguration->adcHwChannelEnabled[0] = ADC_FAST; // ADC0 - PA0 - MAP - boardConfiguration->adcHwChannelEnabled[1] = ADC_SLOW; // TPS + boardConfiguration->adcHwChannelEnabled[1] = ADC_SLOW; boardConfiguration->adcHwChannelEnabled[4] = ADC_SLOW; boardConfiguration->adcHwChannelEnabled[11] = ADC_SLOW; // IAT boardConfiguration->adcHwChannelEnabled[12] = ADC_SLOW; // CLT boardConfiguration->adcHwChannelEnabled[13] = ADC_SLOW; // AFR boardConfiguration->adcHwChannelEnabled[14] = ADC_SLOW; // VBatt + boardConfiguration->adcHwChannelEnabled[15] = ADC_SLOW; // TPS diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index f5a3a92174..fc9759b40a 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -126,18 +126,18 @@ void setDefaultConfiguration(engine_configuration_s *engineConfiguration, board_ engineConfiguration->cltFuelCorr[i] = 1; // this correction is a multiplier } -// setTableValue(engineConfiguration->cltFuelCorrBins, engineConfiguration->cltFuelCorr, CLT_CURVE_SIZE, -40, 1.5); -// setTableValue(engineConfiguration->cltFuelCorrBins, engineConfiguration->cltFuelCorr, CLT_CURVE_SIZE, -30, 1.5); -// setTableValue(engineConfiguration->cltFuelCorrBins, engineConfiguration->cltFuelCorr, CLT_CURVE_SIZE, -20, 1.42); -// setTableValue(engineConfiguration->cltFuelCorrBins, engineConfiguration->cltFuelCorr, CLT_CURVE_SIZE, -10, 1.36); -// setTableValue(engineConfiguration->cltFuelCorrBins, engineConfiguration->cltFuelCorr, CLT_CURVE_SIZE, 0, 1.28); -// setTableValue(engineConfiguration->cltFuelCorrBins, engineConfiguration->cltFuelCorr, CLT_CURVE_SIZE, 10, 1.19); -// setTableValue(engineConfiguration->cltFuelCorrBins, engineConfiguration->cltFuelCorr, CLT_CURVE_SIZE, 20, 1.12); -// setTableValue(engineConfiguration->cltFuelCorrBins, engineConfiguration->cltFuelCorr, CLT_CURVE_SIZE, 30, 1.10); -// setTableValue(engineConfiguration->cltFuelCorrBins, engineConfiguration->cltFuelCorr, CLT_CURVE_SIZE, 40, 1.06); -// setTableValue(engineConfiguration->cltFuelCorrBins, engineConfiguration->cltFuelCorr, CLT_CURVE_SIZE, 50, 1.06); -// setTableValue(engineConfiguration->cltFuelCorrBins, engineConfiguration->cltFuelCorr, CLT_CURVE_SIZE, 60, 1.03); -// setTableValue(engineConfiguration->cltFuelCorrBins, engineConfiguration->cltFuelCorr, CLT_CURVE_SIZE, 70, 1.01); + setTableValue(engineConfiguration->cltFuelCorrBins, engineConfiguration->cltFuelCorr, CLT_CURVE_SIZE, -40, 1.5); + setTableValue(engineConfiguration->cltFuelCorrBins, engineConfiguration->cltFuelCorr, CLT_CURVE_SIZE, -30, 1.5); + setTableValue(engineConfiguration->cltFuelCorrBins, engineConfiguration->cltFuelCorr, CLT_CURVE_SIZE, -20, 1.42); + setTableValue(engineConfiguration->cltFuelCorrBins, engineConfiguration->cltFuelCorr, CLT_CURVE_SIZE, -10, 1.36); + setTableValue(engineConfiguration->cltFuelCorrBins, engineConfiguration->cltFuelCorr, CLT_CURVE_SIZE, 0, 1.28); + setTableValue(engineConfiguration->cltFuelCorrBins, engineConfiguration->cltFuelCorr, CLT_CURVE_SIZE, 10, 1.19); + setTableValue(engineConfiguration->cltFuelCorrBins, engineConfiguration->cltFuelCorr, CLT_CURVE_SIZE, 20, 1.12); + setTableValue(engineConfiguration->cltFuelCorrBins, engineConfiguration->cltFuelCorr, CLT_CURVE_SIZE, 30, 1.10); + setTableValue(engineConfiguration->cltFuelCorrBins, engineConfiguration->cltFuelCorr, CLT_CURVE_SIZE, 40, 1.06); + setTableValue(engineConfiguration->cltFuelCorrBins, engineConfiguration->cltFuelCorr, CLT_CURVE_SIZE, 50, 1.06); + setTableValue(engineConfiguration->cltFuelCorrBins, engineConfiguration->cltFuelCorr, CLT_CURVE_SIZE, 60, 1.03); + setTableValue(engineConfiguration->cltFuelCorrBins, engineConfiguration->cltFuelCorr, CLT_CURVE_SIZE, 70, 1.01); for (int i = 0; i < VBAT_INJECTOR_CURVE_SIZE; i++) { engineConfiguration->battInjectorLagCorrBins[i] = 12 - VBAT_INJECTOR_CURVE_SIZE / 2 + i; @@ -170,7 +170,6 @@ void setDefaultConfiguration(engine_configuration_s *engineConfiguration, board_ engineConfiguration->rpmHardLimit = 7000; engineConfiguration->crankingSettings.crankingRpm = 550; - engineConfiguration->crankingFuelCoef[0] = 5; // base cranking fuel adjustment coefficient engineConfiguration->crankingFuelBins[0] = -20; // temperature in C engineConfiguration->crankingFuelCoef[1] = 3.7; diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index 068b4cc371..820c5e036e 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -153,6 +153,8 @@ static void fanRelayControl(void) { } if (isCurrentlyOn != newValue) { + if (isRunningBenchTest()) + return; // let's not mess with bench testing scheduleMsg(&logger, "FAN relay: %s", newValue ? "ON" : "OFF"); setOutputPinValue(FAN_RELAY, newValue); } @@ -209,6 +211,8 @@ static void setPinState(io_pin_e ioPin, LEElement *element, Engine *engine) { } else { int value = calc.getValue2(element, engine); if (value != getOutputPinValue(ioPin)) { + if (isRunningBenchTest()) + return; // let's not mess with bench testing scheduleMsg(&logger, "setting %s %s", getIo_pin_e(ioPin), boolToString(value)); setOutputPinValue(ioPin, value); } diff --git a/firmware/controllers/injector_central.cpp b/firmware/controllers/injector_central.cpp index 2a784b6204..3a665b6c8a 100644 --- a/firmware/controllers/injector_central.cpp +++ b/firmware/controllers/injector_central.cpp @@ -33,7 +33,6 @@ static Logging logger; EXTERN_ENGINE; -extern board_configuration_s *boardConfiguration; static bool_t isRunningBench = false; @@ -49,14 +48,10 @@ void assertCylinderId(int cylinderId, const char *msg) { // we are here only in case of a fatal issue - at this point it is fine to make some blocking i-o //scheduleSimpleMsg(&logger, "cid=", cylinderId); print("ERROR [%s] cid=%d\r\n", msg, cylinderId); - efiAssertVoid(FALSE, "Cylinder ID"); + efiAssertVoid(false, "Cylinder ID"); } } -///** -// * This method schedules asynchronous fuel squirt -// */ - /** * @param cylinderId - from 1 to NUMBER_OF_CYLINDERS */ @@ -138,7 +133,7 @@ static void fanbench(Engine *engine) { brainPin = boardConfiguration->fanPin; pinX = FAN_RELAY; - delayMs = 1000; + delayMs = 0; onTime = 3000; offTime = 0; count = 1; @@ -150,7 +145,7 @@ static void fuelpumpbench(void) { brainPin = boardConfiguration->fuelPumpPin; pinX = FUEL_PUMP_RELAY; - delayMs = 1000; + delayMs = 0; onTime = 3000; offTime = 0; count = 1; diff --git a/firmware/svnversion.h b/firmware/svnversion.h index af5e801009..f0169a4d90 100644 --- a/firmware/svnversion.h +++ b/firmware/svnversion.h @@ -1,5 +1,5 @@ // This file was generated by Version2Header -// Wed Nov 26 17:54:29 EST 2014 +// Sat Nov 29 23:31:29 EST 2014 #ifndef VCS_VERSION -#define VCS_VERSION "5615" +#define VCS_VERSION "5638" #endif diff --git a/unit_tests/engine_test_helper.cpp b/unit_tests/engine_test_helper.cpp index 26ee673d0e..969bdb6000 100644 --- a/unit_tests/engine_test_helper.cpp +++ b/unit_tests/engine_test_helper.cpp @@ -18,6 +18,22 @@ EngineTestHelper::EngineTestHelper(engine_type_e engineType) { engine.engineConfiguration = &persistentConfig.engineConfiguration; ec2.engineConfiguration = &persistentConfig.engineConfiguration; + engine_configuration_s *engineConfiguration = ec; + + setTableValue(engineConfiguration->cltFuelCorrBins, engineConfiguration->cltFuelCorr, CLT_CURVE_SIZE, -40, 1.5); + setTableValue(engineConfiguration->cltFuelCorrBins, engineConfiguration->cltFuelCorr, CLT_CURVE_SIZE, -30, 1.5); + setTableValue(engineConfiguration->cltFuelCorrBins, engineConfiguration->cltFuelCorr, CLT_CURVE_SIZE, -20, 1.42); + setTableValue(engineConfiguration->cltFuelCorrBins, engineConfiguration->cltFuelCorr, CLT_CURVE_SIZE, -10, 1.36); + setTableValue(engineConfiguration->cltFuelCorrBins, engineConfiguration->cltFuelCorr, CLT_CURVE_SIZE, 0, 1.28); + setTableValue(engineConfiguration->cltFuelCorrBins, engineConfiguration->cltFuelCorr, CLT_CURVE_SIZE, 10, 1.19); + setTableValue(engineConfiguration->cltFuelCorrBins, engineConfiguration->cltFuelCorr, CLT_CURVE_SIZE, 20, 1.12); + setTableValue(engineConfiguration->cltFuelCorrBins, engineConfiguration->cltFuelCorr, CLT_CURVE_SIZE, 30, 1.10); + setTableValue(engineConfiguration->cltFuelCorrBins, engineConfiguration->cltFuelCorr, CLT_CURVE_SIZE, 40, 1.06); + setTableValue(engineConfiguration->cltFuelCorrBins, engineConfiguration->cltFuelCorr, CLT_CURVE_SIZE, 50, 1.06); + setTableValue(engineConfiguration->cltFuelCorrBins, engineConfiguration->cltFuelCorr, CLT_CURVE_SIZE, 60, 1.03); + setTableValue(engineConfiguration->cltFuelCorrBins, engineConfiguration->cltFuelCorr, CLT_CURVE_SIZE, 70, 1.01); + + engine.engineConfiguration2 = &ec2; prepareFuelMap(engine.engineConfiguration); diff --git a/unit_tests/main.cpp b/unit_tests/main.cpp index 39a3edc759..413551ce3b 100644 --- a/unit_tests/main.cpp +++ b/unit_tests/main.cpp @@ -50,14 +50,14 @@ uint64_t getTimeNowNt(void) { return getTimeNowUs() * US_TO_NT_MULTIPLIER; } -void assertEqualsM(const char *msg, float expected, float actual) { +void assertEqualsM2(const char *msg, float expected, float actual, float EPS) { if (cisnan(actual) && !cisnan(expected)) { printf("Assert failed: %s %.4f while expected %.4f\r\n", msg, actual, expected); exit(-1); } float delta = absF(actual - expected); - if (delta > 0.0001) { + if (delta > EPS) { printf("delta: %.7f\r\n", delta); printf("Unexpected: %s %.4f while expected %.4f\r\n", msg, actual, expected); exit(-1); @@ -65,6 +65,11 @@ void assertEqualsM(const char *msg, float expected, float actual) { printf("Validated %s: %f\r\n", msg, expected); } + +void assertEqualsM(const char *msg, float expected, float actual) { + assertEqualsM2(msg, expected, actual, 0.0001); +} + void assertEquals(float expected, float actual) { assertEqualsM("", expected, actual); } diff --git a/unit_tests/main.h b/unit_tests/main.h index bc61b1a1a1..c7d19a864a 100644 --- a/unit_tests/main.h +++ b/unit_tests/main.h @@ -39,6 +39,7 @@ void print(const char *fmt, ...); #define chDbgCheck(x, y) chDbgAssert(x, y, NULL) +void assertEqualsM2(const char *msg, float expected, float actual, float EPS); void assertEqualsM(const char *msg, float expected, float actual); void assertEquals(float expected, float actual); void assertTrue(float actual); diff --git a/unit_tests/test_fuel_map.cpp b/unit_tests/test_fuel_map.cpp index 89012556b9..39c7485fae 100644 --- a/unit_tests/test_fuel_map.cpp +++ b/unit_tests/test_fuel_map.cpp @@ -59,7 +59,7 @@ void testFuelMap(void) { // because all the correction tables are zero printf("*************************************************** getRunningFuel 1\r\n"); float baseFuel = getBaseTableFuel(eth.engine.engineConfiguration, 5, getEngineLoadT(PASS_ENGINE_PARAMETER_F)); - assertEqualsM("base fuel", 5.0, getRunningFuel(baseFuel, 5 PASS_ENGINE_PARAMETER)); + assertEqualsM("base fuel", 5.05, getRunningFuel(baseFuel, 5 PASS_ENGINE_PARAMETER)); printf("*************************************************** setting IAT table\r\n"); for (int i = 0; i < IAT_CURVE_SIZE; i++) { diff --git a/unit_tests/test_trigger_decoder.cpp b/unit_tests/test_trigger_decoder.cpp index 83b11c57bd..6267ca6d39 100644 --- a/unit_tests/test_trigger_decoder.cpp +++ b/unit_tests/test_trigger_decoder.cpp @@ -432,7 +432,7 @@ static void testRpmCalculator(void) { assertEqualsM("queue size 3", 6, schedulingQueue.size()); assertEqualsM("ev 3", 259777, schedulingQueue.getForUnitText(0)->momentX); assertEquals(259277, schedulingQueue.getForUnitText(1)->momentX); - assertEqualsM("ev 5", 261333, schedulingQueue.getForUnitText(2)->momentX); + assertEqualsM2("ev 5", 261362, schedulingQueue.getForUnitText(2)->momentX, 2); assertEqualsM("3/3", 258333, schedulingQueue.getForUnitText(3)->momentX); schedulingQueue.clear(); @@ -458,7 +458,7 @@ static void testRpmCalculator(void) { assertEqualsM("queue size 6", 6, schedulingQueue.size()); assertEqualsM("6/0", 286444, schedulingQueue.getForUnitText(0)->momentX); assertEqualsM("6/1", 285944, schedulingQueue.getForUnitText(1)->momentX); - assertEqualsM("6/2", 288000, schedulingQueue.getForUnitText(2)->momentX); + assertEqualsM2("6/2", 288029, schedulingQueue.getForUnitText(2)->momentX, 1); schedulingQueue.clear(); timeNow += 5000; @@ -471,7 +471,7 @@ static void testRpmCalculator(void) { assertEqualsM("queue size 8", 6, schedulingQueue.size()); assertEqualsM("8/0", 299777, schedulingQueue.getForUnitText(0)->momentX); assertEqualsM("8/1", 299277, schedulingQueue.getForUnitText(1)->momentX); - assertEqualsM("8/2", 301333, schedulingQueue.getForUnitText(2)->momentX); + assertEqualsM2("8/2", 301362, schedulingQueue.getForUnitText(2)->momentX, 1); assertEqualsM("8/3", 298333, schedulingQueue.getForUnitText(3)->momentX); schedulingQueue.clear();