mirror of https://github.com/rusefi/wideband.git
lambda conversion
This commit is contained in:
parent
85b0c4b6b4
commit
2aedbd6eef
|
@ -123,7 +123,7 @@ CPPSRC = $(ALLCPPSRC) \
|
||||||
analog_input.cpp \
|
analog_input.cpp \
|
||||||
can.cpp \
|
can.cpp \
|
||||||
can_helper.cpp \
|
can_helper.cpp \
|
||||||
lambda_lookup.cpp \
|
lambda_conversion.cpp \
|
||||||
pwm.cpp \
|
pwm.cpp \
|
||||||
pump_dac.cpp \
|
pump_dac.cpp \
|
||||||
sampling.cpp \
|
sampling.cpp \
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "sampling.h"
|
||||||
|
|
||||||
|
static float GetPhi(float pumpCurrent)
|
||||||
|
{
|
||||||
|
// This estimation is accurate within 0.5% from 0.8 to 1.0, and 0.01% from 1 to 1.2 lambda when compared to the lookup table in the Bosch datasheet
|
||||||
|
float gain = pumpCurrent > 0 ? -0.28299f : -0.44817f;
|
||||||
|
|
||||||
|
return gain * pumpCurrent + 0.99559f;
|
||||||
|
}
|
||||||
|
|
||||||
|
float GetLambda()
|
||||||
|
{
|
||||||
|
float pumpCurrent = GetPumpNominalCurrent();
|
||||||
|
|
||||||
|
// Lambda is reciprocal of phi
|
||||||
|
return 1 / GetPhi(pumpCurrent);
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
float GetLambda();
|
|
@ -1,3 +0,0 @@
|
||||||
|
|
||||||
static const float pumpCurrentMa[24] = { -2.0f, -1.602f, -1.243f, -0.927f, -0.8f, -0.652f, -0.405f, -0.183f, -0.106f, -0.04f, 0.0f, 0.015f, 0.097f, 0.193f, 0.25f, 0.329f, 0.671f, 0.938f, 1.15f, 1.385f, 1.7f, 2.0f, 2.15f, 2.25 };
|
|
||||||
static const float phi[24] = { 1.538461538f, 1.428571429f, 1.333333333f, 1.25f, 1.216545012f, 1.176470588f, 1.111111111f, 1.052631579f, 1.030927835f, 1.01010101f, 0.997008973f, 0.99009901f, 0.952380952f, 0.909090909f, 0.883392226f, 0.848176421f, 0.699790063f, 0.587889477f, 0.502512563f, 0.410846343f, 0.292997363f, 0.185494342f, 0.133226752f, 0.098823994 };
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "pump_control.h"
|
#include "pump_control.h"
|
||||||
#include "pump_dac.h"
|
#include "pump_dac.h"
|
||||||
#include "sampling.h"
|
#include "sampling.h"
|
||||||
|
#include "lambda_conversion.h"
|
||||||
|
|
||||||
static const UARTConfig uartCfg =
|
static const UARTConfig uartCfg =
|
||||||
{
|
{
|
||||||
|
@ -58,7 +59,7 @@ int main() {
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
size_t writeCount = chsnprintf(strBuffer, 200, "%.4f\t%.2f\t%.2f\n", GetSensorInternalResistance(), nernstVolt, GetPumpNominalCurrent());
|
size_t writeCount = chsnprintf(strBuffer, 200, "%.4f\t%.2f\t%.3f\n", GetSensorInternalResistance(), GetNernstDc(), GetLambda());
|
||||||
uartStartSend(&UARTD1, writeCount, strBuffer);
|
uartStartSend(&UARTD1, writeCount, strBuffer);
|
||||||
|
|
||||||
chThdSleepMilliseconds(5);
|
chThdSleepMilliseconds(5);
|
||||||
|
|
Loading…
Reference in New Issue