auto-sync

This commit is contained in:
rusEfi 2016-01-31 21:02:03 -05:00
parent 24af915928
commit 00a0995823
9 changed files with 27 additions and 20 deletions

View File

@ -586,7 +586,7 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
if (hasVBatt(PASS_ENGINE_PARAMETER_F)) { if (hasVBatt(PASS_ENGINE_PARAMETER_F)) {
tsOutputChannels->vBatt = getVBatt(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__) #if EFI_ANALOG_SENSORS || defined(__DOXYGEN__)
tsOutputChannels->baroPressure = hasBaroSensor() ? getBaroPressure() : 0; tsOutputChannels->baroPressure = hasBaroSensor() ? getBaroPressure() : 0;
#endif /* EFI_ANALOG_SENSORS */ #endif /* EFI_ANALOG_SENSORS */

View File

@ -20,7 +20,8 @@
*/ */
static tps_roc_s states[2]; static tps_roc_s states[2];
int tpsFastAdc = 0; // todo if TPS_FAST_ADC
//int tpsFastAdc = 0;
static volatile int tpsRocIndex = 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); warning(OBD_PCM_Processor_Fault, "Invalid TPS configuration: same value %d", engineConfiguration->tpsMin);
return NAN; 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 // this would put the value into the 0-100 range
return maxF(0, minF(100, result)); 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 * We need ADC value because TunerStudio has a nice TPS configuration wizard, and this wizard
* wants a TPS value. * wants a TPS value.
*/ */
int getTPS10bitAdc(DECLARE_ENGINE_PARAMETER_F) { int getTPS12bitAdc(DECLARE_ENGINE_PARAMETER_F) {
#if !EFI_PROD_CODE #if !EFI_PROD_CODE
if (mockTps != MOCK_UNDEFINED) if (mockTps != MOCK_UNDEFINED)
return mockTps; return mockTps;
#endif #endif
if(engineConfiguration->tpsAdcChannel==EFI_ADC_NONE) if (engineConfiguration->tpsAdcChannel == EFI_ADC_NONE)
return -1; return -1;
#if EFI_PROD_CODE #if EFI_PROD_CODE
return tpsFastAdc / 4;
return getAdcValue("tps10", engineConfiguration->tpsAdcChannel);
// return tpsFastAdc / 4;
#else #else
return 0; return 0;
#endif /* EFI_PROD_CODE */ #endif /* EFI_PROD_CODE */
@ -96,7 +99,7 @@ int getTPS10bitAdc(DECLARE_ENGINE_PARAMETER_F) {
* @brief Position on physical primary TPS * @brief Position on physical primary TPS
*/ */
static percent_t getPrimatyRawTPS(DECLARE_ENGINE_PARAMETER_F) { 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; return tpsValue;
} }

View File

@ -13,6 +13,9 @@
#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_F); bool hasPedalPositionSensor(DECLARE_ENGINE_PARAMETER_F);
percent_t getPedalPosition(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); percent_t getTPS(DECLARE_ENGINE_PARAMETER_F);
int convertVoltageTo10bitADC(float voltage); int convertVoltageTo10bitADC(float voltage);
int getTPS10bitAdc(DECLARE_ENGINE_PARAMETER_F); int getTPS12bitAdc(DECLARE_ENGINE_PARAMETER_F);
float getTPSVoltage(DECLARE_ENGINE_PARAMETER_F); float getTPSVoltage(DECLARE_ENGINE_PARAMETER_F);
percent_t getTpsValue(int adc DECLARE_ENGINE_PARAMETER_S); percent_t getTpsValue(int adc DECLARE_ENGINE_PARAMETER_S);

View File

@ -418,7 +418,7 @@ static void printTPSInfo(void) {
scheduleMsg(&logger, "tps min %d/max %d v=%f @%s%d", engineConfiguration->tpsMin, engineConfiguration->tpsMax, scheduleMsg(&logger, "tps min %d/max %d v=%f @%s%d", engineConfiguration->tpsMin, engineConfiguration->tpsMax,
getTPSVoltage(PASS_ENGINE_PARAMETER_F), portname(port), pin); getTPSVoltage(PASS_ENGINE_PARAMETER_F), portname(port), pin);
#endif #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()); getTpsRateOfChange());
} }

View File

@ -495,11 +495,11 @@ static void configureInputs(void) {
memset(adcHwChannelEnabled, 0, sizeof(adcHwChannelEnabled)); memset(adcHwChannelEnabled, 0, sizeof(adcHwChannelEnabled));
memset(adcHwChannelUsage, 0, sizeof(adcHwChannelUsage)); memset(adcHwChannelUsage, 0, sizeof(adcHwChannelUsage));
addChannel("TPS", engineConfiguration->tpsAdcChannel, ADC_FAST);
addChannel("MAP", engineConfiguration->map.sensor.hwChannel, ADC_FAST); addChannel("MAP", engineConfiguration->map.sensor.hwChannel, ADC_FAST);
addChannel("MAF", engineConfiguration->mafAdcChannel, ADC_FAST); addChannel("MAF", engineConfiguration->mafAdcChannel, ADC_FAST);
addChannel("hip", engineConfiguration->hipOutputChannel, ADC_FAST); addChannel("hip", engineConfiguration->hipOutputChannel, ADC_FAST);
addChannel("TPS", engineConfiguration->tpsAdcChannel, ADC_SLOW);
addChannel("fuel", engineConfiguration->fuelLevelSensor, ADC_SLOW); addChannel("fuel", engineConfiguration->fuelLevelSensor, ADC_SLOW);
addChannel("pPS", engineConfiguration->pedalPositionChannel, ADC_SLOW); addChannel("pPS", engineConfiguration->pedalPositionChannel, ADC_SLOW);
addChannel("VBatt", engineConfiguration->vbattAdcChannel, ADC_SLOW); addChannel("VBatt", engineConfiguration->vbattAdcChannel, ADC_SLOW);

View File

@ -170,8 +170,8 @@ void adc_callback_fast(ADCDriver *adcp, adcsample_t *buffer, size_t n) {
hipAdcCallback(fastAdc.samples[hipSampleIndex]); hipAdcCallback(fastAdc.samples[hipSampleIndex]);
} }
#endif #endif
if(tpsSampleIndex!=TPS_IS_SLOW) { if (tpsSampleIndex != TPS_IS_SLOW) {
tpsFastAdc = fastAdc.samples[tpsSampleIndex]; // tpsFastAdc = fastAdc.samples[tpsSampleIndex];
} }
} }
} }

View File

@ -275,5 +275,5 @@ int getRusEfiVersion(void) {
return 123; // this is here to make the compiler happy about the unused array return 123; // this is here to make the compiler happy about the unused array
if (UNUSED_CCM_SIZE[0] * 0 != 0) if (UNUSED_CCM_SIZE[0] * 0 != 0)
return 3211; // this is here to make the compiler happy about the unused array return 3211; // this is here to make the compiler happy about the unused array
return 20160128; return 20160131;
} }

View File

@ -35,12 +35,12 @@ void testTps(void) {
engineConfiguration->tpsMin = 43; engineConfiguration->tpsMin = 43;
engineConfiguration->tpsMax = 193; engineConfiguration->tpsMax = 193;
assertEquals(49.3333, getTpsValue(117 PASS_ENGINE_PARAMETER)); assertEquals(49.3333, getTpsValue(4 * 117 PASS_ENGINE_PARAMETER));
engineConfiguration->tpsMin = 193; engineConfiguration->tpsMin = 193;
engineConfiguration->tpsMax = 43; 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) { void testTpsRateOfChange(void) {

View File

@ -20,6 +20,7 @@
#include "algo.h" #include "algo.h"
#include "trigger_mazda.h" #include "trigger_mazda.h"
#include "trigger_chrysler.h" #include "trigger_chrysler.h"
#include "tps.h"
#include "trigger_central.h" #include "trigger_central.h"
#include "main_trigger_callback.h" #include "main_trigger_callback.h"
@ -252,11 +253,11 @@ static void testStartupFuelPumping(void) {
engine->engineConfiguration->tpsMin = 0; engine->engineConfiguration->tpsMin = 0;
engine->engineConfiguration->tpsMax = 10; engine->engineConfiguration->tpsMax = 10;
mockTps = 6; mockTps = TPS_TS_CONVERSION * 6;
sf.update(PASS_ENGINE_PARAMETER_F); sf.update(PASS_ENGINE_PARAMETER_F);
assertEqualsM("pc#1", 1, sf.pumpsCounter); assertEqualsM("pc#1", 1, sf.pumpsCounter);
mockTps = 3; mockTps = TPS_TS_CONVERSION * 3;
sf.update(PASS_ENGINE_PARAMETER_F); sf.update(PASS_ENGINE_PARAMETER_F);
assertEqualsM("pc#2", 1, sf.pumpsCounter); assertEqualsM("pc#2", 1, sf.pumpsCounter);
@ -267,16 +268,16 @@ static void testStartupFuelPumping(void) {
sf.update(PASS_ENGINE_PARAMETER_F); sf.update(PASS_ENGINE_PARAMETER_F);
assertEqualsM("pc#4", 0, sf.pumpsCounter); assertEqualsM("pc#4", 0, sf.pumpsCounter);
mockTps = 7; mockTps = TPS_TS_CONVERSION * 7;
engine->rpmCalculator.mockRpm = 0; engine->rpmCalculator.mockRpm = 0;
sf.update(PASS_ENGINE_PARAMETER_F); sf.update(PASS_ENGINE_PARAMETER_F);
assertEqualsM("pc#5", 1, sf.pumpsCounter); assertEqualsM("pc#5", 1, sf.pumpsCounter);
mockTps = 3; mockTps = TPS_TS_CONVERSION * 3;
sf.update(PASS_ENGINE_PARAMETER_F); sf.update(PASS_ENGINE_PARAMETER_F);
assertEqualsM("pc#6", 1, sf.pumpsCounter); assertEqualsM("pc#6", 1, sf.pumpsCounter);
mockTps = 7; mockTps = TPS_TS_CONVERSION * 7;
sf.update(PASS_ENGINE_PARAMETER_F); sf.update(PASS_ENGINE_PARAMETER_F);
assertEqualsM("pc#7", 2, sf.pumpsCounter); assertEqualsM("pc#7", 2, sf.pumpsCounter);
} }