rusefi-1/firmware/controllers/sensors/maf.cpp

89 lines
1.8 KiB
C++
Raw Normal View History

2014-08-29 07:52:33 -07:00
#include "main.h"
2014-11-11 14:03:38 -08:00
#include "engine.h"
2014-08-29 07:52:33 -07:00
#include "adc_inputs.h"
#include "maf.h"
2015-02-11 18:08:16 -08:00
EXTERN_ENGINE
;
2014-08-29 07:52:33 -07:00
2015-02-13 19:04:11 -08:00
/**
* @return MAF sensor voltage
*/
2014-11-11 14:03:38 -08:00
float getMaf(DECLARE_ENGINE_PARAMETER_F) {
2014-08-29 07:52:33 -07:00
return getMafT(engineConfiguration);
}
2015-02-11 18:08:16 -08:00
2015-02-12 19:04:12 -08:00
/**
* @return kg/hour value
*/
float getRealMaf(DECLARE_ENGINE_PARAMETER_F) {
int mafAdc = getAdcValue(engineConfiguration->mafAdcChannel);
/**
* here we drop from 12 bit ADC to 8 bit index
*/
return engine->mafDecodingLookup[mafAdc >> 4];
}
2015-02-13 12:04:38 -08:00
static void fillTheRest(engine_configuration_s *e, int i) {
/**
* unrealistic values just to make binary search happy
*/
while (i < MAF_DECODING_COUNT) {
e->mafDecoding[i] = 200;
e->mafDecodingBins[i] = 10 + i;
i++;
}
}
static int addMafPoint(engine_configuration_s *e, int i, float kgHrValue, float voltage) {
e->mafDecoding[i] = kgHrValue;
e->mafDecodingBins[i] = voltage;
return i + 1;
}
2015-02-14 20:04:14 -08:00
/**
* Hot-film air-mass meter, Type HFM 5
*/
2015-02-13 12:04:38 -08:00
void setBosch0280218037(engine_configuration_s *e) {
2015-02-11 18:08:16 -08:00
int i = 0;
2015-02-13 12:04:38 -08:00
i = addMafPoint(e, i, -34.5, 0);
i = addMafPoint(e, i, -6, 0.78125);
2015-02-11 18:08:16 -08:00
2015-02-13 12:04:38 -08:00
e->mafDecoding[i] = 10.5;
e->mafDecodingBins[i++] = 1.38671875;
2015-02-11 18:08:16 -08:00
2015-02-13 12:04:38 -08:00
e->mafDecoding[i] = 105.3;
e->mafDecodingBins[i++] = 2.91015625;
2015-02-11 18:08:16 -08:00
2015-02-13 12:04:38 -08:00
e->mafDecoding[i] = 387.5;
e->mafDecodingBins[i++] = 4.2578125;
2015-02-11 18:08:16 -08:00
2015-02-13 12:04:38 -08:00
e->mafDecoding[i] = 738;
e->mafDecodingBins[i++] = 4.98046875;
2015-02-11 18:08:16 -08:00
2015-02-13 12:04:38 -08:00
fillTheRest(e, i);
}
2015-02-11 18:08:16 -08:00
2015-02-13 12:04:38 -08:00
void setBosch0280218004(engine_configuration_s *e) {
int i = 0;
fillTheRest(e, i);
2015-02-11 18:08:16 -08:00
}
2015-02-12 20:04:26 -08:00
2015-02-13 12:04:38 -08:00
void setDensoTODO(engine_configuration_s *e) {
int i = 0;
2015-02-12 20:04:26 -08:00
2015-02-14 14:05:25 -08:00
i = addMafPoint(e, i, 116.3, 0.8);
2015-02-14 20:04:14 -08:00
i = addMafPoint(e, i, 76.3, 1.04);
i = addMafPoint(e, i, 40.5, 1.4);
i = addMafPoint(e, i, 32.5, 1.60);
i = addMafPoint(e, i, 23.8, 1.83);
i = addMafPoint(e, i, 0, 3);
2015-02-14 14:05:25 -08:00
2015-02-14 20:04:14 -08:00
while (i < MAF_DECODING_COUNT) {
e->mafDecoding[i] = 0;
e->mafDecodingBins[i] = 10 + i;
i++;
}
2015-02-12 20:04:26 -08:00
}