More than one aux pid #866

progress!
This commit is contained in:
rusefi 2019-07-12 08:31:38 -04:00
parent 8dcb49bdf9
commit 4b0ed3751f
4 changed files with 26 additions and 3 deletions

View File

@ -63,6 +63,7 @@ public:
this->index = index; this->index = index;
pid_s *auxPidS = &persistentState.persistentConfiguration.engineConfiguration.auxPid[index]; pid_s *auxPidS = &persistentState.persistentConfiguration.engineConfiguration.auxPid[index];
auxPid.initPidClass(auxPidS); auxPid.initPidClass(auxPidS);
table = getFSIOTable(index);
} }
int getPeriodMs() override { int getPeriodMs() override {
@ -87,8 +88,8 @@ public:
} }
float value = engine->triggerCentral.vvtPosition; // getVBatt(PASS_ENGINE_PARAMETER_SIGNATURE); // that's temporary float value = engine->triggerCentral.vvtPosition;
float targetValue = fsioTable1.getValue(rpm, getEngineLoadT(PASS_ENGINE_PARAMETER_SIGNATURE)); float targetValue = table->getValue(rpm, getEngineLoadT(PASS_ENGINE_PARAMETER_SIGNATURE));
percent_t pwm = auxPid.getOutput(targetValue, value); percent_t pwm = auxPid.getOutput(targetValue, value);
if (engineConfiguration->isVerboseAuxPid1) { if (engineConfiguration->isVerboseAuxPid1) {
@ -109,6 +110,7 @@ public:
private: private:
Pid auxPid; Pid auxPid;
int index = 0; int index = 0;
ValueProvider3D *table = NULL;
}; };
static AuxPidController instances[AUX_PID_COUNT]; static AuxPidController instances[AUX_PID_COUNT];

View File

@ -636,6 +636,19 @@ static void rpnEval(char *line) {
#endif #endif
} }
ValueProvider3D *getFSIOTable(int index) {
switch (index) {
default:
return &fsioTable1;
case 1:
return &fsioTable2;
case 2:
return &fsioTable3;
case 3:
return &fsioTable4;
}
}
void initFsioImpl(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) { void initFsioImpl(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) {
#if EFI_PROD_CODE || EFI_SIMULATOR #if EFI_PROD_CODE || EFI_SIMULATOR
logger = sharedLogger; logger = sharedLogger;

View File

@ -30,4 +30,6 @@ float getFsioOutputValue(int index DECLARE_ENGINE_PARAMETER_SUFFIX);
void applyFsioConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE); void applyFsioConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE);
void onConfigurationChangeFsioCallback(engine_configuration_s *previousConfiguration DECLARE_ENGINE_PARAMETER_SUFFIX); void onConfigurationChangeFsioCallback(engine_configuration_s *previousConfiguration DECLARE_ENGINE_PARAMETER_SUFFIX);
ValueProvider3D *getFSIOTable(int index);
#endif /* LE_FUNCTIONS_H_ */ #endif /* LE_FUNCTIONS_H_ */

View File

@ -15,11 +15,17 @@
// popular left edge of CLT-based correction curves // popular left edge of CLT-based correction curves
#define CLT_CURVE_RANGE_FROM -40 #define CLT_CURVE_RANGE_FROM -40
class ValueProvider3D {
public:
virtual float getValue(float xRpm, float y) = 0;
};
/** /**
* this helper class brings together 3D table with two 2D axis curves * this helper class brings together 3D table with two 2D axis curves
*/ */
template<int RPM_BIN_SIZE, int LOAD_BIN_SIZE, typename vType, typename kType> template<int RPM_BIN_SIZE, int LOAD_BIN_SIZE, typename vType, typename kType>
class Map3D { class Map3D : public ValueProvider3D {
public: public:
explicit Map3D(const char*name); explicit Map3D(const char*name);
Map3D(const char*name, float multiplier); Map3D(const char*name, float multiplier);