From bd0c8d3d5fc1d216475ac223e71199a80895fa09 Mon Sep 17 00:00:00 2001 From: Fred Cooke Date: Thu, 29 May 2014 18:56:23 +1200 Subject: [PATCH] Add hotel TPS config current throttle opening. This is narrower than full range due to being propped open for a more stable idle. With an idle valve, this will widen a little. Also handle reverse slope TPS inputs automatically. --- src/main/coreVarsGenerator.c | 23 +++++++++++++++++------ src/main/init.c | 6 +++++- src/main/initialisers/FixedConfig2.c | 16 +++++++++------- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/src/main/coreVarsGenerator.c b/src/main/coreVarsGenerator.c index 681e2ca..a4e2ae2 100644 --- a/src/main/coreVarsGenerator.c +++ b/src/main/coreVarsGenerator.c @@ -87,11 +87,23 @@ void generateCoreVars(){ // Throttle Position Sensor /* Bound the TPS ADC reading and shift it to start at zero */ unsigned short unboundedTPSADC = ADCBuffers->TPS; - unsigned short boundedTPSADC = 0; - if(unboundedTPSADC > fixedConfigs2.sensorRanges.TPSMaximumADC){ - boundedTPSADC = TPSADCRange; - }else if(unboundedTPSADC > fixedConfigs2.sensorRanges.TPSMinimumADC){ - boundedTPSADC = unboundedTPSADC - fixedConfigs2.sensorRanges.TPSMinimumADC; + unsigned short boundedTPSADC; + if(fixedConfigs2.sensorRanges.TPSMaximumADC > fixedConfigs2.sensorRanges.TPSMinimumADC){ + if(unboundedTPSADC > fixedConfigs2.sensorRanges.TPSMaximumADC){ + boundedTPSADC = TPSADCRange; + }else if(unboundedTPSADC > fixedConfigs2.sensorRanges.TPSMinimumADC){ + boundedTPSADC = unboundedTPSADC - fixedConfigs2.sensorRanges.TPSMinimumADC; + } else{ + boundedTPSADC = 0; + } + }else{ // Reverse slope! + if(unboundedTPSADC > fixedConfigs2.sensorRanges.TPSMinimumADC){ + boundedTPSADC = 0; + }else if(unboundedTPSADC > fixedConfigs2.sensorRanges.TPSMaximumADC){ + boundedTPSADC = fixedConfigs2.sensorRanges.TPSMinimumADC - unboundedTPSADC; + }else{ + boundedTPSADC = TPSADCRange; + } } /* Get TPS from ADC no need to add TPS min as we know it is zero by definition */ @@ -99,7 +111,6 @@ void generateCoreVars(){ // TODO fail safe mode, only if on the ADC rails AND configured to do so // Default to a low value that will get you home if you are in Alpha-N mode - /* Get RPM by locking out ISRs for a second and grabbing the Tooth logging data */ //atomic start // copy rpm data diff --git a/src/main/init.c b/src/main/init.c index 0ab0319..5d6e09b 100644 --- a/src/main/init.c +++ b/src/main/init.c @@ -660,7 +660,11 @@ void initConfiguration(){ bootFuelConst = ((unsigned long)(masterFuelConstant / fixedConfigs1.engineSettings.injectorFlow) * fixedConfigs1.engineSettings.perCylinderVolume) / fixedConfigs1.engineSettings.stoichiometricAFR; /* The ADC range used to generate TPS percentage */ - TPSADCRange = fixedConfigs2.sensorRanges.TPSMaximumADC - fixedConfigs2.sensorRanges.TPSMinimumADC; + if(fixedConfigs2.sensorRanges.TPSMaximumADC > fixedConfigs2.sensorRanges.TPSMinimumADC){ + TPSADCRange = fixedConfigs2.sensorRanges.TPSMaximumADC - fixedConfigs2.sensorRanges.TPSMinimumADC; + }else{ + TPSADCRange = fixedConfigs2.sensorRanges.TPSMinimumADC - fixedConfigs2.sensorRanges.TPSMaximumADC; + } } diff --git a/src/main/initialisers/FixedConfig2.c b/src/main/initialisers/FixedConfig2.c index 4b2363c..0994f17 100644 --- a/src/main/initialisers/FixedConfig2.c +++ b/src/main/initialisers/FixedConfig2.c @@ -121,17 +121,19 @@ const volatile fixedConfig2 fixedConfigs2 FIXEDCONF2 = { BRVMinimum: VOLTS(0), BRVRange: VOLTS(24.5), // Standard 3.9k and 1k values. #endif -#if CONFIG == DEUCECOUPE_ID // This is calibrated for the Deuce Coupe TPS. - TPSMinimumADC: 81, // This is to correct for the TPS reading at closed throttle. - TPSMaximumADC: 574 // This is to correct for the TPS reading at wide open throttle. - +#if CONFIG == HOTEL_ID + TPSMinimumADC: 913, // Idle! The hotel has a reversed TPS slope on purpose for code testing + TPSMaximumADC: 0 // WOT! So these values are backward compared to normal +#elif CONFIG == DEUCECOUPE_ID + TPSMinimumADC: 81, // Idle + TPSMaximumADC: 574 // WOT #elif CONFIG == DEUCES10_ID // This is an estimate for the S10 TPS. - TPSMinimumADC: 120, // This is to correct for the TPS reading at closed throttle. - TPSMaximumADC: 560 // This is to correct for the TPS reading at wide open throttle. + TPSMinimumADC: 120, // Idle + TPSMaximumADC: 560 // WOT #elif CONFIG == SNOTROCKET_ID TPSMinimumADC: 185, TPSMaximumADC: 809 -#else +#else // Default for a normal TPS slope TPSMinimumADC: 0, TPSMaximumADC: ADC_MAX_VALUE #endif -- 2.11.4.GIT