auto-sync
This commit is contained in:
parent
75f22faf4a
commit
326bef69ea
|
@ -155,14 +155,23 @@ float getBaseTableFuel(engine_configuration_s *engineConfiguration, int rpm, flo
|
||||||
* @return Duration of fuel injection while craning, in milliseconds
|
* @return Duration of fuel injection while craning, in milliseconds
|
||||||
*/
|
*/
|
||||||
float getCrankingFuel(Engine *engine) {
|
float getCrankingFuel(Engine *engine) {
|
||||||
return getStartingFuel(engine->engineConfiguration, getCoolantTemperature(engine));
|
return getCrankingFuel3(engine->engineConfiguration, getCoolantTemperature(engine),
|
||||||
|
engine->rpmCalculator->getRevolutionCounterSinceStart()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
float getStartingFuel(engine_configuration_s *engineConfiguration, float coolantTemperature) {
|
float getCrankingFuel3(engine_configuration_s *engineConfiguration, float coolantTemperature,
|
||||||
|
uint32_t revolutionCounterSinceStart) {
|
||||||
// these magic constants are in Celsius
|
// these magic constants are in Celsius
|
||||||
float baseCrankingFuel = engineConfiguration->crankingSettings.baseCrankingFuel;
|
float baseCrankingFuel = engineConfiguration->crankingSettings.baseCrankingFuel;
|
||||||
if (cisnan(coolantTemperature))
|
if (cisnan(coolantTemperature))
|
||||||
return baseCrankingFuel;
|
return baseCrankingFuel;
|
||||||
|
float durationCoef = interpolate2d(revolutionCounterSinceStart,
|
||||||
|
engineConfiguration->crankingCycleBins,
|
||||||
|
engineConfiguration->crankingCycleCoef, CRANKING_CURVE_SIZE);
|
||||||
|
|
||||||
return interpolate2d(coolantTemperature, engineConfiguration->crankingFuelBins,
|
return interpolate2d(coolantTemperature, engineConfiguration->crankingFuelBins,
|
||||||
engineConfiguration->crankingFuelCoef, CRANKING_CURVE_SIZE) * baseCrankingFuel;
|
engineConfiguration->crankingFuelCoef, CRANKING_CURVE_SIZE)
|
||||||
|
* baseCrankingFuel
|
||||||
|
* durationCoef;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ float getInjectorLag(engine_configuration_s *engineConfiguration, float vBatt);
|
||||||
float getCltCorrection(engine_configuration_s *engineConfiguration, float clt);
|
float getCltCorrection(engine_configuration_s *engineConfiguration, float clt);
|
||||||
float getRunningFuel(float baseFuel, Engine *engine, int rpm);
|
float getRunningFuel(float baseFuel, Engine *engine, int rpm);
|
||||||
float getCrankingFuel(Engine *engine);
|
float getCrankingFuel(Engine *engine);
|
||||||
float getStartingFuel(engine_configuration_s *engineConfiguration, float coolantTemperature);
|
float getCrankingFuel3(engine_configuration_s *engineConfiguration, float coolantTemperature, uint32_t revolutionCounterSinceStart);
|
||||||
float getFuelMs(int rpm, Engine *engine);
|
float getFuelMs(int rpm, Engine *engine);
|
||||||
|
|
||||||
#endif /* FUEL_MAP_H_ */
|
#endif /* FUEL_MAP_H_ */
|
||||||
|
|
|
@ -64,6 +64,8 @@ RpmCalculator::RpmCalculator() {
|
||||||
|
|
||||||
// we need this initial to have not_running at first invocation
|
// we need this initial to have not_running at first invocation
|
||||||
lastRpmEventTimeUs = (uint64_t) -10 * US_PER_SECOND;
|
lastRpmEventTimeUs = (uint64_t) -10 * US_PER_SECOND;
|
||||||
|
revolutionCounterSinceStart = 0;
|
||||||
|
revolutionCounterSinceBoot = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -74,6 +76,20 @@ bool RpmCalculator::isRunning(void) {
|
||||||
return nowUs - lastRpmEventTimeUs < US_PER_SECOND;
|
return nowUs - lastRpmEventTimeUs < US_PER_SECOND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RpmCalculator::onNewEngineCycle() {
|
||||||
|
revolutionCounterSinceBoot++;
|
||||||
|
revolutionCounterSinceStart++;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t RpmCalculator::getRevolutionCounter(void) {
|
||||||
|
return revolutionCounterSinceBoot;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t RpmCalculator::getRevolutionCounterSinceStart(void) {
|
||||||
|
return revolutionCounterSinceStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// todo: migrate to float return result or add a float verion? this would have with calculations
|
// todo: migrate to float return result or add a float verion? this would have with calculations
|
||||||
// todo: add a version which does not check time & saves time? need to profile
|
// todo: add a version which does not check time & saves time? need to profile
|
||||||
int RpmCalculator::rpm(void) {
|
int RpmCalculator::rpm(void) {
|
||||||
|
@ -82,6 +98,7 @@ int RpmCalculator::rpm(void) {
|
||||||
return mockRpm;
|
return mockRpm;
|
||||||
#endif
|
#endif
|
||||||
if (!isRunning()) {
|
if (!isRunning()) {
|
||||||
|
revolutionCounterSinceStart = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return rpmValue;
|
return rpmValue;
|
||||||
|
@ -122,7 +139,7 @@ void rpmShaftPositionCallback(trigger_event_e ckpSignalType, uint32_t index, Rpm
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rpmState->revolutionCounter++;
|
rpmState->onNewEngineCycle();
|
||||||
|
|
||||||
bool hadRpmRecently = rpmState->isRunning();
|
bool hadRpmRecently = rpmState->isRunning();
|
||||||
|
|
||||||
|
@ -186,7 +203,7 @@ uint64_t getLastRpmEventTime(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int getRevolutionCounter(void) {
|
int getRevolutionCounter(void) {
|
||||||
return rpmState.revolutionCounter;
|
return rpmState.getRevolutionCounter();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -28,14 +28,23 @@ public:
|
||||||
int mockRpm;
|
int mockRpm;
|
||||||
#endif
|
#endif
|
||||||
RpmCalculator();
|
RpmCalculator();
|
||||||
|
bool isRunning(void);
|
||||||
int rpm(void);
|
int rpm(void);
|
||||||
|
void onNewEngineCycle();
|
||||||
|
uint32_t getRevolutionCounter(void);
|
||||||
|
uint32_t getRevolutionCounterSinceStart(void);
|
||||||
volatile int rpmValue;
|
volatile int rpmValue;
|
||||||
volatile uint64_t lastRpmEventTimeUs;
|
volatile uint64_t lastRpmEventTimeUs;
|
||||||
|
private:
|
||||||
/**
|
/**
|
||||||
* This counter is incremented with each revolution of one of the shafts. Could be
|
* This counter is incremented with each revolution of one of the shafts. Could be
|
||||||
* crankshaft could be camshaft.
|
* crankshaft could be camshaft.
|
||||||
*/
|
*/
|
||||||
volatile int revolutionCounter;bool isRunning(void);
|
volatile uint32_t revolutionCounterSinceBoot;
|
||||||
|
/**
|
||||||
|
* Same as the above, but since the engine started spinning
|
||||||
|
*/
|
||||||
|
volatile uint32_t revolutionCounterSinceStart;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define getRpm() getRpmE(&engine)
|
#define getRpm() getRpmE(&engine)
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
/**
|
/**
|
||||||
* @file analog_chart.c
|
* @file analog_chart.cpp
|
||||||
*
|
*
|
||||||
* @date Dec 20, 2013
|
* @date Dec 20, 2013
|
||||||
* @author Andrey Belomutskiy, (c) 2012-2014
|
* @author Andrey Belomutskiy, (c) 2012-2014
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "rpm_calculator.h"
|
|
||||||
#include "analog_chart.h"
|
#include "analog_chart.h"
|
||||||
|
#include "rpm_calculator.h"
|
||||||
#include "status_loop.h"
|
#include "status_loop.h"
|
||||||
#include "engine_configuration.h"
|
#include "engine_configuration.h"
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
|
|
||||||
EMULATIONSRC = emulation/hw_layer/poten.c \
|
EMULATIONSRC = emulation/hw_layer/poten.c \
|
||||||
emulation/analog_chart.c \
|
|
||||||
emulation/test/test.c \
|
emulation/test/test.c \
|
||||||
emulation/test/testbmk.c
|
emulation/test/testbmk.c
|
||||||
|
|
||||||
EMULATIONSRC_CPP = emulation/trigger_emulator.cpp \
|
EMULATIONSRC_CPP = emulation/trigger_emulator.cpp \
|
||||||
|
emulation/analog_chart.cpp \
|
||||||
emulation/rfi_perftest.cpp \
|
emulation/rfi_perftest.cpp \
|
||||||
emulation/engine_emulator.cpp \
|
emulation/engine_emulator.cpp \
|
||||||
emulation/wave_analyzer.cpp
|
emulation/wave_analyzer.cpp
|
||||||
|
|
|
@ -94,10 +94,11 @@ void testFuelMap(void) {
|
||||||
|
|
||||||
printf("*************************************************** getStartingFuel\r\n");
|
printf("*************************************************** getStartingFuel\r\n");
|
||||||
// NAN in case we have issues with the CLT sensor
|
// NAN in case we have issues with the CLT sensor
|
||||||
assertEqualsM("getStartingFuel nan", 4, getStartingFuel(engineConfiguration, NAN));
|
assertEqualsM("getStartingFuel nan", 4, getCrankingFuel3(engineConfiguration, NAN, 0));
|
||||||
assertEqualsM("getStartingFuel#1", 11.8667, getStartingFuel(engineConfiguration, 0));
|
assertEqualsM("getStartingFuel#1", 23.7333, getCrankingFuel3(engineConfiguration, 0, 4));
|
||||||
assertEqualsM("getStartingFuel#2", 10.2400, getStartingFuel(engineConfiguration, 8));
|
assertEqualsM("getStartingFuel#2", 18.0419, getCrankingFuel3(engineConfiguration, 8, 15));
|
||||||
assertEqualsM("getStartingFuel#3", 5.6000, getStartingFuel(engineConfiguration, 70));
|
assertEqualsM("getStartingFuel#3", 11.2000, getCrankingFuel3(engineConfiguration, 70, 0));
|
||||||
|
assertEqualsM("getStartingFuel#3", 5.6000, getCrankingFuel3(engineConfiguration, 70, 50));
|
||||||
}
|
}
|
||||||
|
|
||||||
extern engine_configuration_s *engineConfiguration;
|
extern engine_configuration_s *engineConfiguration;
|
||||||
|
|
|
@ -113,7 +113,6 @@ CSRC = ${PORTSRC} \
|
||||||
${CHIBIOS}/os/various/memstreams.c \
|
${CHIBIOS}/os/various/memstreams.c \
|
||||||
$(UTILSRC) \
|
$(UTILSRC) \
|
||||||
simulator/boards.c \
|
simulator/boards.c \
|
||||||
$(PROJECT_DIR)/emulation/analog_chart.c \
|
|
||||||
main.c
|
main.c
|
||||||
|
|
||||||
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
|
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
|
||||||
|
@ -121,6 +120,7 @@ CSRC = ${PORTSRC} \
|
||||||
CPPSRC = $(UTILSRC_CPP) \
|
CPPSRC = $(UTILSRC_CPP) \
|
||||||
$(CONTROLLERS_ALGO_SRC_CPP) \
|
$(CONTROLLERS_ALGO_SRC_CPP) \
|
||||||
$(PROJECT_DIR)/controllers/settings.cpp \
|
$(PROJECT_DIR)/controllers/settings.cpp \
|
||||||
|
$(PROJECT_DIR)/emulation/analog_chart.cpp \
|
||||||
$(TRIGGER_SRC_CPP) \
|
$(TRIGGER_SRC_CPP) \
|
||||||
$(TRIGGER_DECODERS_SRC_CPP) \
|
$(TRIGGER_DECODERS_SRC_CPP) \
|
||||||
$(SYSTEMSRC_CPP) \
|
$(SYSTEMSRC_CPP) \
|
||||||
|
|
Loading…
Reference in New Issue