auto-sync

This commit is contained in:
rusEfi 2015-02-09 14:06:05 -06:00
parent 11c4ad9d3d
commit fc3b585438
5 changed files with 49 additions and 32 deletions

View File

@ -50,7 +50,6 @@ Engine::Engine() {
}
void Engine::precalc(engine_configuration_s *engineConfiguration) {
sparkTable.init(DWELL_CURVE_SIZE, sparkAtable, sparkBtable);
sparkTable.preCalc(engineConfiguration->sparkDwellBins, engineConfiguration->sparkDwell);
}

View File

@ -83,6 +83,10 @@ typedef struct {
adc_channel_e channel;
} Thermistor;
#define MAF_DECODING_CACHE_SIZE 256
#define MAF_DECODING_CACHE_MULT (MAF_DECODING_CACHE_SIZE / 5.0)
class Engine {
public:
Engine();
@ -112,6 +116,11 @@ public:
TriggerShape triggerShape;
/**
* pre-calculated offset for given sequence index within engine cycle
* not cylinder ID
* todo: better name?
*/
float angleExtra[IGNITION_PIN_COUNT];
NamedOutputPin *ignitionPin[IGNITION_PIN_COUNT];
@ -142,10 +151,22 @@ public:
uint32_t beforeIgnitionSch;
uint32_t ignitionSchTime;
float sparkAtable[DWELL_CURVE_SIZE];
float sparkBtable[DWELL_CURVE_SIZE];
/**
* fast spark dwell time interpolation helper
* todo: finish the implementation and
*/
Table2D<DWELL_CURVE_SIZE> sparkTable;
/**
* fast MAF decoding lookup table with ~0.2 volt step
* This table is build based on MAF decoding curve
*/
float mafDecodingLookup[MAF_DECODING_CACHE_SIZE];
float mafDecoding[MAF_DECODING_COUNT];
float mafDecodingBins[MAF_DECODING_COUNT];
Table2D sparkTable;
void precalc(engine_configuration_s *engineConfiguration);
void updateSlowSensors();

View File

@ -50,6 +50,8 @@ typedef void (*Void)(void);
#define LE_COMMAND_LENGTH 200
#define LE_COMMAND_COUNT 16
#define MAF_DECODING_COUNT 256
typedef char le_formula_t[LE_COMMAND_LENGTH];
#define HW_MAX_ADC_INDEX 16

View File

@ -20,30 +20,6 @@ void setTableBin2(float array[], int size, float l, float r, float precision) {
}
}
void Table2D::init(int size, float *aTable, float *bTable) {
this->size = size;
this->aTable = aTable;
this->bTable = bTable;
}
void Table2D::preCalc(float *bin, float *values) {
this->bin = bin;
for (int i = 0; i < size - 1; i++) {
float x1 = bin[i];
float x2 = bin[i + 1];
if (x1 == x2) {
firmwareError("Same x1 and x2 in interpolate: %f/%f", x1, x2);
return;
}
float y1 = values[i];
float y2 = values[i + 1];
aTable[i] = INTERPOLATION_A(x1, y1, x2, y2);
bTable[i] = y1 - aTable[i] * x1;
}
}
void setTableBin(float array[], int size, float from, float to) {
setTableBin2(array, size, from, to, 0.01);
}

View File

@ -25,16 +25,35 @@ private:
int initialized;
};
template<int SIZE>
class Table2D {
public:
void init(int size, float *aTable, float *bTable);
void preCalc(float *bin, float *values);
int size;
float *aTable;
float *bTable;
float aTable[SIZE];
float bTable[SIZE];
float *bin;
};
template<int SIZE>
void Table2D<SIZE>::preCalc(float *bin, float *values) {
this->bin = bin;
for (int i = 0; i < SIZE - 1; i++) {
float x1 = bin[i];
float x2 = bin[i + 1];
if (x1 == x2) {
firmwareError("Same x1 and x2 in interpolate: %f/%f", x1, x2);
return;
}
float y1 = values[i];
float y2 = values[i + 1];
aTable[i] = INTERPOLATION_A(x1, y1, x2, y2);
bTable[i] = y1 - aTable[i] * x1;
}
}
template<int RPM_BIN_SIZE, int LOAD_BIN_SIZE>
void Map3D<RPM_BIN_SIZE, LOAD_BIN_SIZE>::init(float table[RPM_BIN_SIZE][LOAD_BIN_SIZE]) {
for (int k = 0; k < LOAD_BIN_SIZE; k++) {