diff --git a/lambda-test/lambda-test.c b/lambda-test/lambda-test.c index 6cf512b..4a3bbe7 100644 --- a/lambda-test/lambda-test.c +++ b/lambda-test/lambda-test.c @@ -172,8 +172,7 @@ assertTrue(meas.tempIVoltage > 4900); assertTrue(meas.tempOVoltage > 4900); - // lambdaVoltage is divided by the OP amplification factor 11 - assertTrue(meas.lambdaVoltage > (4900 / 11)); + assertTrue(meas.lambdaVoltage > 4900); // verify that temperatures and lambda are calculated correctly assertTrue(meas.tempI == toTempI(meas.tempIVoltage)); @@ -184,13 +183,13 @@ } bool testToLambdaValue(void) { - int16_t lambda = toLambda(12); + int16_t lambda = toLambda(132); return lambda == 1500; } bool testToLambdaInter(void) { - int16_t lambda = toLambda(50); + int16_t lambda = toLambda(550); return lambda == 1073; } diff --git a/lambda/sensors.c b/lambda/sensors.c index fd34c7e..2a56e95 100644 --- a/lambda/sensors.c +++ b/lambda/sensors.c @@ -21,25 +21,26 @@ /** * Table used to look up the lambda value at 12 V heater voltage * and 220°C exhaust gas temperature. Most values are approximated - * from the characteristic curve in the data sheet. + * from the characteristic curve in the data sheet. The voltage + * of the sensor is amplified by factor 11. * TODO real data? */ static const tableEntry lambdaTable[] = { - { 4, 2000 }, - { 5, 1900 }, - { 6, 1800 }, - { 8, 1700 }, - { 10, 1600 }, - { 12, 1500 }, - { 15, 1400 }, - { 20, 1300 }, - { 28, 1200 }, - { 40, 1100 }, - { 68, 1025 }, - { 400, 1000 }, - { 800, 980 }, - { 860, 900 }, - { 880, 800 } + { 44, 2000 }, + { 55, 1900 }, + { 66, 1800 }, + { 80, 1700 }, + { 110, 1600 }, + { 132, 1500 }, + { 165, 1400 }, + { 220, 1300 }, + { 308, 1200 }, + { 440, 1100 }, + { 748, 1025 }, + { 4400, 1000 }, + { 8800, 980 }, + { 9460, 900 }, + { 9680, 800 } }; /** @@ -78,7 +79,7 @@ ((tempOVoltageAvg - 4) >> 3); // OP factor is 11 - uint32_t lambdaVoltage = divRoundNearest(getVoltage(PC2), 11); + uint32_t lambdaVoltage = getVoltage(PC2); lambdaVoltageAvg = lambdaVoltage + lambdaVoltageAvg - ((lambdaVoltageAvg - 4) >> 3);