auto-sync
This commit is contained in:
parent
b68de96fb1
commit
32a707db5f
|
@ -34,10 +34,9 @@ EXTERN_ENGINE
|
|||
|
||||
/**
|
||||
* We are executing these heavy (logarithm) methods from outside the trigger callbacks for performance reasons.
|
||||
* See also periodicFastCallback
|
||||
*/
|
||||
void Engine::updateSlowSensors() {
|
||||
Engine *engine = this;
|
||||
board_configuration_s * boardConfiguration = &engineConfiguration->bc;
|
||||
void Engine::updateSlowSensors(DECLARE_ENGINE_PARAMETER_F) {
|
||||
engineState.iat = getIntakeAirTemperature(PASS_ENGINE_PARAMETER_F);
|
||||
engineState.clt = getCoolantTemperature(PASS_ENGINE_PARAMETER_F);
|
||||
|
||||
|
@ -97,8 +96,21 @@ Engine::Engine(persistent_config_s *config) {
|
|||
|
||||
EngineState::EngineState() {
|
||||
advance = dwellAngle = 0;
|
||||
engineNoiseHipLevel = 0;
|
||||
}
|
||||
|
||||
void EngineState::periodicFastCallback(DECLARE_ENGINE_PARAMETER_F) {
|
||||
int rpm = ENGINE(rpmCalculator.rpmValue);
|
||||
|
||||
sparkDwell = getSparkDwell(rpm PASS_ENGINE_PARAMETER);
|
||||
dwellAngle = sparkDwell / getOneDegreeTimeMs(rpm);
|
||||
|
||||
iatFuelCorrection = getIatCorrection(iat PASS_ENGINE_PARAMETER);
|
||||
cltFuelCorrection = getCltCorrection(clt PASS_ENGINE_PARAMETER);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Here we have a bunch of stuff which should invoked after configuration change
|
||||
* so that we can prepare some helper structures
|
||||
|
@ -218,18 +230,36 @@ extern fuel_Map3D_t afrMap;
|
|||
|
||||
/**
|
||||
* The idea of this method is to execute all heavy calculations in a lower-priority thread,
|
||||
* so that trigger event handler/IO scheduler tasks are faster. Th
|
||||
* so that trigger event handler/IO scheduler tasks are faster.
|
||||
*/
|
||||
void Engine::periodicFastCallback(DECLARE_ENGINE_PARAMETER_F) {
|
||||
int rpm = rpmCalculator.rpmValue;
|
||||
float engineLoad = getEngineLoadT(PASS_ENGINE_PARAMETER_F);
|
||||
|
||||
engineState.sparkDwell = getSparkDwellMsT(rpm PASS_ENGINE_PARAMETER);
|
||||
// todo: move this field to engineState
|
||||
engine->engineState.dwellAngle = engineState.sparkDwell / getOneDegreeTimeMs(rpm);
|
||||
if (isValidRpm(rpm)) {
|
||||
MAP_sensor_config_s * c = &engineConfiguration->map;
|
||||
angle_t start = interpolate2d(rpm, c->samplingAngleBins, c->samplingAngle, MAP_ANGLE_SIZE);
|
||||
|
||||
angle_t offsetAngle = TRIGGER_SHAPE(eventAngles[CONFIG(mapAveragingSchedulingAtIndex)]);
|
||||
|
||||
for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) {
|
||||
angle_t cylinderOffset = getEngineCycle(engineConfiguration->operationMode) * i / engineConfiguration->specs.cylindersCount;
|
||||
float cylinderStart = start + cylinderOffset - offsetAngle + tdcPosition();
|
||||
fixAngle(cylinderStart);
|
||||
engine->engineState.mapAveragingStart[i] = cylinderStart;
|
||||
}
|
||||
engine->engineState.mapAveragingDuration = interpolate2d(rpm, c->samplingWindowBins, c->samplingWindow, MAP_WINDOW_SIZE);
|
||||
} else {
|
||||
for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) {
|
||||
engine->engineState.mapAveragingStart[i] = NAN;
|
||||
}
|
||||
engine->engineState.mapAveragingDuration = NAN;
|
||||
}
|
||||
|
||||
engineState.periodicFastCallback(PASS_ENGINE_PARAMETER_F);
|
||||
|
||||
//engineState.engineNoiseHipLevel = interpolate2d(rpm)
|
||||
|
||||
engine->engineState.iatFuelCorrection = getIatCorrection(engine->engineState.iat PASS_ENGINE_PARAMETER);
|
||||
engine->engineState.cltFuelCorrection = getCltCorrection(engine->engineState.clt PASS_ENGINE_PARAMETER);
|
||||
|
||||
engine->engineState.baroCorrection = getBaroCorrection(PASS_ENGINE_PARAMETER_F);
|
||||
|
||||
|
|
|
@ -83,6 +83,8 @@ private:
|
|||
class EngineState {
|
||||
public:
|
||||
EngineState();
|
||||
void periodicFastCallback(DECLARE_ENGINE_PARAMETER_F);
|
||||
|
||||
/**
|
||||
* WIP: accessing these values here would be a performance optimization since log() function needed for
|
||||
* thermistor logic is relatively heavy
|
||||
|
@ -93,6 +95,8 @@ public:
|
|||
|
||||
float airMass;
|
||||
|
||||
float engineNoiseHipLevel;
|
||||
|
||||
/**
|
||||
* that's fuel in tank - just a gauge
|
||||
*/
|
||||
|
@ -221,8 +225,8 @@ public:
|
|||
*/
|
||||
floatms_t actualLastInjection;
|
||||
|
||||
|
||||
void periodicFastCallback(DECLARE_ENGINE_PARAMETER_F);
|
||||
void updateSlowSensors(DECLARE_ENGINE_PARAMETER_F);
|
||||
|
||||
bool_t clutchUpState;
|
||||
bool_t clutchDownState;
|
||||
|
@ -312,7 +316,6 @@ public:
|
|||
void preCalculate();
|
||||
void addConfigurationListener(configuration_callback_t callback);
|
||||
|
||||
void updateSlowSensors();
|
||||
void watchdog();
|
||||
|
||||
/**
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
#include "alternatorController.h"
|
||||
#endif
|
||||
|
||||
#include "hip9011_lookup.h"
|
||||
|
||||
#include "custom_engine.h"
|
||||
#include "acura_rsx.h"
|
||||
#include "audi_aan.h"
|
||||
|
@ -332,6 +334,8 @@ void setDefaultConfiguration(DECLARE_ENGINE_PARAMETER_F) {
|
|||
setFuelTablesLoadBin(10, 160 PASS_ENGINE_PARAMETER);
|
||||
setDefaultIatTimingCorrection(PASS_ENGINE_PARAMETER_F);
|
||||
|
||||
initEngineNoiseTable(PASS_ENGINE_PARAMETER_F);
|
||||
|
||||
setThermistorConfiguration(&engineConfiguration->clt, 0, 9500, 23.8889, 2100, 48.8889, 1000);
|
||||
engineConfiguration->clt.config.bias_resistor = 1500;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Thu Dec 31 17:15:37 EST 2015
|
||||
// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Fri Jan 01 16:03:19 EST 2016
|
||||
// begin
|
||||
#include "rusefi_types.h"
|
||||
typedef struct {
|
||||
|
@ -1356,11 +1356,11 @@ typedef struct {
|
|||
/**
|
||||
* offset 1952
|
||||
*/
|
||||
float knockNoiseBins[8];
|
||||
float knockNoiseBins[ENGINE_NOISE_CURVE_SIZE];
|
||||
/**
|
||||
* offset 1984
|
||||
*/
|
||||
float knockNoise[8];
|
||||
float knockNoise[ENGINE_NOISE_CURVE_SIZE];
|
||||
/**
|
||||
* offset 2016
|
||||
*/
|
||||
|
@ -1605,4 +1605,4 @@ typedef struct {
|
|||
} persistent_config_s;
|
||||
|
||||
// end
|
||||
// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Thu Dec 31 17:15:37 EST 2015
|
||||
// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Fri Jan 01 16:03:19 EST 2016
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#define MAP_ANGLE_SIZE 8
|
||||
#define MAP_WINDOW_SIZE 8
|
||||
#define CLT_CURVE_SIZE 16
|
||||
#define ENGINE_NOISE_CURVE_SIZE 8
|
||||
#define IAT_CURVE_SIZE 16
|
||||
#define VBAT_INJECTOR_CURVE_SIZE 8
|
||||
#define DWELL_CURVE_SIZE 8
|
||||
|
|
|
@ -201,28 +201,6 @@ static void scheduleNextSlowInvocation(void) {
|
|||
}
|
||||
|
||||
static void periodicFastCallback(DECLARE_ENGINE_PARAMETER_F) {
|
||||
int rpm = engine->rpmCalculator.rpmValue;
|
||||
|
||||
if (isValidRpm(rpm)) {
|
||||
MAP_sensor_config_s * c = &engineConfiguration->map;
|
||||
angle_t start = interpolate2d(rpm, c->samplingAngleBins, c->samplingAngle, MAP_ANGLE_SIZE);
|
||||
|
||||
angle_t offsetAngle = TRIGGER_SHAPE(eventAngles[CONFIG(mapAveragingSchedulingAtIndex)]);
|
||||
|
||||
for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) {
|
||||
angle_t cylinderOffset = getEngineCycle(engineConfiguration->operationMode) * i / engineConfiguration->specs.cylindersCount;
|
||||
float cylinderStart = start + cylinderOffset - offsetAngle + tdcPosition();
|
||||
fixAngle(cylinderStart);
|
||||
engine->engineState.mapAveragingStart[i] = cylinderStart;
|
||||
}
|
||||
engine->engineState.mapAveragingDuration = interpolate2d(rpm, c->samplingWindowBins, c->samplingWindow, MAP_WINDOW_SIZE);
|
||||
} else {
|
||||
for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) {
|
||||
engine->engineState.mapAveragingStart[i] = NAN;
|
||||
}
|
||||
engine->engineState.mapAveragingDuration = NAN;
|
||||
}
|
||||
|
||||
engine->periodicFastCallback();
|
||||
|
||||
chVTSetAny(&periodicFastTimer, 20 * TICKS_IN_MS, (vtfunc_t) &periodicFastCallback, engine);
|
||||
|
|
|
@ -219,7 +219,7 @@ void FuelSchedule::addFuelEvents(injection_mode_e mode DECLARE_ENGINE_PARAMETER_
|
|||
/**
|
||||
* @return Spark dwell time, in milliseconds.
|
||||
*/
|
||||
float getSparkDwellMsT(int rpm DECLARE_ENGINE_PARAMETER_S) {
|
||||
floatms_t getSparkDwell(int rpm DECLARE_ENGINE_PARAMETER_S) {
|
||||
if (isCrankingR(rpm)) {
|
||||
if (engineConfiguration->useConstantDwellDuringCranking) {
|
||||
return engineConfiguration->ignitionDwellForCrankingMs;
|
||||
|
|
|
@ -66,7 +66,7 @@ floatms_t getCrankshaftRevolutionTimeMs(int rpm);
|
|||
|
||||
float getEngineLoadT(DECLARE_ENGINE_PARAMETER_F);
|
||||
|
||||
float getSparkDwellMsT(int rpm DECLARE_ENGINE_PARAMETER_S);
|
||||
floatms_t getSparkDwell(int rpm DECLARE_ENGINE_PARAMETER_S);
|
||||
|
||||
int getCylinderId(firing_order_e firingOrder, int index);
|
||||
|
||||
|
|
|
@ -80,3 +80,10 @@ int getHip9011GainIndex(float gain) {
|
|||
int getHip9011BandIndex(float frequency) {
|
||||
return findIndex(bandFreqLookup, BAND_LOOKUP_SIZE, frequency);
|
||||
}
|
||||
|
||||
EXTERN_ENGINE;
|
||||
|
||||
void initEngineNoiseTable(DECLARE_ENGINE_PARAMETER_F) {
|
||||
setRpmTableBin(engineConfiguration->knockNoiseBins, ENGINE_NOISE_CURVE_SIZE);
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#ifndef CONTROLLERS_SENSORS_HIP9011_LOOKUP_H_
|
||||
#define CONTROLLERS_SENSORS_HIP9011_LOOKUP_H_
|
||||
|
||||
#include "engine.h"
|
||||
|
||||
#define INT_LOOKUP_SIZE 32
|
||||
#define GAIN_LOOKUP_SIZE 64
|
||||
#define BAND_LOOKUP_SIZE 64
|
||||
|
@ -28,5 +30,6 @@ void prepareHip9011RpmLookup(float angleWindowWidth);
|
|||
|
||||
extern float rpmLookup[INT_LOOKUP_SIZE];
|
||||
int getIntegrationIndexByRpm(float rpm);
|
||||
void initEngineNoiseTable(DECLARE_ENGINE_PARAMETER_F);
|
||||
|
||||
#endif /* CONTROLLERS_SENSORS_HIP9011_LOOKUP_H_ */
|
||||
|
|
|
@ -27,6 +27,7 @@ struct_no_prefix engine_configuration_s
|
|||
#define MAP_WINDOW_SIZE 8
|
||||
|
||||
#define CLT_CURVE_SIZE 16
|
||||
#define ENGINE_NOISE_CURVE_SIZE 8
|
||||
|
||||
#define IAT_CURVE_SIZE 16
|
||||
|
||||
|
@ -597,8 +598,8 @@ baro_corr_table_t baroCorrTable;
|
|||
brain_pin_e binarySerialRxPin;
|
||||
brain_pin_e consoleSerialTxPin;
|
||||
brain_pin_e consoleSerialRxPin;
|
||||
float[8] knockNoiseBins;
|
||||
float[8] knockNoise;
|
||||
float[ENGINE_NOISE_CURVE_SIZE] knockNoiseBins;
|
||||
float[ENGINE_NOISE_CURVE_SIZE] knockNoise;
|
||||
pid_s etb;
|
||||
|
||||
float[CLT_CURVE_SIZE] cltIdleRpmBins;CLT-based target RPM for automatic idle controller;"C", 1, 0, -100.0, 250.0, 2
|
||||
|
|
|
@ -41,7 +41,7 @@ enable2ndByteCanID = false
|
|||
|
||||
; see PAGE_0_SIZE in C source code
|
||||
; CONFIG_DEFINITION_START
|
||||
; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Thu Dec 31 17:15:37 EST 2015
|
||||
; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Fri Jan 01 16:03:19 EST 2016
|
||||
|
||||
pageSize = 16088
|
||||
page = 1
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.rusefi.config;
|
||||
|
||||
// this file was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Thu Dec 31 16:50:15 EST 2015
|
||||
// this file was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Fri Jan 01 16:03:19 EST 2016
|
||||
public class Fields {
|
||||
public static final Field ENGINETYPE = new Field("ENGINETYPE", 0, FieldType.INT);
|
||||
public static final Field UNUSEDOFFSET4 = new Field("UNUSEDOFFSET4", 4, FieldType.INT);
|
||||
|
@ -458,8 +458,8 @@ public class Fields {
|
|||
public static final Field WARNINIGPIN = new Field("WARNINIGPIN", 2220, FieldType.INT, brain_pin_e);
|
||||
public static final Field CONFIGRESETPIN = new Field("CONFIGRESETPIN", 2224, FieldType.INT, brain_pin_e);
|
||||
public static final Field UARTCONSOLESERIALSPEED = new Field("UARTCONSOLESERIALSPEED", 2228, FieldType.INT);
|
||||
public static final Field TPSDECELENRICHMENTTHRESHOLD = new Field("TPSDECELENRICHMENTTHRESHOLD", 2232, FieldType.FLOAT);
|
||||
public static final Field TPSDECELENRICHMENTMULTIPLIER = new Field("TPSDECELENRICHMENTMULTIPLIER", 2236, FieldType.FLOAT);
|
||||
public static final Field TPSDECELENLEANMENTTHRESHOLD = new Field("TPSDECELENLEANMENTTHRESHOLD", 2232, FieldType.FLOAT);
|
||||
public static final Field TPSDECELENLEANMENTMULTIPLIER = new Field("TPSDECELENLEANMENTMULTIPLIER", 2236, FieldType.FLOAT);
|
||||
public static final Field LE_FORMULAS1 = new Field("LE_FORMULAS1", 3016, FieldType.INT);
|
||||
public static final Field LE_FORMULAS2 = new Field("LE_FORMULAS2", 3216, FieldType.INT);
|
||||
public static final Field LE_FORMULAS3 = new Field("LE_FORMULAS3", 3416, FieldType.INT);
|
||||
|
|
|
@ -67,7 +67,7 @@ void testFuelMap(void) {
|
|||
eth.engine.engineConfiguration->injector.battLagCorr[i] = 2 * i;
|
||||
}
|
||||
|
||||
eth.engine.updateSlowSensors();
|
||||
eth.engine.updateSlowSensors(PASS_ENGINE_PARAMETER_F);
|
||||
|
||||
// because all the correction tables are zero
|
||||
printf("*************************************************** getRunningFuel 1\r\n");
|
||||
|
|
|
@ -169,7 +169,7 @@ static void test1995FordInline6TriggerDecoder(void) {
|
|||
state.decodeTriggerEvent(SHAFT_PRIMARY_UP, r++ PASS_ENGINE_PARAMETER);
|
||||
assertEquals(0, state.getCurrentIndex()); // new revolution
|
||||
|
||||
assertEqualsM("running dwell", 0.5, getSparkDwellMsT(2000 PASS_ENGINE_PARAMETER));
|
||||
assertEqualsM("running dwell", 0.5, getSparkDwell(2000 PASS_ENGINE_PARAMETER));
|
||||
}
|
||||
|
||||
void testFordAspire(void) {
|
||||
|
@ -188,10 +188,10 @@ void testFordAspire(void) {
|
|||
engineConfiguration->crankingChargeAngle = 65;
|
||||
engineConfiguration->crankingTimingAngle = 31;
|
||||
|
||||
assertEqualsM("cranking dwell", 54.166670, getSparkDwellMsT(200 PASS_ENGINE_PARAMETER));
|
||||
assertEqualsM("running dwell", 4, getSparkDwellMsT(2000 PASS_ENGINE_PARAMETER));
|
||||
assertEqualsM("cranking dwell", 54.166670, getSparkDwell(200 PASS_ENGINE_PARAMETER));
|
||||
assertEqualsM("running dwell", 4, getSparkDwell(2000 PASS_ENGINE_PARAMETER));
|
||||
|
||||
assertEqualsM("higher rpm dwell", 3.25, getSparkDwellMsT(6000 PASS_ENGINE_PARAMETER));
|
||||
assertEqualsM("higher rpm dwell", 3.25, getSparkDwell(6000 PASS_ENGINE_PARAMETER));
|
||||
}
|
||||
|
||||
void testMazda323(void) {
|
||||
|
@ -289,7 +289,7 @@ static void testRpmCalculator(void) {
|
|||
efiAssertVoid(eth.engine.engineConfiguration!=NULL, "null config in engine");
|
||||
|
||||
initThermistors(NULL PASS_ENGINE_PARAMETER);
|
||||
engine->updateSlowSensors();
|
||||
engine->updateSlowSensors(PASS_ENGINE_PARAMETER_F);
|
||||
|
||||
engineConfiguration->trigger.customTotalToothCount = 8;
|
||||
engineConfiguration->globalFuelCorrection = 3;
|
||||
|
@ -299,7 +299,7 @@ static void testRpmCalculator(void) {
|
|||
// engine.engineConfiguration = eth.engine.engineConfiguration;
|
||||
eth.engine.engineConfiguration->injector.lag = 0.0;
|
||||
|
||||
engine->updateSlowSensors();
|
||||
engine->updateSlowSensors(PASS_ENGINE_PARAMETER_F);
|
||||
timeNow = 0;
|
||||
assertEquals(0, eth.engine.rpmCalculator.rpm(PASS_ENGINE_PARAMETER_F));
|
||||
|
||||
|
|
Loading…
Reference in New Issue