rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
trigger_misc.cpp
Go to the documentation of this file.
1/*
2 * trigger_misc.cpp
3 *
4 * Created on: Oct 30, 2018
5 * @author Andrey Belomutskiy, (c) 2012-2020
6 */
7
8#include "pch.h"
9
10#include "trigger_misc.h"
11#include "trigger_universal.h"
12
13// TT_FIAT_IAW_P8
27
28// TT_TRI_TACH
31
32 s->isSynchronizationNeeded = false;
33
34 float toothWidth = 0.5;
35
36 float engineCycle = FOUR_STROKE_ENGINE_CYCLE;
37
38 int totalTeethCount = 135;
39 float offset = 0;
40
41 float angleDown = engineCycle / totalTeethCount * (0 + (1 - toothWidth));
42 float angleUp = engineCycle / totalTeethCount * (0 + 1);
43 s->addEventClamped(offset + angleDown, TriggerValue::RISE, TriggerWheel::T_PRIMARY, NO_LEFT_FILTER, NO_RIGHT_FILTER);
44 s->addEventClamped(offset + angleDown + 0.1, TriggerValue::RISE, TriggerWheel::T_SECONDARY, NO_LEFT_FILTER, NO_RIGHT_FILTER);
45 s->addEventClamped(offset + angleUp, TriggerValue::FALL, TriggerWheel::T_PRIMARY, NO_LEFT_FILTER, NO_RIGHT_FILTER);
46 s->addEventClamped(offset + angleUp + 0.1, TriggerValue::FALL, TriggerWheel::T_SECONDARY, NO_LEFT_FILTER, NO_RIGHT_FILTER);
47
48
49 addSkippedToothTriggerEvents(TriggerWheel::T_SECONDARY, s, totalTeethCount, /* skipped */ 0, toothWidth, offset, engineCycle,
50 1.0 * FOUR_STROKE_ENGINE_CYCLE / 135,
51 NO_RIGHT_FILTER);
52}
53
54/**
55 * based on https://fordsix.com/threads/understanding-standard-and-signature-pip-thick-film-ignition.81515/
56 * based on https://www.w8ji.com/distributor_stabbing.htm
57 */
60
61 s->tdcPosition = 662.5;
62
65 /**
66 * sensor is mounted on distributor but trigger shape is defined in engine cycle angles
67 */
68 int oneCylinder = s->getCycleDuration() / 8;
69
70 s->addEventAngle(oneCylinder * 0.75, TriggerValue::RISE);
71 s->addEventAngle(oneCylinder, TriggerValue::FALL);
72
73
74 for (int i = 2;i<=8;i++) {
75 s->addEventAngle(oneCylinder * (i - 0.5), TriggerValue::RISE);
76 s->addEventAngle(oneCylinder * i, TriggerValue::FALL);
77 }
78
79}
80
83 int width = 10;
84
85 int total = s->getCycleDuration() / 8;
86
87 s->addEventAngle(1 * total - width, TriggerValue::RISE);
88 s->addEventAngle(1 * total, TriggerValue::FALL);
89
90 s->addEventAngle(2 * total - width, TriggerValue::RISE);
91 s->addEventAngle(2 * total, TriggerValue::FALL);
92
93 s->addEventAngle(4 * total - width, TriggerValue::RISE);
94 s->addEventAngle(4 * total, TriggerValue::FALL);
95
96 s->addEventAngle(6 * total - width, TriggerValue::RISE);
97 s->addEventAngle(6 * total, TriggerValue::FALL);
98
99 s->addEventAngle(8 * total - width, TriggerValue::RISE);
100 s->addEventAngle(8 * total, TriggerValue::FALL);
101}
102
103static void daihatsu(TriggerWaveform * s, int count) {
105 s->tdcPosition = 720 - 30;
106
107 int width = 10;
108
109 s->addEventAngle(30 - width, TriggerValue::RISE);
111
112 for (int i = 1;i<=count;i++) {
115 }
116}
117
122
123
128
131
132 // This wheel has four teeth
133 // two short gaps, and two long gaps
134 // short = 60 deg
135 // long = 120 deg
136
137 {
138 int offset = 60;
139 int w = 5;
140
142
143 // short gap 60 deg
144 s->addToothRiseFall(offset + 60, w);
145
146 // long gap 120 deg
147 s->addToothRiseFall(offset + 180, w);
148 // long gap 120 deg
149 s->addToothRiseFall(offset + 300, w);
150
151 // short gap, 60 deg back to zero/720
152 }
153
154 // sync tooth is the zero tooth, the first short gap after two long gaps
155 s->setTriggerSynchronizationGap3(0, 1.6f, 2.4f);
156 // previous gap should be 1.0
157 s->setTriggerSynchronizationGap3(1, 0.8f, 1.2f);
158}
159
162
163 constexpr float magic = 15;
164
165 float angle = 3 * magic;
166
167 s->addEvent360(angle / 2 /* 22.5 */, TriggerValue::RISE);
168 s->addEvent360(angle /* 45 */, TriggerValue::FALL);
169
170 for (int i = 0;i< 24 - 3;i++) {
171 angle += magic / 2;
173
174 angle += magic / 2;
176 }
177}
178
180 /** @todo
181 * My approach was to utilize ::Both especially for single
182 * tooth and manual kikstarter, to be ready on both sides of blind.
183 * But unfortuneally, my experiments show me the Trigger can't
184 * become syncronized by 'last' and folowed 'first' events only.
185 * Also I observe phase-aligment mehanism is trying to consume a
186 * longer side of trigger as latest before TDC.
187 * I wish to setup SyncEdge::Both for my TT_60DEG_TOOTH after
188 * this case of scenario become work well. For now, ::Rise work
189 * well for my 60 degree trigger and both edges phase sync work
190 * as mush as expected for my engine startup. */
191
193
196
197 s->tdcPosition = 60;
198
199 s->isSynchronizationNeeded = false;
200 s->useOnlyPrimaryForSync = true;
201}
202
205
206 int totalTeethCount = 24;
207 float engineCycle = TWO_STROKE_CYCLE_DURATION;
208 float toothWidth = 0.5;
209
210 addSkippedToothTriggerEvents(TriggerWheel::T_PRIMARY, s, totalTeethCount, 0, toothWidth, /*offset*/0, engineCycle,
211 /*from*/ 30 + 1, /* to */ 195 + 1);
212
213
214 addSkippedToothTriggerEvents(TriggerWheel::T_PRIMARY, s, totalTeethCount, 0, toothWidth, /*offset*/0, engineCycle,
215 /*from*/ 210 + 1, /* to */ NO_RIGHT_FILTER);
216
218 int c = 9;
219 for (int gapIndex = 1; gapIndex <= c; gapIndex++) {
220 s->setTriggerSynchronizationGap3(gapIndex, 0.75, 1.25);
221 }
222
223
224}
Trigger shape has all the fields needed to describe and decode trigger signal.
void initialize(operation_mode_e operationMode, SyncEdge syncEdge)
void setSecondTriggerSynchronizationGap(float syncRatio)
angle_t getCycleDuration() const
void setTriggerSynchronizationGap(float syncRatio)
void addToothRiseFall(angle_t angle, angle_t width=10, TriggerWheel const channelIndex=TriggerWheel::T_PRIMARY)
void addEventAngle(angle_t angle, TriggerValue const state, TriggerWheel const channelIndex=TriggerWheel::T_PRIMARY)
void addEvent720(angle_t angle, TriggerValue const state, TriggerWheel const channelIndex=TriggerWheel::T_PRIMARY)
void addEvent360(angle_t angle, TriggerValue const state, TriggerWheel const channelIndex=TriggerWheel::T_PRIMARY)
void setTriggerSynchronizationGap3(int index, float syncRatioFrom, float syncRatioTo)
void addEventClamped(angle_t angle, TriggerValue const state, TriggerWheel const channelIndex, float filterLeft, float filterRight)
@ FOUR_STROKE_CRANK_SENSOR
@ FOUR_STROKE_CAM_SENSOR
@ TWO_STROKE
void configureDaihatsu4cyl(TriggerWaveform *s)
void configureDaihatsu3cyl(TriggerWaveform *s)
void configureBarra3plus1cam(TriggerWaveform *s)
void configureFordPip(TriggerWaveform *s)
void configureTriTach(TriggerWaveform *s)
void configureFiatIAQ_P8(TriggerWaveform *s)
void configureFordST170(TriggerWaveform *s)
static void daihatsu(TriggerWaveform *s, int count)
void configure60degSingleTooth(TriggerWaveform *s)
Configure trigger as Sovek or Saruman ignition.
void configureArcticCat(TriggerWaveform *s)
void configureBenelli(TriggerWaveform *s)
void addSkippedToothTriggerEvents(TriggerWheel wheel, TriggerWaveform *s, int totalTeethCount, int skippedCount, float toothWidthPercentage, float offset, float engineCycle, float filterLeft, float filterRight)
uint16_t offset
Definition tunerstudio.h:0
uint16_t count
Definition tunerstudio.h:1