Add unit test for basic TAE
This commit is contained in:
parent
d7ccf4945b
commit
3bd945f546
|
@ -15,7 +15,8 @@ framework=arduino
|
|||
build_unflags = -Os
|
||||
build_flags = -O3 -ffast-math -fshort-enums -funroll-loops -Wall -Wextra -std=c99
|
||||
lib_deps = EEPROM, Time
|
||||
test_build_project_src = true
|
||||
;test_build_project_src = true
|
||||
test_build_src = yes
|
||||
debug_tool = simavr
|
||||
test_ignore = test_table3d_native
|
||||
|
||||
|
@ -26,7 +27,7 @@ framework=arduino
|
|||
build_unflags = -Os
|
||||
build_flags = -O3 -ffast-math -Wall -Wextra -std=c99
|
||||
lib_deps = EEPROM, Time
|
||||
test_build_project_src = true
|
||||
test_build_src = yes
|
||||
|
||||
[env:teensy35]
|
||||
;platform=teensy
|
||||
|
|
|
@ -365,7 +365,7 @@ uint16_t correctionAccel()
|
|||
else if(configPage2.aeMode == AE_MODE_TPS)
|
||||
{
|
||||
//Get the TPS rate change
|
||||
TPS_change = (currentStatus.TPS - TPSlast);
|
||||
TPS_change = (currentStatus.TPS - currentStatus.TPSlast);
|
||||
//TPS_rateOfChange = ldiv(1000000, (TPS_time - TPSlast_time)).quot * TPS_change; //This is the % per second that the TPS has moved
|
||||
TPS_rateOfChange = (TPS_READ_FREQUENCY * TPS_change) / 2; //This is the % per second that the TPS has moved, adjusted for the 0.5% resolution of the TPS
|
||||
if(TPS_rateOfChange >= 0) { currentStatus.tpsDOT = TPS_rateOfChange / 10; } //The TAE bins are divided by 10 in order to allow them to be stored in a byte
|
||||
|
|
|
@ -637,6 +637,7 @@ struct statuses {
|
|||
byte TPS; /**< The current TPS reading (0% - 100%). Is the tpsADC value after the calibration is applied */
|
||||
byte tpsADC; /**< byte (valued: 0-255) representation of the TPS. Downsampled from the original 10-bit (0-1023) reading, but before any calibration is applied */
|
||||
byte tpsDOT; /**< TPS delta over time. Measures the % per second that the TPS is changing. Value is divided by 10 to be stored in a byte */
|
||||
byte TPSlast; /**< The previous TPS reading */
|
||||
byte mapDOT; /**< MAP delta over time. Measures the kpa per second that the MAP is changing. Value is divided by 10 to be stored in a byte */
|
||||
volatile int rpmDOT; /**< RPM delta over time (RPM increase / s ?) */
|
||||
byte VE; /**< The current VE value being used in the fuel calculation. Can be the same as VE1 or VE2, or a calculated value of both. */
|
||||
|
|
|
@ -52,9 +52,6 @@ unsigned long EMAPrunningValue; //As above but for EMAP
|
|||
unsigned int MAPcount; //Number of samples taken in the current MAP cycle
|
||||
uint32_t MAPcurRev; //Tracks which revolution we're sampling on
|
||||
bool auxIsEnabled;
|
||||
byte TPSlast; /**< The previous TPS reading */
|
||||
unsigned long TPS_time; //The time the TPS sample was taken
|
||||
unsigned long TPSlast_time; //The time the previous TPS sample was taken
|
||||
uint16_t MAPlast; /**< The previous MAP reading */
|
||||
unsigned long MAP_time; //The time the MAP sample was taken
|
||||
unsigned long MAPlast_time; //The time the previous MAP sample was taken
|
||||
|
|
|
@ -397,8 +397,7 @@ static inline void readMAP()
|
|||
|
||||
void readTPS(bool useFilter)
|
||||
{
|
||||
TPSlast = currentStatus.TPS;
|
||||
TPSlast_time = TPS_time;
|
||||
currentStatus.TPSlast = currentStatus.TPS;
|
||||
#if defined(ANALOG_ISR)
|
||||
byte tempTPS = fastMap1023toX(AnChannel[pinTPS-A0], 255); //Get the current raw TPS ADC value and map it into a byte
|
||||
#else
|
||||
|
@ -439,7 +438,6 @@ void readTPS(bool useFilter)
|
|||
else { currentStatus.CTPSActive = digitalRead(pinCTPS); } //Inverted mode (5v activates closed throttle position sensor)
|
||||
}
|
||||
else { currentStatus.CTPSActive = 0; }
|
||||
TPS_time = micros();
|
||||
}
|
||||
|
||||
void readCLT(bool useFilter)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
#include <Arduino.h>
|
||||
#include <globals.h>
|
||||
#include <unity.h>
|
||||
|
||||
#include "missing_tooth/missing_tooth.h"
|
||||
|
|
|
@ -8,6 +8,7 @@ void testCorrections()
|
|||
{
|
||||
test_corrections_WUE();
|
||||
test_corrections_dfco();
|
||||
test_corrections_TAE(); //TPS based accel enrichment corrections
|
||||
/*
|
||||
RUN_TEST(test_corrections_cranking); //Not written yet
|
||||
RUN_TEST(test_corrections_ASE); //Not written yet
|
||||
|
@ -140,7 +141,7 @@ void setup_DFCO_on()
|
|||
correctionDFCO();
|
||||
dfcoTaper = 20;
|
||||
}
|
||||
|
||||
//**********************************************************************************************************************
|
||||
void test_corrections_dfco_on(void)
|
||||
{
|
||||
//Test under ideal conditions that DFCO goes active
|
||||
|
@ -185,3 +186,72 @@ void test_corrections_dfco()
|
|||
RUN_TEST(test_corrections_dfco_off_TPS);
|
||||
RUN_TEST(test_corrections_dfco_off_delay);
|
||||
}
|
||||
//**********************************************************************************************************************
|
||||
//Setup a basic TAE enrichment curve, threshold etc that are common to all tests. Specifica values maybe updated in each individual test
|
||||
void test_corrections_TAE_setup()
|
||||
{
|
||||
configPage2.aeMode = AE_MODE_TPS; //Set AE to TPS
|
||||
|
||||
configPage4.taeValues[0] = 70;
|
||||
configPage4.taeValues[1] = 103;
|
||||
configPage4.taeValues[2] = 124;
|
||||
configPage4.taeValues[3] = 136;
|
||||
|
||||
//Note: These values are divided by 10
|
||||
configPage4.taeBins[0] = 0;
|
||||
configPage4.taeBins[1] = 8;
|
||||
configPage4.taeBins[2] = 22;
|
||||
configPage4.taeBins[3] = 97;
|
||||
|
||||
configPage2.taeThresh = 0;
|
||||
|
||||
//Divided by 100
|
||||
configPage2.aeTaperMin = 10; //1000
|
||||
configPage2.aeTaperMax = 50; //5000
|
||||
|
||||
BIT_CLEAR(currentStatus.engine, BIT_ENGINE_ACC); //Make sure AE is turned off
|
||||
}
|
||||
|
||||
void test_corrections_TAE_no_taper()
|
||||
{
|
||||
//Disable the taper
|
||||
currentStatus.RPM = 2000;
|
||||
configPage2.aeTaperMin = 50; //5000
|
||||
configPage2.aeTaperMax = 60; //6000
|
||||
|
||||
currentStatus.TPSlast = 0;
|
||||
currentStatus.TPS = 50; //25% actual value
|
||||
|
||||
uint16_t accelValue = correctionAccel(); //Run the AE calcs
|
||||
|
||||
TEST_ASSERT_EQUAL(75, currentStatus.tpsDOT); //DOT is 750%/s (25 * 30), value divided by 10;
|
||||
TEST_ASSERT_EQUAL((100+132), accelValue);
|
||||
|
||||
}
|
||||
|
||||
void test_corrections_TAE_50pc_taper()
|
||||
{
|
||||
//RPM is 50% of the way through the taper range
|
||||
currentStatus.RPM = 3000;
|
||||
configPage2.aeTaperMin = 10; //1000
|
||||
configPage2.aeTaperMax = 50; //5000
|
||||
|
||||
currentStatus.TPSlast = 0;
|
||||
currentStatus.TPS = 50; //25% actual value
|
||||
|
||||
uint16_t accelValue = correctionAccel(); //Run the AE calcs
|
||||
|
||||
TEST_ASSERT_EQUAL(75, currentStatus.tpsDOT); //DOT is 750%/s (25 * 30), value divided by 10;
|
||||
TEST_ASSERT_EQUAL((100+66), accelValue);
|
||||
|
||||
}
|
||||
|
||||
void test_corrections_TAE()
|
||||
{
|
||||
test_corrections_TAE_setup();
|
||||
|
||||
|
||||
RUN_TEST(test_corrections_TAE_no_taper);
|
||||
BIT_CLEAR(currentStatus.engine, BIT_ENGINE_ACC); //Flag must be cleared between tests
|
||||
RUN_TEST(test_corrections_TAE_50pc_taper);
|
||||
}
|
|
@ -9,4 +9,5 @@ void test_corrections_bat(void);
|
|||
void test_corrections_iatdensity(void);
|
||||
void test_corrections_baro(void);
|
||||
void test_corrections_launch(void);
|
||||
void test_corrections_dfco(void);
|
||||
void test_corrections_dfco(void);
|
||||
void test_corrections_TAE(void);
|
Loading…
Reference in New Issue