auto-sync
This commit is contained in:
parent
03cdee0274
commit
d7504604c2
|
@ -118,6 +118,7 @@ void setFordAspireEngineConfiguration(DECLARE_ENGINE_PARAMETER_F) {
|
||||||
setSingleCoilDwell(engineConfiguration);
|
setSingleCoilDwell(engineConfiguration);
|
||||||
engineConfiguration->ignitionMode = IM_ONE_COIL;
|
engineConfiguration->ignitionMode = IM_ONE_COIL;
|
||||||
setOperationMode(engineConfiguration, FOUR_STROKE_CAM_SENSOR);
|
setOperationMode(engineConfiguration, FOUR_STROKE_CAM_SENSOR);
|
||||||
|
engineConfiguration->useOnlyFrontForTrigger = true;
|
||||||
engineConfiguration->trigger.type = TT_FORD_ASPIRE;
|
engineConfiguration->trigger.type = TT_FORD_ASPIRE;
|
||||||
|
|
||||||
boardConfiguration->injectionPins[4] = GPIO_UNASSIGNED;
|
boardConfiguration->injectionPins[4] = GPIO_UNASSIGNED;
|
||||||
|
|
|
@ -370,8 +370,10 @@ void prepareOutputSignals(DECLARE_ENGINE_PARAMETER_F) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int angle = 0; angle < CONFIG(engineCycle); angle++) {
|
for (int angle = 0; angle < CONFIG(engineCycle); angle++) {
|
||||||
int triggerIndex = findAngleIndex(angle PASS_ENGINE_PARAMETER);
|
int triggerShapeIndex = findAngleIndex(angle PASS_ENGINE_PARAMETER);
|
||||||
TRIGGER_SHAPE(triggerIndexByAngle[angle])= engineConfiguration->useOnlyFrontForTrigger ? TRIGGER_SHAPE(frontOnlyIndexes[triggerIndex]) : triggerIndex;
|
if (engineConfiguration->useOnlyFrontForTrigger)
|
||||||
|
triggerShapeIndex = triggerShapeIndex & 0xFFFFFFFE; // we need even index for front_only
|
||||||
|
TRIGGER_SHAPE(triggerIndexByAngle[angle]) = triggerShapeIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
engineConfiguration2->crankingInjectionEvents.addFuelEvents(&crankingInjectonSignals,
|
engineConfiguration2->crankingInjectionEvents.addFuelEvents(&crankingInjectonSignals,
|
||||||
|
|
|
@ -44,11 +44,10 @@ TriggerShape::TriggerShape() :
|
||||||
tdcPosition = 0;
|
tdcPosition = 0;
|
||||||
skippedToothCount = totalToothCount = 0;
|
skippedToothCount = totalToothCount = 0;
|
||||||
syncRatioFrom = syncRatioTo = 0;
|
syncRatioFrom = syncRatioTo = 0;
|
||||||
|
memset(eventAngles, 0, sizeof(eventAngles));
|
||||||
memset(frontOnlyIndexes, 0, sizeof(frontOnlyIndexes));
|
memset(frontOnlyIndexes, 0, sizeof(frontOnlyIndexes));
|
||||||
memset(isFrontEvent, 0, sizeof(isFrontEvent));
|
memset(isFrontEvent, 0, sizeof(isFrontEvent));
|
||||||
memset(triggerIndexByAngle, 0, sizeof(triggerIndexByAngle));
|
memset(triggerIndexByAngle, 0, sizeof(triggerIndexByAngle));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int TriggerShape::getSize() const {
|
int TriggerShape::getSize() const {
|
||||||
|
@ -74,15 +73,24 @@ void TriggerShape::calculateTriggerSynchPoint(DECLARE_ENGINE_PARAMETER_F) {
|
||||||
if (eventIndex == 0) {
|
if (eventIndex == 0) {
|
||||||
// explicit check for zero to avoid issues where logical zero is not exactly zero due to float nature
|
// explicit check for zero to avoid issues where logical zero is not exactly zero due to float nature
|
||||||
eventAngles[0] = 0;
|
eventAngles[0] = 0;
|
||||||
|
// this value would be used in case of front-only
|
||||||
|
eventAngles[1] = 0;
|
||||||
frontOnlyIndexes[0] = 0;
|
frontOnlyIndexes[0] = 0;
|
||||||
} else {
|
} else {
|
||||||
int triggerDefinitionCoordinate = (triggerShapeSynchPointIndex + eventIndex) % engine->engineCycleEventCount;
|
int triggerDefinitionCoordinate = (triggerShapeSynchPointIndex + eventIndex) % engine->engineCycleEventCount;
|
||||||
int triggerDefinitionIndex = triggerDefinitionCoordinate >= size ? triggerDefinitionCoordinate - size : triggerDefinitionCoordinate;
|
int triggerDefinitionIndex = triggerDefinitionCoordinate >= size ? triggerDefinitionCoordinate - size : triggerDefinitionCoordinate;
|
||||||
if (isFrontEvent[triggerDefinitionIndex])
|
|
||||||
frontOnlyIndex += 2;
|
|
||||||
float angle = getAngle(triggerDefinitionCoordinate) - firstAngle;
|
float angle = getAngle(triggerDefinitionCoordinate) - firstAngle;
|
||||||
fixAngle(angle);
|
fixAngle(angle);
|
||||||
eventAngles[eventIndex] = angle;
|
if (engineConfiguration->useOnlyFrontForTrigger) {
|
||||||
|
if (isFrontEvent[triggerDefinitionIndex]) {
|
||||||
|
frontOnlyIndex += 2;
|
||||||
|
eventAngles[frontOnlyIndex] = angle;
|
||||||
|
eventAngles[frontOnlyIndex + 1] = angle;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
eventAngles[eventIndex] = angle;
|
||||||
|
}
|
||||||
|
|
||||||
frontOnlyIndexes[eventIndex] = frontOnlyIndex;
|
frontOnlyIndexes[eventIndex] = frontOnlyIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -268,6 +276,7 @@ void TriggerShape::addEvent(float angle, trigger_wheel_e const waveIndex, trigge
|
||||||
wave->pinStates[0] = initialState[i];
|
wave->pinStates[0] = initialState[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isFrontEvent[0] = TV_HIGH == stateParam;
|
||||||
wave.setSwitchTime(0, angle);
|
wave.setSwitchTime(0, angle);
|
||||||
wave.waves[waveIndex].pinStates[0] = state;
|
wave.waves[waveIndex].pinStates[0] = state;
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -171,14 +171,12 @@ void testAngleResolver(void) {
|
||||||
assertTrue(engine->engineConfiguration2!=NULL);
|
assertTrue(engine->engineConfiguration2!=NULL);
|
||||||
TriggerShape * ts = &engine->triggerShape;
|
TriggerShape * ts = &engine->triggerShape;
|
||||||
|
|
||||||
confgiureFordAspireTriggerShape(ts);
|
|
||||||
|
|
||||||
ts->calculateTriggerSynchPoint(PASS_ENGINE_PARAMETER_F);
|
ts->calculateTriggerSynchPoint(PASS_ENGINE_PARAMETER_F);
|
||||||
|
|
||||||
assertEqualsM("index 2", 228.0450, ts->eventAngles[3]); // this angle is relation to synch point
|
assertEqualsM("index 2", 52.76, ts->eventAngles[3]); // this angle is relation to synch point
|
||||||
assertEqualsM("time 2", 0.3233, ts->wave.getSwitchTime(2));
|
assertEqualsM("time 2", 0.3233, ts->wave.getSwitchTime(2));
|
||||||
assertEqualsM("index 5", 413.7470, ts->eventAngles[6]);
|
assertEqualsM("index 5", 412.76, ts->eventAngles[6]);
|
||||||
assertEqualsM("time 5", 0.5692, ts->wave.getSwitchTime(5));
|
assertEqualsM("time 5", 0.5733, ts->wave.getSwitchTime(5));
|
||||||
|
|
||||||
assertEquals(4, ts->getTriggerShapeSynchPointIndex());
|
assertEquals(4, ts->getTriggerShapeSynchPointIndex());
|
||||||
|
|
||||||
|
@ -190,40 +188,41 @@ void testAngleResolver(void) {
|
||||||
printf("*************************************************** testAngleResolver 0\r\n");
|
printf("*************************************************** testAngleResolver 0\r\n");
|
||||||
findTriggerPosition(&ae.add()->injectionStart, -122 PASS_ENGINE_PARAMETER);
|
findTriggerPosition(&ae.add()->injectionStart, -122 PASS_ENGINE_PARAMETER);
|
||||||
assertEqualsM("size", 1, ae.size);
|
assertEqualsM("size", 1, ae.size);
|
||||||
// assertEquals(0, ae.elements[0].injectionStart.eventIndex);
|
assertEquals(2, ae.elements[0].injectionStart.eventIndex);
|
||||||
// assertEquals(53, ae.elements[0].injectionStart.angleOffset);
|
assertEquals(0.24, ae.elements[0].injectionStart.angleOffset);
|
||||||
assertEquals(1, ae.elements[0].injectionStart.eventIndex);
|
|
||||||
assertEquals(3.1588, ae.elements[0].injectionStart.angleOffset);
|
|
||||||
|
|
||||||
printf("*************************************************** testAngleResolver 0.1\r\n");
|
printf("*************************************************** testAngleResolver 0.1\r\n");
|
||||||
ae.reset();
|
ae.reset();
|
||||||
findTriggerPosition(&ae.add()->injectionStart, -80 PASS_ENGINE_PARAMETER);
|
findTriggerPosition(&ae.add()->injectionStart, -80 PASS_ENGINE_PARAMETER);
|
||||||
assertEquals(1, ae.elements[0].injectionStart.eventIndex);
|
assertEquals(2, ae.elements[0].injectionStart.eventIndex);
|
||||||
assertEquals(45.1588, ae.elements[0].injectionStart.angleOffset);
|
assertEquals(42.24, ae.elements[0].injectionStart.angleOffset);
|
||||||
|
|
||||||
printf("*************************************************** testAngleResolver 0.2\r\n");
|
printf("*************************************************** testAngleResolver 0.2\r\n");
|
||||||
ae.reset();
|
ae.reset();
|
||||||
findTriggerPosition(&ae.add()->injectionStart, -54 PASS_ENGINE_PARAMETER);
|
findTriggerPosition(&ae.add()->injectionStart, -54 PASS_ENGINE_PARAMETER);
|
||||||
assertEquals(1, ae.elements[0].injectionStart.eventIndex);
|
assertEquals(2, ae.elements[0].injectionStart.eventIndex);
|
||||||
assertEquals(71.1588, ae.elements[0].injectionStart.angleOffset);
|
assertEquals(68.2400, ae.elements[0].injectionStart.angleOffset);
|
||||||
|
|
||||||
printf("*************************************************** testAngleResolver 0.3\r\n");
|
printf("*************************************************** testAngleResolver 0.3\r\n");
|
||||||
ae.reset();
|
ae.reset();
|
||||||
findTriggerPosition(&ae.add()->injectionStart, -53 PASS_ENGINE_PARAMETER);
|
findTriggerPosition(&ae.add()->injectionStart, -53 PASS_ENGINE_PARAMETER);
|
||||||
assertEquals(2, ae.elements[0].injectionStart.eventIndex);
|
assertEquals(2, ae.elements[0].injectionStart.eventIndex);
|
||||||
assertEquals(3.3495, ae.elements[0].injectionStart.angleOffset);
|
assertEquals(69.24, ae.elements[0].injectionStart.angleOffset);
|
||||||
|
|
||||||
printf("*************************************************** testAngleResolver 1\r\n");
|
printf("*************************************************** testAngleResolver 1\r\n");
|
||||||
ae.reset();
|
ae.reset();
|
||||||
findTriggerPosition(&ae.add()->injectionStart, 0 PASS_ENGINE_PARAMETER);
|
findTriggerPosition(&ae.add()->injectionStart, 0 PASS_ENGINE_PARAMETER);
|
||||||
assertEquals(2, ae.elements[0].injectionStart.eventIndex);
|
assertEquals(2, ae.elements[0].injectionStart.eventIndex);
|
||||||
assertEquals(56.3495, ae.elements[0].injectionStart.angleOffset);
|
assertEquals(122.24, ae.elements[0].injectionStart.angleOffset);
|
||||||
|
|
||||||
printf("*************************************************** testAngleResolver 2\r\n");
|
printf("*************************************************** testAngleResolver 2\r\n");
|
||||||
ae.reset();
|
ae.reset();
|
||||||
findTriggerPosition(&ae.add()->injectionStart, 56 PASS_ENGINE_PARAMETER);
|
findTriggerPosition(&ae.add()->injectionStart, 56 PASS_ENGINE_PARAMETER);
|
||||||
assertEquals(2, ae.elements[0].injectionStart.eventIndex);
|
assertEquals(2, ae.elements[0].injectionStart.eventIndex);
|
||||||
assertEquals(112.3495, ae.elements[0].injectionStart.angleOffset);
|
assertEquals(178.24, ae.elements[0].injectionStart.angleOffset);
|
||||||
|
|
||||||
|
TriggerShape t;
|
||||||
|
confgiureFordAspireTriggerShape(&t);
|
||||||
}
|
}
|
||||||
|
|
||||||
void testPinHelper(void) {
|
void testPinHelper(void) {
|
||||||
|
|
|
@ -508,7 +508,7 @@ void testTriggerDecoder(void) {
|
||||||
|
|
||||||
testFordAspire();
|
testFordAspire();
|
||||||
// lame duty cycle implementation!
|
// lame duty cycle implementation!
|
||||||
testTriggerDecoder2("ford aspire", FORD_ASPIRE_1996, 4, 0.5, 0.3841);
|
testTriggerDecoder2("ford aspire", FORD_ASPIRE_1996, 4, 0.0, 0.5);
|
||||||
|
|
||||||
//testTriggerDecoder2("bmw", BMW_E34, 0, 0.9750, 0.5167);
|
//testTriggerDecoder2("bmw", BMW_E34, 0, 0.9750, 0.5167);
|
||||||
testTriggerDecoder2("bmw", BMW_E34, 0, 0.4833, 0.0);
|
testTriggerDecoder2("bmw", BMW_E34, 0, 0.4833, 0.0);
|
||||||
|
|
Loading…
Reference in New Issue