auto-sync
This commit is contained in:
parent
148a5c481e
commit
237703a49d
|
@ -24,6 +24,10 @@ void setBmwE43(engine_configuration_s *engineConfiguration) {
|
|||
engineConfiguration->injectionMode = IM_SIMULTANEOUS;
|
||||
engineConfiguration->ignitionMode = IM_WASTED_SPARK;
|
||||
|
||||
setConstantDwell(engineConfiguration, 3); // a bit shorter dwell
|
||||
engineConfiguration->useConstantDwellDuringCranking = true;
|
||||
engineConfiguration->ignitionDwellForCrankingMs = 5;
|
||||
|
||||
// todo: check the digital sniffer while simulating
|
||||
// set_global_trigger_offset_angle 84
|
||||
engineConfiguration->globalTriggerAngleOffset = 84;
|
||||
|
|
|
@ -179,8 +179,6 @@ void printState(Engine *engine, int currentCkpEventCounter) {
|
|||
debugFloat(&logger, "timing", getAdvance(rpm, engineLoad), 2);
|
||||
|
||||
// float map = getMap();
|
||||
// float fuel = getDefaultFuel(rpm, map);
|
||||
// debugFloat(&logger, "d_fuel", fuel, 2);
|
||||
|
||||
#endif /* EFI_SHAFT_POSITION_INPUT */
|
||||
}
|
||||
|
@ -454,7 +452,7 @@ void updateTunerStudioState(Engine *engine, TunerStudioOutputChannels *tsOutputC
|
|||
tsOutputChannels->isIatError = !isValidIntakeAirTemperature(getIntakeAirTemperature(engine));
|
||||
#endif
|
||||
tsOutputChannels->tCharge = getTCharge(rpm, tps, coolant, intake);
|
||||
tsOutputChannels->sparkDwell = getSparkDwellMs(rpm);
|
||||
tsOutputChannels->sparkDwell = getSparkDwellMsT(engineConfiguration, rpm);
|
||||
tsOutputChannels->pulseWidthMs = getRunningFuel(baseFuelMs, engine, rpm);
|
||||
tsOutputChannels->crankingFuelMs = getCrankingFuel(engine);
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ float getAdvance(int rpm, float engineLoad) {
|
|||
} else {
|
||||
angle = -getBaseAdvance(rpm, engineLoad);
|
||||
}
|
||||
return fixAngle(angle + engineConfiguration->ignitionOffset);
|
||||
return fixAngle(engineConfiguration, angle + engineConfiguration->ignitionOffset);
|
||||
}
|
||||
|
||||
void prepareTimingMap(void) {
|
||||
|
|
|
@ -141,6 +141,7 @@ void setDefaultConfiguration(engine_configuration_s *engineConfiguration, board_
|
|||
}
|
||||
|
||||
setConstantDwell(engineConfiguration, 4); // 4ms is global default dwell
|
||||
engineConfiguration->useConstantDwellDuringCranking = false;
|
||||
|
||||
setFuelLoadBin(engineConfiguration, 1.2, 4.4);
|
||||
setFuelRpmBin(engineConfiguration, 800, 7000);
|
||||
|
|
|
@ -440,6 +440,7 @@ typedef struct {
|
|||
bool_t hasIatSensor : 1; // bit 1
|
||||
bool_t hasBaroSensor : 1; // bit 1
|
||||
bool_t hasAfrSensor : 1; // bit 2
|
||||
bool_t useConstantDwellDuringCranking : 1; // bit 3
|
||||
// that's the next 32 bit field
|
||||
int hasCltSensor;
|
||||
|
||||
|
@ -480,7 +481,9 @@ typedef struct {
|
|||
float crankingCycleCoef[CRANKING_CURVE_SIZE];
|
||||
float crankingCycleBins[CRANKING_CURVE_SIZE];
|
||||
|
||||
int unused3[94];
|
||||
float ignitionDwellForCrankingMs;
|
||||
|
||||
int unused3[93];
|
||||
|
||||
} engine_configuration_s;
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ float getCrankshaftRevolutionTimeMs(int rpm) {
|
|||
* @brief Shifts angle into the [0..720) range
|
||||
* TODO: should be 'crankAngleRange' range?
|
||||
*/
|
||||
float fixAngle(float angle) {
|
||||
float fixAngle(engine_configuration_s const *engineConfiguration, float angle) {
|
||||
// I guess this implementation would be faster than 'angle % 720'
|
||||
while (angle < 0)
|
||||
angle += 720;
|
||||
|
@ -231,10 +231,14 @@ void addFuelEvents(engine_configuration_s const *e, engine_configuration2_s *eng
|
|||
*/
|
||||
float getSparkDwellMsT(engine_configuration_s *engineConfiguration, int rpm) {
|
||||
if (isCrankingR(rpm)) {
|
||||
if(engineConfiguration->useConstantDwellDuringCranking) {
|
||||
return engineConfiguration->ignitionDwellForCrankingMs;
|
||||
} else {
|
||||
// technically this could be implemented via interpolate2d
|
||||
float angle = engineConfiguration->crankingChargeAngle;
|
||||
return getOneDegreeTimeMs(rpm) * angle;
|
||||
}
|
||||
}
|
||||
efiAssert(!cisnan(rpm), "invalid rpm", NAN);
|
||||
|
||||
return interpolate2d(rpm, engineConfiguration->sparkDwellBins, engineConfiguration->sparkDwell, DWELL_CURVE_SIZE);
|
||||
|
@ -255,7 +259,7 @@ int getEngineCycleEventCount(engine_configuration_s const *engineConfiguration,
|
|||
void findTriggerPosition(engine_configuration_s const *engineConfiguration, trigger_shape_s * s,
|
||||
event_trigger_position_s *position, float angleOffset) {
|
||||
|
||||
angleOffset = fixAngle(angleOffset + engineConfiguration->globalTriggerAngleOffset);
|
||||
angleOffset = fixAngle(engineConfiguration, angleOffset + engineConfiguration->globalTriggerAngleOffset);
|
||||
|
||||
int engineCycleEventCount = getEngineCycleEventCount(engineConfiguration, s);
|
||||
|
||||
|
@ -345,7 +349,7 @@ void prepareOutputSignals(Engine *engine) {
|
|||
engine_configuration2_s *engineConfiguration2 = engine->engineConfiguration2;
|
||||
|
||||
// todo: move this reset into decoder
|
||||
engineConfiguration2->triggerShape.calculateTriggerSynchPoint(&engineConfiguration->triggerConfig);
|
||||
engineConfiguration2->triggerShape.calculateTriggerSynchPoint(engineConfiguration, &engineConfiguration->triggerConfig);
|
||||
|
||||
injectonSignals.clear();
|
||||
EventHandlerConfiguration *config = &engineConfiguration2->engineEventConfiguration;
|
||||
|
|
|
@ -21,8 +21,6 @@ void findTriggerPosition(engine_configuration_s const *engineConfiguration, trig
|
|||
|
||||
int isInjectionEnabled(engine_configuration_s *engineConfiguration);
|
||||
|
||||
float fixAngle(float angle);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -30,7 +28,7 @@ extern "C"
|
|||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
float getDefaultFuel(int rpm, float map);
|
||||
float fixAngle(engine_configuration_s const *engineConfiguration, float angle);
|
||||
|
||||
/**
|
||||
* So that's how 'inline' syntax for both GCC and IAR
|
||||
|
@ -57,7 +55,6 @@ float getEngineLoadT(Engine *engine);
|
|||
#define getEngineLoad() getEngineLoadT(&engine)
|
||||
|
||||
float getSparkDwellMsT(engine_configuration_s *engineConfiguration, int rpm);
|
||||
#define getSparkDwellMs(rpm) getSparkDwellMsT(engineConfiguration, rpm)
|
||||
|
||||
int getCylinderId(firing_order_e firingOrder, int index);
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "trigger_structure.h"
|
||||
#include "error_handling.h"
|
||||
#include "trigger_decoder.h"
|
||||
#include "engine_math.h"
|
||||
|
||||
trigger_shape_helper::trigger_shape_helper() {
|
||||
for (int i = 0; i < TRIGGER_CHANNEL_COUNT; i++) {
|
||||
|
@ -53,13 +54,12 @@ int trigger_shape_s::getTriggerShapeSynchPointIndex() {
|
|||
|
||||
// todo: clean-up!
|
||||
int getEngineCycleEventCount2(operation_mode_e mode, trigger_shape_s * s);
|
||||
float fixAngle(float angle);
|
||||
|
||||
void trigger_shape_s::calculateTriggerSynchPoint(trigger_config_s const*triggerConfig) {
|
||||
setTriggerShapeSynchPointIndex(findTriggerZeroEventIndex(this, triggerConfig));
|
||||
void trigger_shape_s::calculateTriggerSynchPoint(engine_configuration_s const*engineConfiguration, trigger_config_s const*triggerConfig) {
|
||||
setTriggerShapeSynchPointIndex(engineConfiguration, findTriggerZeroEventIndex(this, triggerConfig));
|
||||
}
|
||||
|
||||
void trigger_shape_s::setTriggerShapeSynchPointIndex(int triggerShapeSynchPointIndex) {
|
||||
void trigger_shape_s::setTriggerShapeSynchPointIndex(engine_configuration_s const *engineConfiguration, int triggerShapeSynchPointIndex) {
|
||||
this->triggerShapeSynchPointIndex = triggerShapeSynchPointIndex;
|
||||
|
||||
int engineCycleEventCount = getEngineCycleEventCount2(operationMode, this);
|
||||
|
@ -71,7 +71,7 @@ void trigger_shape_s::setTriggerShapeSynchPointIndex(int triggerShapeSynchPointI
|
|||
// explicit check for zero to avoid issues where logical zero is not exactly zero due to float nature
|
||||
eventAngles[i] = 0;
|
||||
} else {
|
||||
eventAngles[i] = fixAngle(getAngle((triggerShapeSynchPointIndex + i) % engineCycleEventCount) - firstAngle);
|
||||
eventAngles[i] = fixAngle(engineConfiguration, getAngle((triggerShapeSynchPointIndex + i) % engineCycleEventCount) - firstAngle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,9 +83,9 @@ public:
|
|||
|
||||
int getTriggerShapeSynchPointIndex();
|
||||
|
||||
void calculateTriggerSynchPoint(trigger_config_s const*triggerConfig);
|
||||
void calculateTriggerSynchPoint(engine_configuration_s const *engineConfiguration, trigger_config_s const*triggerConfig);
|
||||
|
||||
void setTriggerShapeSynchPointIndex(int triggerShapeSynchPointIndex);
|
||||
void setTriggerShapeSynchPointIndex(engine_configuration_s const *engineConfiguration, int triggerShapeSynchPointIndex);
|
||||
/**
|
||||
* These angles are in event coordinates - with synchronization point located at angle zero.
|
||||
* These values are pre-calculated for performance reasons.
|
||||
|
|
|
@ -234,7 +234,7 @@ static void reportWave(Logging *logging, int index) {
|
|||
float oneDegreeUs = getOneDegreeTimeUs(getRpm());
|
||||
|
||||
appendPrintf(logging, "advance%d%s", index, DELIMETER);
|
||||
appendFloat(logging, fixAngle((offsetUs / oneDegreeUs) - engineConfiguration->globalTriggerAngleOffset), 3);
|
||||
appendFloat(logging, fixAngle(engineConfiguration, (offsetUs / oneDegreeUs) - engineConfiguration->globalTriggerAngleOffset), 3);
|
||||
appendPrintf(logging, "%s", DELIMETER);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -249,5 +249,5 @@ void firmwareError(const char *fmt, ...) {
|
|||
}
|
||||
|
||||
int getRusEfiVersion(void) {
|
||||
return 20141105;
|
||||
return 20141106;
|
||||
}
|
||||
|
|
|
@ -303,9 +303,9 @@ enable2ndByteCanID = false
|
|||
max31855spiDevice = bits, U32, 5912, [0:1], "Off", "SPI1", "SPI2", "SPI3"
|
||||
|
||||
|
||||
|
||||
|
||||
; idle mode 6288
|
||||
useConstantDwellDuringCranking= bits, U32, 6280, [3:3], "false", "true"
|
||||
; hasCltSensor 6284
|
||||
; idleMode 6288
|
||||
|
||||
isInjectionEnabled = bits, U32, 6292, [0:0], "false", "true"
|
||||
isIgnitionEnabled = bits, U32, 6292, [1:1], "false", "true"
|
||||
|
@ -327,6 +327,7 @@ enable2ndByteCanID = false
|
|||
|
||||
crankingCycleCoef = array, F32, 9568, [8], "%", 100, 0, 0.0, 500.0, 2; size 32
|
||||
crankingCycleBins = array, F32, 9600, [8], "C", 1, 0, -80.0, 170.0, 2; size 32
|
||||
ignitionDwellForCrankingMs=scalar, F32, 9632, "ms", 1, 0, 0, 200, 1; size 4
|
||||
|
||||
|
||||
[OutputChannels]
|
||||
|
|
|
@ -156,7 +156,7 @@ void testAngleResolver(void) {
|
|||
|
||||
confgiureFordAspireTriggerShape(ts);
|
||||
|
||||
ts->calculateTriggerSynchPoint(&engineConfiguration->triggerConfig);
|
||||
ts->calculateTriggerSynchPoint(engineConfiguration, &engineConfiguration->triggerConfig);
|
||||
|
||||
assertEqualsM("index 2", 232.76, ts->eventAngles[3]); // this angle is relation to synch point
|
||||
assertEqualsM("time 2", 0.3233, ts->wave.getSwitchTime(2));
|
||||
|
|
Loading…
Reference in New Issue