-
-
Notifications
You must be signed in to change notification settings - Fork 223
/
trigger_mazda.cpp
189 lines (147 loc) · 6.07 KB
/
trigger_mazda.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/**
* @file trigger_mazda.cpp
*
* @date Feb 18, 2014
* @author Andrey Belomutskiy, (c) 2012-2020
*
* This file is part of rusEfi - see http://rusefi.com
*
* rusEfi is free software; you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* rusEfi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "trigger_mazda.h"
#include "error_handling.h"
#define NB_CRANK_MAGIC 70
void initializeMazdaMiataNaShape(TriggerWaveform *s) {
s->initialize(FOUR_STROKE_CAM_SENSOR);
s->setTriggerSynchronizationGap2(4 * 0.75f, 4 * 1.4f);
s->useRiseEdge = false;
s->bothFrontsRequired = true;
s->gapBothDirections = true;
s->tdcPosition = 436.965;
/**
* http://rusefi.com/forum/viewtopic.php?f=3&t=729&p=12983#p12983
*/
s->addEvent720(52.960405, T_SECONDARY, TV_RISE);
s->addEvent720(122.635956, T_SECONDARY, TV_FALL);
s->addEvent720(216.897031, T_PRIMARY, TV_RISE);
s->addEvent720(232.640068, T_SECONDARY, TV_RISE);
s->addEvent720(288.819688, T_PRIMARY, TV_FALL);
s->addEvent720(302.646323, T_SECONDARY, TV_FALL);
s->addEvent720(412.448056, T_SECONDARY, TV_RISE);
s->addEvent720(482.816719, T_SECONDARY, TV_FALL);
s->addEvent720(577.035495, T_PRIMARY, TV_RISE);
s->addEvent720(592.878113, T_SECONDARY, TV_RISE);
s->addEvent720(662.899708, T_SECONDARY, TV_FALL);
s->addEvent720(720.0f, T_PRIMARY, TV_FALL);
s->useOnlyPrimaryForSync = true;
}
// TT_MIATA_VVT
void initializeMazdaMiataNb2Crank(TriggerWaveform *s) {
/**
* Note how we use 0..180 range while defining FOUR_STROKE_SYMMETRICAL_CRANK_SENSOR trigger
* Note that only half of the physical wheel is defined here!
*/
s->initialize(FOUR_STROKE_SYMMETRICAL_CRANK_SENSOR);
s->tdcPosition = 60 + 655;
s->setTriggerSynchronizationGap2(0.35f, 0.98f);
// todo: NB2 fronts are inverted comparing to NB1, life is not perfect :(
s->addEventAngle(180.0f - NB_CRANK_MAGIC - 4, T_PRIMARY, TV_FALL);
s->addEventAngle(180.0f - NB_CRANK_MAGIC, T_PRIMARY, TV_RISE);
s->addEventAngle(180.0f - 4, T_PRIMARY, TV_FALL);
s->addEventAngle(180.0f, T_PRIMARY, TV_RISE);
}
static void addNBCrankTooth(TriggerWaveform *s, angle_t angle, trigger_wheel_e const channelIndex) {
s->addEvent720(angle, channelIndex, TV_RISE);
s->addEvent720(angle + 4, channelIndex, TV_FALL);
}
static void initializeMazdaMiataNb1ShapeWithOffset(TriggerWaveform *s, float offset) {
s->initialize(FOUR_STROKE_CAM_SENSOR);
s->setTriggerSynchronizationGap3(0, 0.065, 0.17f);
s->useRiseEdge = false;
s->bothFrontsRequired = true;
s->useOnlyPrimaryForSync = true;
efiAssertVoid(OBD_PCM_Processor_Fault, s->gapBothDirections == false, "NB1 trigger measures on FALL events");
s->tdcPosition = 276;
/**
* cam sensor is primary, crank sensor is secondary
*/
s->addEvent720(20.0f, T_PRIMARY, TV_FALL);
addNBCrankTooth(s, offset + 66.0f, T_SECONDARY);
addNBCrankTooth(s, offset + 66.0f + NB_CRANK_MAGIC, T_SECONDARY);
addNBCrankTooth(s, offset + 66.0f + 180, T_SECONDARY);
addNBCrankTooth(s, offset + 66.0f + 180 + NB_CRANK_MAGIC, T_SECONDARY);
s->addEvent720(340.0f, T_PRIMARY, TV_RISE);
s->addEvent720(360.0f, T_PRIMARY, TV_FALL);
s->addEvent720(380.0f, T_PRIMARY, TV_RISE);
s->addEvent720(400.0f, T_PRIMARY, TV_FALL);
addNBCrankTooth(s, offset + 66.0f + 360, T_SECONDARY);
addNBCrankTooth(s, offset + 66.0f + 360 + NB_CRANK_MAGIC, T_SECONDARY);
addNBCrankTooth(s, offset + 66.0f + 540, T_SECONDARY);
addNBCrankTooth(s, offset + 66.0f + 540 + NB_CRANK_MAGIC, T_SECONDARY);
s->addEvent720(720.0f, T_PRIMARY, TV_RISE);
}
void initializeMazdaMiataNb1Shape(TriggerWaveform *s) {
initializeMazdaMiataNb1ShapeWithOffset(s, 0);
}
void initializeMazdaMiataVVtTestShape(TriggerWaveform *s) {
initializeMazdaMiataNb1ShapeWithOffset(s, -22);
}
void configureMazdaProtegeSOHC(TriggerWaveform *s) {
s->initialize(FOUR_STROKE_CAM_SENSOR);
// s->initialState[0] = 1;
// float w = 720 / 4 * 0.215;
float a = 5;
s->bothFrontsRequired = true;
float z = 0.093;
a = 180;
s->addEvent720(a - z * 720, T_PRIMARY, TV_RISE);
s->addEvent720(a, T_PRIMARY, TV_FALL);
a += 180;
s->addEvent720(a - z * 720, T_PRIMARY, TV_RISE);
s->addEvent720(a, T_PRIMARY, TV_FALL);
a += 180;
s->addEvent720(a - z * 720, T_PRIMARY, TV_RISE);
s->addEvent720(a, T_PRIMARY, TV_FALL);
a += 180;
s->addEvent720(a - z * 720, T_PRIMARY, TV_RISE);
s->addEvent720(a, T_PRIMARY, TV_FALL);
s->isSynchronizationNeeded = false;
s->shapeWithoutTdc = true;
}
void configureMazdaProtegeLx(TriggerWaveform *s) {
s->initialize(FOUR_STROKE_CAM_SENSOR);
/**
* based on https://svn.code.sf.net/p/rusefi/code/trunk/misc/logs/1993_escort_gt/MAIN_rfi_report_2015-02-01%2017_39.csv
*/
s->addEvent720(95.329254, T_PRIMARY, TV_RISE);
s->addEvent720(95.329254 + 14.876692, T_SECONDARY, TV_RISE);
s->addEvent720(95.329254 + 82.693557, T_SECONDARY, TV_FALL);
s->addEvent720(95.329254 + 137.119154, T_PRIMARY, TV_FALL);
s->addEvent720(95.329254 + 192.378308, T_SECONDARY, TV_RISE);
s->addEvent720(95.329254 + 261.556418, T_SECONDARY, TV_FALL);
s->addEvent720(95.329254 + 373.060597, T_SECONDARY, TV_RISE);
s->addEvent720(95.329254 + 443.503184, T_SECONDARY, TV_FALL);
s->addEvent720(95.329254 + 555.349776, T_SECONDARY, TV_RISE);
s->addEvent720(720, T_SECONDARY, TV_FALL);
s->tdcPosition = 137.119154;
s->isSynchronizationNeeded = false;
}
void initializeMazdaMiataVVtCamShape(TriggerWaveform *s) {
s->initialize(FOUR_STROKE_CAM_SENSOR);
s->setTriggerSynchronizationGap2(8.50 * TRIGGER_GAP_DEVIATION_LOW, 14.0);
s->addEvent720(325, T_PRIMARY, TV_FALL);
s->addEvent720(360, T_PRIMARY, TV_RISE);
s->addEvent720(641, T_PRIMARY, TV_FALL);
s->addEvent720(677, T_PRIMARY, TV_RISE);
s->addEvent720(700, T_PRIMARY, TV_FALL);
s->addEvent720(720, T_PRIMARY, TV_RISE);
}