auto-sync
This commit is contained in:
parent
88735937fa
commit
3fe7c9da8e
|
@ -50,7 +50,7 @@ float getAdvance(int rpm, float engineLoad DECLARE_ENGINE_PARAMETER_S) {
|
|||
} else {
|
||||
angle = getBaseAdvance(rpm, engineLoad);
|
||||
}
|
||||
return fixAngle(engineConfiguration, angle - engineConfiguration->ignitionOffset);
|
||||
return fixAngle(angle - engineConfiguration->ignitionOffset PASS_ENGINE_PARAMETER);
|
||||
}
|
||||
|
||||
void prepareTimingMap(void) {
|
||||
|
|
|
@ -52,7 +52,7 @@ float getCrankshaftRevolutionTimeMs(int rpm) {
|
|||
* @brief Shifts angle into the [0..720) range
|
||||
* TODO: should be 'crankAngleRange' range?
|
||||
*/
|
||||
float fixAngle(engine_configuration_s const *engineConfiguration, float angle) {
|
||||
float fixAngle(float angle DECLARE_ENGINE_PARAMETER_S) {
|
||||
efiAssert(engineConfiguration->engineCycle!=0, "engine cycle", NAN);
|
||||
// I guess this implementation would be faster than 'angle % 720'
|
||||
while (angle < 0)
|
||||
|
@ -286,7 +286,7 @@ int getEngineCycleEventCount(engine_configuration_s const *engineConfiguration,
|
|||
void findTriggerPosition(trigger_shape_s * s,
|
||||
event_trigger_position_s *position, float angleOffset DECLARE_ENGINE_PARAMETER_S) {
|
||||
|
||||
angleOffset = fixAngle(engineConfiguration, angleOffset + engineConfiguration->globalTriggerAngleOffset);
|
||||
angleOffset = fixAngle(angleOffset + engineConfiguration->globalTriggerAngleOffset PASS_ENGINE_PARAMETER);
|
||||
|
||||
int engineCycleEventCount = getEngineCycleEventCount(engineConfiguration, s);
|
||||
|
||||
|
@ -363,7 +363,7 @@ void prepareOutputSignals(Engine *engine) {
|
|||
engine_configuration2_s *engineConfiguration2 = engine->engineConfiguration2;
|
||||
|
||||
// todo: move this reset into decoder
|
||||
engineConfiguration2->triggerShape.calculateTriggerSynchPoint(engineConfiguration, &engineConfiguration->triggerConfig);
|
||||
engineConfiguration2->triggerShape.calculateTriggerSynchPoint(engineConfiguration, &engineConfiguration->triggerConfig, engine);
|
||||
|
||||
trigger_shape_s * ts = &engineConfiguration2->triggerShape;
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ extern "C"
|
|||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
float fixAngle(engine_configuration_s const *engineConfiguration, float angle);
|
||||
float fixAngle(float angle DECLARE_ENGINE_PARAMETER_S);
|
||||
|
||||
/**
|
||||
* So that's how 'inline' syntax for both GCC and IAR
|
||||
|
|
|
@ -348,7 +348,7 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t eventIndex, Eng
|
|||
|
||||
float dwellAngle = dwellMs / getOneDegreeTimeMs(rpm);
|
||||
|
||||
initializeIgnitionActions(fixAngle(engineConfiguration, -advance), dwellAngle, engine->engineConfiguration2,
|
||||
initializeIgnitionActions(fixAngle(-advance PASS_ENGINE_PARAMETER), dwellAngle, engine->engineConfiguration2,
|
||||
&engine->engineConfiguration2->ignitionEvents[revolutionIndex] PASS_ENGINE_PARAMETER);
|
||||
}
|
||||
|
||||
|
|
|
@ -55,11 +55,11 @@ int trigger_shape_s::getTriggerShapeSynchPointIndex() {
|
|||
// todo: clean-up!
|
||||
int getEngineCycleEventCount2(operation_mode_e mode, trigger_shape_s * s);
|
||||
|
||||
void trigger_shape_s::calculateTriggerSynchPoint(engine_configuration_s const*engineConfiguration, trigger_config_s const*triggerConfig) {
|
||||
setTriggerShapeSynchPointIndex(engineConfiguration, findTriggerZeroEventIndex(this, triggerConfig));
|
||||
void trigger_shape_s::calculateTriggerSynchPoint(engine_configuration_s *engineConfiguration, trigger_config_s const*triggerConfig, Engine *engine) {
|
||||
setTriggerShapeSynchPointIndex(engineConfiguration, findTriggerZeroEventIndex(this, triggerConfig), engine);
|
||||
}
|
||||
|
||||
void trigger_shape_s::setTriggerShapeSynchPointIndex(engine_configuration_s const *engineConfiguration, int triggerShapeSynchPointIndex) {
|
||||
void trigger_shape_s::setTriggerShapeSynchPointIndex(engine_configuration_s *engineConfiguration, int triggerShapeSynchPointIndex, Engine *engine) {
|
||||
this->triggerShapeSynchPointIndex = triggerShapeSynchPointIndex;
|
||||
|
||||
int engineCycleEventCount = getEngineCycleEventCount2(operationMode, this);
|
||||
|
@ -71,7 +71,7 @@ void trigger_shape_s::setTriggerShapeSynchPointIndex(engine_configuration_s cons
|
|||
// 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(engineConfiguration, getAngle((triggerShapeSynchPointIndex + i) % engineCycleEventCount) - firstAngle);
|
||||
eventAngles[i] = fixAngle(getAngle((triggerShapeSynchPointIndex + i) % engineCycleEventCount) - firstAngle PASS_ENGINE_PARAMETER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,8 @@ public:
|
|||
single_wave_s waves[TRIGGER_CHANNEL_COUNT];
|
||||
};
|
||||
|
||||
class Engine;
|
||||
|
||||
class trigger_shape_s {
|
||||
public:
|
||||
trigger_shape_s();
|
||||
|
@ -83,9 +85,9 @@ public:
|
|||
|
||||
int getTriggerShapeSynchPointIndex();
|
||||
|
||||
void calculateTriggerSynchPoint(engine_configuration_s const *engineConfiguration, trigger_config_s const*triggerConfig);
|
||||
void calculateTriggerSynchPoint(engine_configuration_s *engineConfiguration, trigger_config_s const*triggerConfig, Engine *engine);
|
||||
|
||||
void setTriggerShapeSynchPointIndex(engine_configuration_s const *engineConfiguration, int triggerShapeSynchPointIndex);
|
||||
void setTriggerShapeSynchPointIndex(engine_configuration_s *engineConfiguration, int triggerShapeSynchPointIndex, Engine *engine);
|
||||
/**
|
||||
* 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(engineConfiguration, (offsetUs / oneDegreeUs) - engineConfiguration->globalTriggerAngleOffset), 3);
|
||||
appendFloat(logging, fixAngle((offsetUs / oneDegreeUs) - engineConfiguration->globalTriggerAngleOffset PASS_ENGINE_PARAMETER), 3);
|
||||
appendPrintf(logging, "%s", DELIMETER);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -163,7 +163,7 @@ void testAngleResolver(void) {
|
|||
|
||||
confgiureFordAspireTriggerShape(ts);
|
||||
|
||||
ts->calculateTriggerSynchPoint(engineConfiguration, &engineConfiguration->triggerConfig);
|
||||
ts->calculateTriggerSynchPoint(engineConfiguration, &engineConfiguration->triggerConfig, engine);
|
||||
|
||||
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