Merge branch 'master' of https://github.com/rusefi/rusefi
This commit is contained in:
commit
097afd19c4
|
@ -735,7 +735,7 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
|
||||||
tsOutputChannels->vBatt = getVBatt(PASS_ENGINE_PARAMETER_SIGNATURE);
|
tsOutputChannels->vBatt = getVBatt(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||||
}
|
}
|
||||||
// offset 32
|
// offset 32
|
||||||
tsOutputChannels->tpsADC = getTPS12bitAdc(0 PASS_ENGINE_PARAMETER_SUFFIX) / TPS_TS_CONVERSION;
|
tsOutputChannels->tpsADC = getTPS10bitAdc(0 PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
// offset 36
|
// offset 36
|
||||||
#if EFI_ANALOG_SENSORS
|
#if EFI_ANALOG_SENSORS
|
||||||
tsOutputChannels->baroPressure = hasBaroSensor() ? getBaroPressure() : 0;
|
tsOutputChannels->baroPressure = hasBaroSensor() ? getBaroPressure() : 0;
|
||||||
|
|
|
@ -223,17 +223,6 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(int injEventIndex, InjectionE
|
||||||
|
|
||||||
floatus_t durationUs = MS2US(injectionDuration);
|
floatus_t durationUs = MS2US(injectionDuration);
|
||||||
|
|
||||||
// How long until the injector should start to fire (SOI)
|
|
||||||
floatus_t injectionStartDelayUs = ENGINE(rpmCalculator.oneDegreeUs) * event->injectionStart.angleOffsetFromTriggerEvent;
|
|
||||||
|
|
||||||
#if EFI_DEFAILED_LOGGING
|
|
||||||
scheduleMsg(logger, "handleFuel pin=%s eventIndex %d duration=%.2fms %d", event->outputs[0]->name,
|
|
||||||
injEventIndex,
|
|
||||||
injectionDuration,
|
|
||||||
getRevolutionCounter());
|
|
||||||
scheduleMsg(logger, "handleFuel pin=%s delay=%.2f %d", event->outputs[0]->name, injectionStartDelayUs,
|
|
||||||
getRevolutionCounter());
|
|
||||||
#endif /* EFI_DEFAILED_LOGGING */
|
|
||||||
|
|
||||||
// we are ignoring low RPM in order not to handle "engine was stopped to engine now running" transition
|
// we are ignoring low RPM in order not to handle "engine was stopped to engine now running" transition
|
||||||
if (rpm > 2 * engineConfiguration->cranking.rpm) {
|
if (rpm > 2 * engineConfiguration->cranking.rpm) {
|
||||||
|
@ -261,9 +250,6 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(int injEventIndex, InjectionE
|
||||||
|
|
||||||
event->isScheduled = true;
|
event->isScheduled = true;
|
||||||
|
|
||||||
efitick_t turnOnTime = nowNt + US2NT((int)injectionStartDelayUs);
|
|
||||||
efitick_t turnOffTime = turnOnTime + US2NT((int)durationUs);
|
|
||||||
|
|
||||||
action_s startAction, endAction;
|
action_s startAction, endAction;
|
||||||
// We use different callbacks based on whether we're running sequential mode or not - everything else is the same
|
// We use different callbacks based on whether we're running sequential mode or not - everything else is the same
|
||||||
if (event->isSimultanious) {
|
if (event->isSimultanious) {
|
||||||
|
@ -275,11 +261,21 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(int injEventIndex, InjectionE
|
||||||
endAction = { &turnInjectionPinLow, event };
|
endAction = { &turnInjectionPinLow, event };
|
||||||
}
|
}
|
||||||
|
|
||||||
#if EFI_UNIT_TEST
|
efitick_t startTime = scheduleByAngle(&event->signalTimerUp, nowNt, event->injectionStart.angleOffsetFromTriggerEvent, startAction PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
printf("scheduling injection angle=%.2f/delay=%.2f injectionDuration=%.2f\r\n", event->injectionStart.angleOffsetFromTriggerEvent, injectionStartDelayUs, injectionDuration);
|
efitick_t turnOffTime = startTime + US2NT((int)durationUs);
|
||||||
#endif
|
|
||||||
engine->executor.scheduleByTimestampNt(&event->signalTimerUp, turnOnTime, startAction);
|
|
||||||
engine->executor.scheduleByTimestampNt(&event->endOfInjectionEvent, turnOffTime, endAction);
|
engine->executor.scheduleByTimestampNt(&event->endOfInjectionEvent, turnOffTime, endAction);
|
||||||
|
|
||||||
|
#if EFI_UNIT_TEST
|
||||||
|
printf("scheduling injection angle=%.2f/delay=%.2f injectionDuration=%.2f\r\n", event->injectionStart.angleOffsetFromTriggerEvent, NT2US(startTime - nowNt), injectionDuration);
|
||||||
|
#endif
|
||||||
|
#if EFI_DEFAILED_LOGGING
|
||||||
|
scheduleMsg(logger, "handleFuel pin=%s eventIndex %d duration=%.2fms %d", event->outputs[0]->name,
|
||||||
|
injEventIndex,
|
||||||
|
injectionDuration,
|
||||||
|
getRevolutionCounter());
|
||||||
|
scheduleMsg(logger, "handleFuel pin=%s delay=%.2f %d", event->outputs[0]->name, NT2US(startTime - nowNt),
|
||||||
|
getRevolutionCounter());
|
||||||
|
#endif /* EFI_DEFAILED_LOGGING */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fuelClosedLoopCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
static void fuelClosedLoopCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
|
|
|
@ -360,7 +360,7 @@ void initRpmCalculator(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
* The callback would be executed once after the duration of time which
|
* The callback would be executed once after the duration of time which
|
||||||
* it takes the crankshaft to rotate to the specified angle.
|
* it takes the crankshaft to rotate to the specified angle.
|
||||||
*/
|
*/
|
||||||
void scheduleByAngle(scheduling_s *timer, efitick_t edgeTimestamp, angle_t angle,
|
efitick_t scheduleByAngle(scheduling_s *timer, efitick_t edgeTimestamp, angle_t angle,
|
||||||
action_s action DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
action_s action DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
float delayUs = ENGINE(rpmCalculator.oneDegreeUs) * angle;
|
float delayUs = ENGINE(rpmCalculator.oneDegreeUs) * angle;
|
||||||
|
|
||||||
|
@ -368,6 +368,8 @@ void scheduleByAngle(scheduling_s *timer, efitick_t edgeTimestamp, angle_t angle
|
||||||
efitime_t delayedTime = edgeTimestamp + delayNt;
|
efitime_t delayedTime = edgeTimestamp + delayNt;
|
||||||
|
|
||||||
ENGINE(executor.scheduleByTimestampNt(timer, delayedTime, action));
|
ENGINE(executor.scheduleByTimestampNt(timer, delayedTime, action));
|
||||||
|
|
||||||
|
return delayedTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -165,5 +165,5 @@ float getCrankshaftAngleNt(efitick_t timeNt DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||||
#define addEngineSnifferEvent(n, msg) {}
|
#define addEngineSnifferEvent(n, msg) {}
|
||||||
#endif /* EFI_ENGINE_SNIFFER */
|
#endif /* EFI_ENGINE_SNIFFER */
|
||||||
|
|
||||||
void scheduleByAngle(scheduling_s *timer, efitick_t edgeTimestamp, angle_t angle, action_s action DECLARE_ENGINE_PARAMETER_SUFFIX);
|
efitick_t scheduleByAngle(scheduling_s *timer, efitick_t edgeTimestamp, angle_t angle, action_s action DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,9 @@
|
||||||
|
|
||||||
EXTERN_ENGINE;
|
EXTERN_ENGINE;
|
||||||
|
|
||||||
|
// Scaled to 1000 counts = 5.0 volts
|
||||||
|
#define TPS_TS_CONVERSION 200
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set mock_pedal_position X
|
* set mock_pedal_position X
|
||||||
* See also directPwmValue
|
* See also directPwmValue
|
||||||
|
@ -22,7 +25,7 @@ percent_t mockPedalPosition = MOCK_UNDEFINED;
|
||||||
* this allows unit tests to simulate TPS position
|
* this allows unit tests to simulate TPS position
|
||||||
*/
|
*/
|
||||||
void setMockTpsAdc(percent_t tpsPosition DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
void setMockTpsAdc(percent_t tpsPosition DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
engine->mockTpsAdcValue = TPS_TS_CONVERSION * tpsPosition;
|
engine->mockTpsAdcValue = tpsPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMockTpsValue(percent_t tpsPosition DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
void setMockTpsValue(percent_t tpsPosition DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
|
@ -78,7 +81,7 @@ float getTpsRateOfChange(void) {
|
||||||
* Return current TPS position based on configured ADC levels, and adc
|
* Return current TPS position based on configured ADC levels, and adc
|
||||||
*
|
*
|
||||||
* */
|
* */
|
||||||
percent_t getTpsValue(int index, int adc DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
percent_t getTpsValue(int index, float adc DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
|
|
||||||
DISPLAY_STATE(Engine)
|
DISPLAY_STATE(Engine)
|
||||||
DISPLAY_TAG(TPS_SECTION);
|
DISPLAY_TAG(TPS_SECTION);
|
||||||
|
@ -117,8 +120,7 @@ percent_t getTpsValue(int index, int adc DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
int tpsMax = index == 0 ? CONFIG(tpsMax) : CONFIG(tps2Max);
|
int tpsMax = index == 0 ? CONFIG(tpsMax) : CONFIG(tps2Max);
|
||||||
int tpsMin = index == 0 ? CONFIG(tpsMin) : CONFIG(tps2Min);
|
int tpsMin = index == 0 ? CONFIG(tpsMin) : CONFIG(tps2Min);
|
||||||
|
|
||||||
float result = interpolateMsg("TPS", TPS_TS_CONVERSION * tpsMax, 100,
|
float result = interpolateMsg("TPS", tpsMax, 100, tpsMin, 0, adc);
|
||||||
TPS_TS_CONVERSION * tpsMin, 0, adc);
|
|
||||||
if (result < engineConfiguration->tpsErrorDetectionTooLow) {
|
if (result < engineConfiguration->tpsErrorDetectionTooLow) {
|
||||||
#if EFI_PROD_CODE
|
#if EFI_PROD_CODE
|
||||||
// too much noise with simulator
|
// too much noise with simulator
|
||||||
|
@ -149,7 +151,7 @@ float getTPSVoltage(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
* wants a TPS value.
|
* wants a TPS value.
|
||||||
* @param index [0, ETB_COUNT)
|
* @param index [0, ETB_COUNT)
|
||||||
*/
|
*/
|
||||||
int getTPS12bitAdc(int index DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
float getTPS10bitAdc(int index DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
#if !EFI_PROD_CODE
|
#if !EFI_PROD_CODE
|
||||||
if (engine->mockTpsAdcValue != MOCK_UNDEFINED) {
|
if (engine->mockTpsAdcValue != MOCK_UNDEFINED) {
|
||||||
return engine->mockTpsAdcValue;
|
return engine->mockTpsAdcValue;
|
||||||
|
@ -160,9 +162,9 @@ int getTPS12bitAdc(int index DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
#if EFI_PROD_CODE
|
#if EFI_PROD_CODE
|
||||||
|
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
return getAdcValue("tps10", engineConfiguration->tps1_1AdcChannel);
|
return convertVoltageTo10bitADC(getVoltageDivided("tps10", engineConfiguration->tps1_1AdcChannel));
|
||||||
} else {
|
} else {
|
||||||
return getAdcValue("tps20", engineConfiguration->tps2_1AdcChannel);
|
return convertVoltageTo10bitADC(getVoltageDivided("tps20", engineConfiguration->tps2_1AdcChannel));
|
||||||
}
|
}
|
||||||
// return tpsFastAdc / 4;
|
// return tpsFastAdc / 4;
|
||||||
#else
|
#else
|
||||||
|
@ -173,7 +175,7 @@ int getTPS12bitAdc(int index DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
void grabTPSIsClosed() {
|
void grabTPSIsClosed() {
|
||||||
#if EFI_PROD_CODE
|
#if EFI_PROD_CODE
|
||||||
printTPSInfo();
|
printTPSInfo();
|
||||||
engineConfiguration->tpsMin = getTPS10bitAdc();
|
engineConfiguration->tpsMin = getTPS10bitAdc(0);
|
||||||
printTPSInfo();
|
printTPSInfo();
|
||||||
#endif /* EFI_PROD_CODE */
|
#endif /* EFI_PROD_CODE */
|
||||||
}
|
}
|
||||||
|
@ -181,7 +183,7 @@ void grabTPSIsClosed() {
|
||||||
void grabTPSIsWideOpen() {
|
void grabTPSIsWideOpen() {
|
||||||
#if EFI_PROD_CODE
|
#if EFI_PROD_CODE
|
||||||
printTPSInfo();
|
printTPSInfo();
|
||||||
engineConfiguration->tpsMax = getTPS10bitAdc();
|
engineConfiguration->tpsMax = getTPS10bitAdc(0);
|
||||||
printTPSInfo();
|
printTPSInfo();
|
||||||
#endif /* EFI_PROD_CODE */
|
#endif /* EFI_PROD_CODE */
|
||||||
}
|
}
|
||||||
|
@ -206,7 +208,7 @@ void grabPedalIsWideOpen() {
|
||||||
* @brief Position on physical primary TPS
|
* @brief Position on physical primary TPS
|
||||||
*/
|
*/
|
||||||
static percent_t getPrimaryRawTPS(int index DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
static percent_t getPrimaryRawTPS(int index DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
int adcValue = getTPS12bitAdc(index PASS_ENGINE_PARAMETER_SUFFIX);
|
float adcValue = getTPS10bitAdc(index PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
percent_t tpsValue = getTpsValue(index, adcValue PASS_ENGINE_PARAMETER_SUFFIX);
|
percent_t tpsValue = getTpsValue(index, adcValue PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
return tpsValue;
|
return tpsValue;
|
||||||
}
|
}
|
||||||
|
@ -268,5 +270,5 @@ void setBosch0280750009(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
|
|
||||||
int convertVoltageTo10bitADC(float voltage) {
|
int convertVoltageTo10bitADC(float voltage) {
|
||||||
// divided by 2 because of voltage divider, then converted into 10bit ADC value (TunerStudio format)
|
// divided by 2 because of voltage divider, then converted into 10bit ADC value (TunerStudio format)
|
||||||
return (int) (voltage / 2 * 1024 / 3.3);
|
return (int) (voltage * TPS_TS_CONVERSION);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,9 +12,6 @@
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "engine_configuration.h"
|
#include "engine_configuration.h"
|
||||||
|
|
||||||
// we have 12 bit precision and TS uses 10 bit precision
|
|
||||||
#define TPS_TS_CONVERSION 4
|
|
||||||
|
|
||||||
bool hasPedalPositionSensor(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
bool hasPedalPositionSensor(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||||
percent_t getPedalPosition(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
percent_t getPedalPosition(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||||
/**
|
/**
|
||||||
|
@ -26,11 +23,10 @@ percent_t getTPS(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||||
percent_t getTPSWithIndex(int index DECLARE_ENGINE_PARAMETER_SUFFIX);
|
percent_t getTPSWithIndex(int index DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||||
bool hasTpsSensor(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
bool hasTpsSensor(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||||
int convertVoltageTo10bitADC(float voltage);
|
int convertVoltageTo10bitADC(float voltage);
|
||||||
int getTPS12bitAdc(int index DECLARE_ENGINE_PARAMETER_SUFFIX);
|
float getTPS10bitAdc(int index DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||||
bool hasSecondThrottleBody(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
bool hasSecondThrottleBody(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||||
#define getTPS10bitAdc() (getTPS12bitAdc(0 PASS_ENGINE_PARAMETER_SUFFIX) / TPS_TS_CONVERSION)
|
|
||||||
float getTPSVoltage(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
float getTPSVoltage(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||||
percent_t getTpsValue(int index, int adc DECLARE_ENGINE_PARAMETER_SUFFIX);
|
percent_t getTpsValue(int index, float adc DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||||
void setBosch0280750009(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
void setBosch0280750009(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||||
void setMockTpsAdc(percent_t tpsPosition DECLARE_ENGINE_PARAMETER_SUFFIX);
|
void setMockTpsAdc(percent_t tpsPosition DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||||
void setMockTpsValue(percent_t tpsPosition DECLARE_ENGINE_PARAMETER_SUFFIX);
|
void setMockTpsValue(percent_t tpsPosition DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
|
|
@ -426,7 +426,7 @@ void printTPSInfo(void) {
|
||||||
|
|
||||||
|
|
||||||
#endif /* EFI_PROD_CODE */
|
#endif /* EFI_PROD_CODE */
|
||||||
scheduleMsg(&logger, "current 10bit=%d value=%.2f rate=%.2f", getTPS10bitAdc(), getTPS(PASS_ENGINE_PARAMETER_SIGNATURE),
|
scheduleMsg(&logger, "current 10bit=%d value=%.2f rate=%.2f", (int)getTPS10bitAdc(0), getTPS(PASS_ENGINE_PARAMETER_SIGNATURE),
|
||||||
getTpsRateOfChange());
|
getTpsRateOfChange());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,12 +34,12 @@ TEST(sensors, tps) {
|
||||||
engineConfiguration->tpsMax = 193;
|
engineConfiguration->tpsMax = 193;
|
||||||
engineConfiguration->tpsMin = 43;
|
engineConfiguration->tpsMin = 43;
|
||||||
|
|
||||||
ASSERT_NEAR(49.3333, getTpsValue(0, 4 * 117 PASS_ENGINE_PARAMETER_SUFFIX), EPS4D);
|
ASSERT_NEAR(49.3333, getTpsValue(0, 117 PASS_ENGINE_PARAMETER_SUFFIX), EPS4D);
|
||||||
|
|
||||||
|
|
||||||
engineConfiguration->tpsMax = 43;
|
engineConfiguration->tpsMax = 43;
|
||||||
engineConfiguration->tpsMin = 193;
|
engineConfiguration->tpsMin = 193;
|
||||||
assertEqualsM("test#2", 50.6667, getTpsValue(0, 4 * 117 PASS_ENGINE_PARAMETER_SUFFIX));
|
assertEqualsM("test#2", 50.6667, getTpsValue(0, 117 PASS_ENGINE_PARAMETER_SUFFIX));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(sensors, testTpsRateOfChange) {
|
TEST(sensors, testTpsRateOfChange) {
|
||||||
|
|
Loading…
Reference in New Issue