auto-sync

This commit is contained in:
rusEfi 2017-01-03 17:01:42 -05:00
parent 4c39b2dc0e
commit 9240dc79b8
5 changed files with 70 additions and 45 deletions

View File

@ -5,9 +5,39 @@
* @author Andrey Belomutskiy, (c) 2012-2017
*/
#include "main.h"
#include "trigger_structure.h"
#include "engine_configuration.h"
#include "trigger_universal.h"
angle_t getEngineCycle(operation_mode_e operationMode) {
return operationMode == TWO_STROKE ? 360 : 720;
}
void addSkippedToothTriggerEvents(trigger_wheel_e wheel, TriggerShape *s, int totalTeethCount, int skippedCount,
float toothWidth, float offset, float engineCycle, float filterLeft, float filterRight DECLARE_ENGINE_PARAMETER_S) {
efiAssertVoid(totalTeethCount > 0, "total count");
efiAssertVoid(skippedCount >= 0, "skipped count");
for (int i = 0; i < totalTeethCount - skippedCount - 1; i++) {
float angleDown = engineCycle / totalTeethCount * (i + (1 - toothWidth));
float angleUp = engineCycle / totalTeethCount * (i + 1);
s->addEvent2(offset + angleDown, wheel, TV_RISE, filterLeft, filterRight PASS_ENGINE_PARAMETER);
s->addEvent2(offset + angleUp, wheel, TV_FALL, filterLeft, filterRight PASS_ENGINE_PARAMETER);
}
float angleDown = engineCycle / totalTeethCount * (totalTeethCount - skippedCount - 1 + (1 - toothWidth));
s->addEvent2(offset + angleDown, wheel, TV_RISE, filterLeft, filterRight PASS_ENGINE_PARAMETER);
s->addEvent2(offset + engineCycle, wheel, TV_FALL, filterLeft, filterRight PASS_ENGINE_PARAMETER);
}
void initializeSkippedToothTriggerShapeExt(TriggerShape *s, int totalTeethCount, int skippedCount,
operation_mode_e operationMode DECLARE_ENGINE_PARAMETER_S) {
efiAssertVoid(totalTeethCount > 0, "totalTeethCount is zero");
efiAssertVoid(s != NULL, "TriggerShape is NULL");
s->initialize(operationMode, false);
s->setTriggerSynchronizationGap(skippedCount + 1);
s->isSynchronizationNeeded = (skippedCount != 0);
addSkippedToothTriggerEvents(T_PRIMARY, s, totalTeethCount, skippedCount, 0.5, 0, getEngineCycle(operationMode),
NO_LEFT_FILTER, NO_RIGHT_FILTER PASS_ENGINE_PARAMETER);
}

View File

@ -0,0 +1,32 @@
/*
* @file trigger_universal.h
*
*
* @date Jan 3, 2017
* @author Andrey Belomutskiy, (c) 2012-2017
*/
#ifndef CONTROLLERS_TRIGGER_DECODERS_TRIGGER_UNIVERSAL_H_
#define CONTROLLERS_TRIGGER_DECODERS_TRIGGER_UNIVERSAL_H_
#include "main.h"
#include "trigger_structure.h"
#include "engine_configuration.h"
#define NO_LEFT_FILTER -1
#define NO_RIGHT_FILTER 1000
void addSkippedToothTriggerEvents(trigger_wheel_e wheel, TriggerShape *s,
int totalTeethCount, int skippedCount,
float toothWidth,
float offset, float engineCycle, float filterLeft, float filterRight DECLARE_ENGINE_PARAMETER_S);
void initializeSkippedToothTriggerShapeExt(TriggerShape *s, int totalTeethCount, int skippedCount, operation_mode_e operationMode DECLARE_ENGINE_PARAMETER_S);;
void configureOnePlus60_2(TriggerShape *s, operation_mode_e operationMode DECLARE_ENGINE_PARAMETER_S);
void configure3_1_cam(TriggerShape *s, operation_mode_e operationMode DECLARE_ENGINE_PARAMETER_S);
void configureOnePlusOne(TriggerShape *s, operation_mode_e operationMode DECLARE_ENGINE_PARAMETER_S);
#endif /* CONTROLLERS_TRIGGER_DECODERS_TRIGGER_UNIVERSAL_H_ */

View File

@ -41,6 +41,7 @@
#include "engine_math.h"
#include "trigger_central.h"
#include "trigger_simulator.h"
#include "trigger_universal.h"
#if EFI_SENSOR_CHART || defined(__DOXYGEN__)
#include "sensor_chart.h"
@ -348,41 +349,7 @@ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, efitime_t no
}
}
angle_t getEngineCycle(operation_mode_e operationMode) {
return operationMode == TWO_STROKE ? 360 : 720;
}
void addSkippedToothTriggerEvents(trigger_wheel_e wheel, TriggerShape *s, int totalTeethCount, int skippedCount,
float toothWidth, float offset, float engineCycle, float filterLeft, float filterRight DECLARE_ENGINE_PARAMETER_S) {
efiAssertVoid(totalTeethCount > 0, "total count");
efiAssertVoid(skippedCount >= 0, "skipped count");
for (int i = 0; i < totalTeethCount - skippedCount - 1; i++) {
float angleDown = engineCycle / totalTeethCount * (i + (1 - toothWidth));
float angleUp = engineCycle / totalTeethCount * (i + 1);
s->addEvent2(offset + angleDown, wheel, TV_RISE, filterLeft, filterRight PASS_ENGINE_PARAMETER);
s->addEvent2(offset + angleUp, wheel, TV_FALL, filterLeft, filterRight PASS_ENGINE_PARAMETER);
}
float angleDown = engineCycle / totalTeethCount * (totalTeethCount - skippedCount - 1 + (1 - toothWidth));
s->addEvent2(offset + angleDown, wheel, TV_RISE, filterLeft, filterRight PASS_ENGINE_PARAMETER);
s->addEvent2(offset + engineCycle, wheel, TV_FALL, filterLeft, filterRight PASS_ENGINE_PARAMETER);
}
void initializeSkippedToothTriggerShapeExt(TriggerShape *s, int totalTeethCount, int skippedCount,
operation_mode_e operationMode DECLARE_ENGINE_PARAMETER_S) {
efiAssertVoid(totalTeethCount > 0, "totalTeethCount is zero");
efiAssertVoid(s != NULL, "TriggerShape is NULL");
s->initialize(operationMode, false);
s->setTriggerSynchronizationGap(skippedCount + 1);
s->isSynchronizationNeeded = (skippedCount != 0);
addSkippedToothTriggerEvents(T_PRIMARY, s, totalTeethCount, skippedCount, 0.5, 0, getEngineCycle(operationMode),
NO_LEFT_FILTER, NO_RIGHT_FILTER PASS_ENGINE_PARAMETER);
}
static void configure3_1_cam(TriggerShape *s, operation_mode_e operationMode DECLARE_ENGINE_PARAMETER_S) {
void configure3_1_cam(TriggerShape *s, operation_mode_e operationMode DECLARE_ENGINE_PARAMETER_S) {
s->initialize(FOUR_STROKE_CAM_SENSOR, true);
@ -418,8 +385,7 @@ static void configure3_1_cam(TriggerShape *s, operation_mode_e operationMode DEC
s->isSynchronizationNeeded = false;
}
static void configureOnePlusOne(TriggerShape *s, operation_mode_e operationMode DECLARE_ENGINE_PARAMETER_S) {
void configureOnePlusOne(TriggerShape *s, operation_mode_e operationMode DECLARE_ENGINE_PARAMETER_S) {
float engineCycle = getEngineCycle(operationMode);
s->initialize(FOUR_STROKE_CAM_SENSOR, true);
@ -434,7 +400,7 @@ static void configureOnePlusOne(TriggerShape *s, operation_mode_e operationMode
s->useOnlyPrimaryForSync = true;
}
static void configureOnePlus60_2(TriggerShape *s, operation_mode_e operationMode DECLARE_ENGINE_PARAMETER_S) {
void configureOnePlus60_2(TriggerShape *s, operation_mode_e operationMode DECLARE_ENGINE_PARAMETER_S) {
s->initialize(FOUR_STROKE_CAM_SENSOR, true);
int totalTeethCount = 60;

View File

@ -12,9 +12,6 @@
#include "trigger_structure.h"
#include "engine_configuration.h"
#define NO_LEFT_FILTER -1
#define NO_RIGHT_FILTER 1000
class TriggerState;
typedef void (*TriggerStateCallback)(TriggerState *);
@ -119,7 +116,6 @@ private:
};
angle_t getEngineCycle(operation_mode_e operationMode);
void initializeSkippedToothTriggerShapeExt(TriggerShape *s, int totalTeethCount, int skippedCount, operation_mode_e operationMode DECLARE_ENGINE_PARAMETER_S);
uint32_t findTriggerZeroEventIndex(TriggerState *state, TriggerShape * shape, trigger_config_s const*triggerConfig DECLARE_ENGINE_PARAMETER_S);
class Engine;

View File

@ -30,6 +30,7 @@
#include "speed_density.h"
#include "fuel_math.h"
#include "spark_logic.h"
#include "trigger_universal.h"
extern int timeNow;
extern float unitTestValue;