mirror of https://github.com/rusefi/rusefi-1.git
auto-sync
This commit is contained in:
parent
5f2eb115fb
commit
a8836cfc30
|
@ -6,8 +6,10 @@
|
|||
*/
|
||||
|
||||
#include "aux_pid.h"
|
||||
#include "LocalVersionHolder.h"
|
||||
|
||||
#if EFI_AUX_PID || defined(__DOXYGEN__)
|
||||
#include "pwm_generator.h"
|
||||
|
||||
EXTERN_ENGINE
|
||||
;
|
||||
|
@ -17,6 +19,12 @@ EXTERN_ENGINE
|
|||
|
||||
static THD_WORKING_AREA(auxPidThreadStack, UTILITY_THREAD_STACK_SIZE);
|
||||
|
||||
static LocalVersionHolder parametersVersion;
|
||||
static SimplePwm auxPid1;
|
||||
static OutputPin auxPid1Pin;
|
||||
static pid_s *altPidS = &persistentState.persistentConfiguration.engineConfiguration.alternatorControl;
|
||||
static Pid altPid(altPidS, 1, 90);
|
||||
|
||||
static msg_t auxPidThread(int param) {
|
||||
UNUSED(param);
|
||||
chRegSetThreadName("AuxPidController");
|
||||
|
@ -24,6 +32,10 @@ static msg_t auxPidThread(int param) {
|
|||
int dt = maxI(10, engineConfiguration->auxPid1DT);
|
||||
chThdSleepMilliseconds(dt);
|
||||
|
||||
if (parametersVersion.isOld())
|
||||
altPid.reset();
|
||||
|
||||
|
||||
|
||||
}
|
||||
#if defined __GNUC__
|
||||
|
@ -35,6 +47,17 @@ void initAuxPid(Logging *sharedLogger) {
|
|||
chThdCreateStatic(auxPidThreadStack, sizeof(auxPidThreadStack), LOWPRIO,
|
||||
(tfunc_t) auxPidThread, NULL);
|
||||
|
||||
if (engineConfiguration->activateAuxPid1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (boardConfiguration->fsioPins[0] == GPIO_UNASSIGNED) {
|
||||
return;
|
||||
}
|
||||
|
||||
startSimplePwmExt(&auxPid1, "Aux PID", boardConfiguration->fsioPins[0],
|
||||
&auxPid1Pin,
|
||||
boardConfiguration->fsioFrequency[0], 0.1, applyPinState);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -19,6 +19,8 @@ template<int RPM_BIN_SIZE, int LOAD_BIN_SIZE, typename vType>
|
|||
class Map3D {
|
||||
public:
|
||||
Map3D(const char*name);
|
||||
Map3D(const char*name, float multiplier);
|
||||
void create(const char*name, float multiplier);
|
||||
void init(vType table[RPM_BIN_SIZE][LOAD_BIN_SIZE], float loadBins[LOAD_BIN_SIZE], float rpmBins[RPM_BIN_SIZE]);
|
||||
float getValue(float xRpm, float y);
|
||||
void setAll(vType value);
|
||||
|
@ -28,6 +30,7 @@ private:
|
|||
float *rpmBins;
|
||||
bool initialized;
|
||||
const char *name;
|
||||
float multiplier;
|
||||
};
|
||||
|
||||
template<int SIZE>
|
||||
|
@ -90,12 +93,23 @@ float Map3D<RPM_BIN_SIZE, LOAD_BIN_SIZE, vType>::getValue(float xRpm, float y) {
|
|||
return NAN;
|
||||
}
|
||||
// todo: we have a bit of a mess: in TunerStudio, RPM is X-axis
|
||||
return interpolate3d<vType>(y, loadBins, LOAD_BIN_SIZE, xRpm, rpmBins, RPM_BIN_SIZE, pointers);
|
||||
return multiplier * interpolate3d<vType>(y, loadBins, LOAD_BIN_SIZE, xRpm, rpmBins, RPM_BIN_SIZE, pointers);
|
||||
}
|
||||
|
||||
template<int RPM_BIN_SIZE, int LOAD_BIN_SIZE, typename vType>
|
||||
Map3D<RPM_BIN_SIZE, LOAD_BIN_SIZE, vType>::Map3D(const char *name) {
|
||||
create(name, 1);
|
||||
}
|
||||
|
||||
template<int RPM_BIN_SIZE, int LOAD_BIN_SIZE, typename vType>
|
||||
Map3D<RPM_BIN_SIZE, LOAD_BIN_SIZE, vType>::Map3D(const char *name, float multiplier) {
|
||||
create(name, multiplier);
|
||||
}
|
||||
|
||||
template<int RPM_BIN_SIZE, int LOAD_BIN_SIZE, typename vType>
|
||||
void Map3D<RPM_BIN_SIZE, LOAD_BIN_SIZE, vType>::create(const char *name, float multiplier) {
|
||||
this->name = name;
|
||||
this->multiplier = multiplier;
|
||||
initialized = false;
|
||||
memset(&pointers, 0, sizeof(pointers));
|
||||
loadBins = NULL;
|
||||
|
@ -107,7 +121,7 @@ void Map3D<RPM_BIN_SIZE, LOAD_BIN_SIZE, vType>::setAll(vType value) {
|
|||
efiAssertVoid(initialized, "map not initialized");
|
||||
for (int l = 0; l < LOAD_BIN_SIZE; l++) {
|
||||
for (int r = 0; r < RPM_BIN_SIZE; r++) {
|
||||
pointers[l][r] = value;
|
||||
pointers[l][r] = value / multiplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -289,7 +289,7 @@ void firmwareError(const char *errorMsg, ...) {
|
|||
}
|
||||
}
|
||||
|
||||
static char UNUSED_RAM_SIZE[200];
|
||||
static char UNUSED_RAM_SIZE[100];
|
||||
|
||||
static char UNUSED_CCM_SIZE[3600] CCM_OPTIONAL;
|
||||
|
||||
|
|
|
@ -1624,6 +1624,7 @@ cmd_test_idle_valve = "w\x00\x17\x00\x01"
|
|||
dialog = auxPidDialog, "Aux PID"
|
||||
field = "Enabled", activateAuxPid1
|
||||
field = "FSIO pin #1", fsioPins1
|
||||
field = "PWM Frequency", fsioFrequency1
|
||||
field = "#target based on FSIO map#1"
|
||||
field = "control period", auxPid1DT, {activateAuxPid1 == 1}
|
||||
field = "#PID control"
|
||||
|
|
Loading…
Reference in New Issue