mirror of https://github.com/rusefi/rusefi-1.git
auto-sync
This commit is contained in:
parent
24af915928
commit
00a0995823
|
@ -586,7 +586,7 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
|
|||
if (hasVBatt(PASS_ENGINE_PARAMETER_F)) {
|
||||
tsOutputChannels->vBatt = getVBatt(PASS_ENGINE_PARAMETER_F);
|
||||
}
|
||||
tsOutputChannels->tpsADC = getTPS10bitAdc(PASS_ENGINE_PARAMETER_F);
|
||||
tsOutputChannels->tpsADC = getTPS12bitAdc(PASS_ENGINE_PARAMETER_F) / TPS_TS_CONVERSION;
|
||||
#if EFI_ANALOG_SENSORS || defined(__DOXYGEN__)
|
||||
tsOutputChannels->baroPressure = hasBaroSensor() ? getBaroPressure() : 0;
|
||||
#endif /* EFI_ANALOG_SENSORS */
|
||||
|
|
|
@ -20,7 +20,8 @@
|
|||
*/
|
||||
static tps_roc_s states[2];
|
||||
|
||||
int tpsFastAdc = 0;
|
||||
// todo if TPS_FAST_ADC
|
||||
//int tpsFastAdc = 0;
|
||||
|
||||
static volatile int tpsRocIndex = 0;
|
||||
|
||||
|
@ -61,7 +62,7 @@ percent_t getTpsValue(int adc DECLARE_ENGINE_PARAMETER_S) {
|
|||
warning(OBD_PCM_Processor_Fault, "Invalid TPS configuration: same value %d", engineConfiguration->tpsMin);
|
||||
return NAN;
|
||||
}
|
||||
float result = interpolate(engineConfiguration->tpsMin, 0, engineConfiguration->tpsMax, 100, adc);
|
||||
float result = interpolate(TPS_TS_CONVERSION * engineConfiguration->tpsMin, 0, TPS_TS_CONVERSION * engineConfiguration->tpsMax, 100, adc);
|
||||
// this would put the value into the 0-100 range
|
||||
return maxF(0, minF(100, result));
|
||||
}
|
||||
|
@ -78,15 +79,17 @@ float getTPSVoltage(DECLARE_ENGINE_PARAMETER_F) {
|
|||
* We need ADC value because TunerStudio has a nice TPS configuration wizard, and this wizard
|
||||
* wants a TPS value.
|
||||
*/
|
||||
int getTPS10bitAdc(DECLARE_ENGINE_PARAMETER_F) {
|
||||
int getTPS12bitAdc(DECLARE_ENGINE_PARAMETER_F) {
|
||||
#if !EFI_PROD_CODE
|
||||
if (mockTps != MOCK_UNDEFINED)
|
||||
return mockTps;
|
||||
#endif
|
||||
if(engineConfiguration->tpsAdcChannel==EFI_ADC_NONE)
|
||||
if (engineConfiguration->tpsAdcChannel == EFI_ADC_NONE)
|
||||
return -1;
|
||||
#if EFI_PROD_CODE
|
||||
return tpsFastAdc / 4;
|
||||
|
||||
return getAdcValue("tps10", engineConfiguration->tpsAdcChannel);
|
||||
// return tpsFastAdc / 4;
|
||||
#else
|
||||
return 0;
|
||||
#endif /* EFI_PROD_CODE */
|
||||
|
@ -96,7 +99,7 @@ int getTPS10bitAdc(DECLARE_ENGINE_PARAMETER_F) {
|
|||
* @brief Position on physical primary TPS
|
||||
*/
|
||||
static percent_t getPrimatyRawTPS(DECLARE_ENGINE_PARAMETER_F) {
|
||||
percent_t tpsValue = getTpsValue(getTPS10bitAdc(PASS_ENGINE_PARAMETER_F) PASS_ENGINE_PARAMETER);
|
||||
percent_t tpsValue = getTpsValue(getTPS12bitAdc(PASS_ENGINE_PARAMETER_F) PASS_ENGINE_PARAMETER);
|
||||
return tpsValue;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
#include "global.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_F);
|
||||
percent_t getPedalPosition(DECLARE_ENGINE_PARAMETER_F);
|
||||
/**
|
||||
|
@ -22,7 +25,7 @@ percent_t getPedalPosition(DECLARE_ENGINE_PARAMETER_F);
|
|||
*/
|
||||
percent_t getTPS(DECLARE_ENGINE_PARAMETER_F);
|
||||
int convertVoltageTo10bitADC(float voltage);
|
||||
int getTPS10bitAdc(DECLARE_ENGINE_PARAMETER_F);
|
||||
int getTPS12bitAdc(DECLARE_ENGINE_PARAMETER_F);
|
||||
float getTPSVoltage(DECLARE_ENGINE_PARAMETER_F);
|
||||
percent_t getTpsValue(int adc DECLARE_ENGINE_PARAMETER_S);
|
||||
|
||||
|
|
|
@ -418,7 +418,7 @@ static void printTPSInfo(void) {
|
|||
scheduleMsg(&logger, "tps min %d/max %d v=%f @%s%d", engineConfiguration->tpsMin, engineConfiguration->tpsMax,
|
||||
getTPSVoltage(PASS_ENGINE_PARAMETER_F), portname(port), pin);
|
||||
#endif
|
||||
scheduleMsg(&logger, "current 10bit=%d value=%f rate=%f", getTPS10bitAdc(), getTPS(PASS_ENGINE_PARAMETER_F),
|
||||
scheduleMsg(&logger, "current 10bit=%d value=%f rate=%f", getTPS12bitAdc() / TPS_TS_CONVERSION, getTPS(PASS_ENGINE_PARAMETER_F),
|
||||
getTpsRateOfChange());
|
||||
}
|
||||
|
||||
|
|
|
@ -495,11 +495,11 @@ static void configureInputs(void) {
|
|||
memset(adcHwChannelEnabled, 0, sizeof(adcHwChannelEnabled));
|
||||
memset(adcHwChannelUsage, 0, sizeof(adcHwChannelUsage));
|
||||
|
||||
addChannel("TPS", engineConfiguration->tpsAdcChannel, ADC_FAST);
|
||||
addChannel("MAP", engineConfiguration->map.sensor.hwChannel, ADC_FAST);
|
||||
addChannel("MAF", engineConfiguration->mafAdcChannel, ADC_FAST);
|
||||
addChannel("hip", engineConfiguration->hipOutputChannel, ADC_FAST);
|
||||
|
||||
addChannel("TPS", engineConfiguration->tpsAdcChannel, ADC_SLOW);
|
||||
addChannel("fuel", engineConfiguration->fuelLevelSensor, ADC_SLOW);
|
||||
addChannel("pPS", engineConfiguration->pedalPositionChannel, ADC_SLOW);
|
||||
addChannel("VBatt", engineConfiguration->vbattAdcChannel, ADC_SLOW);
|
||||
|
|
|
@ -170,8 +170,8 @@ void adc_callback_fast(ADCDriver *adcp, adcsample_t *buffer, size_t n) {
|
|||
hipAdcCallback(fastAdc.samples[hipSampleIndex]);
|
||||
}
|
||||
#endif
|
||||
if(tpsSampleIndex!=TPS_IS_SLOW) {
|
||||
tpsFastAdc = fastAdc.samples[tpsSampleIndex];
|
||||
if (tpsSampleIndex != TPS_IS_SLOW) {
|
||||
// tpsFastAdc = fastAdc.samples[tpsSampleIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -275,5 +275,5 @@ int getRusEfiVersion(void) {
|
|||
return 123; // this is here to make the compiler happy about the unused array
|
||||
if (UNUSED_CCM_SIZE[0] * 0 != 0)
|
||||
return 3211; // this is here to make the compiler happy about the unused array
|
||||
return 20160128;
|
||||
return 20160131;
|
||||
}
|
||||
|
|
|
@ -35,12 +35,12 @@ void testTps(void) {
|
|||
engineConfiguration->tpsMin = 43;
|
||||
engineConfiguration->tpsMax = 193;
|
||||
|
||||
assertEquals(49.3333, getTpsValue(117 PASS_ENGINE_PARAMETER));
|
||||
assertEquals(49.3333, getTpsValue(4 * 117 PASS_ENGINE_PARAMETER));
|
||||
|
||||
|
||||
engineConfiguration->tpsMin = 193;
|
||||
engineConfiguration->tpsMax = 43;
|
||||
assertEquals(50.6667, getTpsValue(117 PASS_ENGINE_PARAMETER));
|
||||
assertEqualsM("test#2", 50.6667, getTpsValue(4 * 117 PASS_ENGINE_PARAMETER));
|
||||
}
|
||||
|
||||
void testTpsRateOfChange(void) {
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "algo.h"
|
||||
#include "trigger_mazda.h"
|
||||
#include "trigger_chrysler.h"
|
||||
#include "tps.h"
|
||||
|
||||
#include "trigger_central.h"
|
||||
#include "main_trigger_callback.h"
|
||||
|
@ -252,11 +253,11 @@ static void testStartupFuelPumping(void) {
|
|||
engine->engineConfiguration->tpsMin = 0;
|
||||
engine->engineConfiguration->tpsMax = 10;
|
||||
|
||||
mockTps = 6;
|
||||
mockTps = TPS_TS_CONVERSION * 6;
|
||||
sf.update(PASS_ENGINE_PARAMETER_F);
|
||||
assertEqualsM("pc#1", 1, sf.pumpsCounter);
|
||||
|
||||
mockTps = 3;
|
||||
mockTps = TPS_TS_CONVERSION * 3;
|
||||
sf.update(PASS_ENGINE_PARAMETER_F);
|
||||
assertEqualsM("pc#2", 1, sf.pumpsCounter);
|
||||
|
||||
|
@ -267,16 +268,16 @@ static void testStartupFuelPumping(void) {
|
|||
sf.update(PASS_ENGINE_PARAMETER_F);
|
||||
assertEqualsM("pc#4", 0, sf.pumpsCounter);
|
||||
|
||||
mockTps = 7;
|
||||
mockTps = TPS_TS_CONVERSION * 7;
|
||||
engine->rpmCalculator.mockRpm = 0;
|
||||
sf.update(PASS_ENGINE_PARAMETER_F);
|
||||
assertEqualsM("pc#5", 1, sf.pumpsCounter);
|
||||
|
||||
mockTps = 3;
|
||||
mockTps = TPS_TS_CONVERSION * 3;
|
||||
sf.update(PASS_ENGINE_PARAMETER_F);
|
||||
assertEqualsM("pc#6", 1, sf.pumpsCounter);
|
||||
|
||||
mockTps = 7;
|
||||
mockTps = TPS_TS_CONVERSION * 7;
|
||||
sf.update(PASS_ENGINE_PARAMETER_F);
|
||||
assertEqualsM("pc#7", 2, sf.pumpsCounter);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue