From 4340e58fa399017b6bdde49411d43a86bc0fdce3 Mon Sep 17 00:00:00 2001 From: Josh Stewart Date: Mon, 21 Aug 2017 11:50:50 +1000 Subject: [PATCH] Add very lite filter to the cycle average MAP sampling --- speeduino/sensors.ino | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/speeduino/sensors.ino b/speeduino/sensors.ino index 7eee44d2..a4e60f06 100644 --- a/speeduino/sensors.ino +++ b/speeduino/sensors.ino @@ -98,7 +98,9 @@ void readMAP() //Error check if( (tempReading < VALID_MAP_MAX) && (tempReading > VALID_MAP_MIN) ) { - MAPrunningValue = MAPrunningValue + (unsigned long)tempReading; //Add the current reading onto the total + currentStatus.mapADC = ADC_FILTER(tempReading, ADCFILTER_MAP, currentStatus.mapADC); + MAPrunningValue += currentStatus.mapADC; //Add the current reading onto the total + //MAPrunningValue = MAPrunningValue + (unsigned long)tempReading; //Add the current reading onto the total MAPcount++; } else { mapErrorCount += 1; } @@ -111,6 +113,7 @@ void readMAP() { currentStatus.mapADC = ldiv(MAPrunningValue, MAPcount).quot; currentStatus.MAP = fastMap10Bit(currentStatus.mapADC, configPage1.mapMin, configPage1.mapMax); //Get the current MAP value + //currentStatus.MAP = fastMap1023toX(currentStatus.mapADC, configPage1.mapMax); if(currentStatus.MAP < 0) { currentStatus.MAP = 0; } //Sanity check MAPcurRev = currentStatus.startRevolutions; //Reset the current rev count MAPrunningValue = 0;