rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
trigger_nissan.cpp
Go to the documentation of this file.
1/**
2 * @file trigger_nissan.cpp
3 *
4 * https://rusefi.com/forum/viewtopic.php?f=3&t=1194&start=150#p27784
5 *
6 * @date Sep 19, 2015
7 * @author Andrey Belomutskiy, (c) 2012-2020
8 */
9
10#include "pch.h"
11
12#include "trigger_nissan.h"
13#include "trigger_universal.h"
14#include "trigger_subaru.h"
15
37
38/**
39 * 8,2,2,2 Nissan pattern
40 */
43
44 s->tdcPosition = 630;
45
46 s->setTriggerSynchronizationGap2(9.67 * 0.75, 16);
47
48 float width = 4;
49
50 s->addEvent720(1 * 180 - 4 * width, TriggerValue::RISE);
52
53 s->addEvent720(2 * 180 - width, TriggerValue::RISE);
55
56 s->addEvent720(3 * 180 - width, TriggerValue::RISE);
58
59 s->addEvent720(4 * 180 - width, TriggerValue::RISE);
61}
62
78
79void makeNissanPattern(TriggerWaveform* s, size_t halfCylinderCount, size_t totalWheel, size_t missing) {
80
81 auto toothAngle = 360.0f / totalWheel;
82
83 auto patternTeeth = totalWheel / halfCylinderCount;
84 auto toothCount = patternTeeth - missing;
85
86 float currentAngle = missing * toothAngle;
87 for (size_t i = 0; i < toothCount; i++) {
88 currentAngle += toothAngle;
89 s->addEventAngle(currentAngle - 5, TriggerValue::RISE);
90 s->addEventAngle(currentAngle, TriggerValue::FALL);
91 }
92}
93
96
97 s->tdcPosition = 675;
98
99 // 6 cylinder = 36 tooth wheel, missing 2 teeth in 3 spots
100 makeNissanPattern(s, 3, 36, 2);
101 s->setTriggerSynchronizationGap3(/*gapIndex*/0, 0.2, 0.5);
102 s->setTriggerSynchronizationGap3(/*gapIndex*/1, 2, 4);
103 s->setTriggerSynchronizationGap3(/*gapIndex*/2, 0.6, 1.4);
104}
105
108
109 s->tdcPosition = 80;
110
111 // 4 cylinder = 36 tooth wheel, missing 2 teeth in 2 spots
112 makeNissanPattern(s, 2, 36, 2);
114}
115
120
121 s->tdcPosition = 585;
122
123 float currentAngle = 20;
124 for (int i = 0;i < 16;i++) {
125 currentAngle += 10;
126 s->addEventAngle(currentAngle - 5, TriggerValue::RISE);
127 s->addEventAngle(currentAngle, TriggerValue::FALL);
128 }
129}
130
131static void addvq30tooth(TriggerWaveform *s, float angle) {
132 s->addEvent360(angle - 4, TriggerValue::RISE);
134}
135
136// yes, this is CAM shaft shape NOT crank shaft shape!
137// we will add crank shape once Pavel makes progress
140
141 s->tdcPosition = 120;
142
143 int x = 360 + 52;
144
145 addvq30tooth(s, x - (360 - 9 * 0));
146 addvq30tooth(s, x - (360 - 9 * 1));
147 addvq30tooth(s, x - (360 - 9 * 2));
148
149 addvq30tooth(s, x - (252 + 9 * 5));
150 addvq30tooth(s, x - (252 + 9 * 4));
151 addvq30tooth(s, x - (252 + 9 * 3));
152 addvq30tooth(s, x - (252 + 9 * 2));
153 addvq30tooth(s, x - (252 + 9 * 1));
154 addvq30tooth(s, x - (252 + 9 * 0));
155
156 addvq30tooth(s, x - (236 ));
157
158 addvq30tooth(s, x - (152 + 9 * 3));
159 addvq30tooth(s, x - (152 + 9 * 2));
160 addvq30tooth(s, x - (152 + 9 * 1));
161 addvq30tooth(s, x - (152 + 9 * 0));
162
163 addvq30tooth(s, x - (85 + 9 * 4));
164 addvq30tooth(s, x - (85 + 9 * 3));
165 addvq30tooth(s, x - (85 + 9 * 2));
166 addvq30tooth(s, x - (85 + 9 * 1));
167 addvq30tooth(s, x - (85 + 9 * 0));
168
169 addvq30tooth(s, x - (52 + 9 * 1));
170 addvq30tooth(s, x - (52 + 9 * 0));
171
172 s->setTriggerSynchronizationGap4(/*gapIndex*/0, 5.78);
173 s->setTriggerSynchronizationGap4(/*gapIndex*/1, 0.38);
174 s->setTriggerSynchronizationGap4(/*gapIndex*/2, 2.67);
175}
176
179 s->tdcPosition = 0;
180
181 int x = 73;
182
183 // All "groups" start every 90 degrees of cam rotation
184 // The groups have 1, 3, 4, 2 teeth each (which is the firing order?)
185
186 // Teeth within a group are spaced 17 cam degrees apart
187 int toothSpacing = 17;
188
189 // "1"
190 addvq30tooth(s, x + 0); // <-- sync point here
191
192 // "3"
193 addvq30tooth(s, x + 90 + 0 * toothSpacing);
194 addvq30tooth(s, x + 90 + 1 * toothSpacing);
195 addvq30tooth(s, x + 90 + 2 * toothSpacing);
196
197 // "4"
198 addvq30tooth(s, x + 180 + 0 * toothSpacing);
199 addvq30tooth(s, x + 180 + 1 * toothSpacing);
200 addvq30tooth(s, x + 180 + 2 * toothSpacing);
201 addvq30tooth(s, x + 180 + 3 * toothSpacing);
202
203 // "2"
204 addvq30tooth(s, x + 270 + 0 * toothSpacing);
205 addvq30tooth(s, x + 270 + 1 * toothSpacing);
206
207 // nominal gap 4.31
209
210 // nominal gap 0.44
212}
213
214void initialize_one_of_36_2_2(TriggerWaveform *s, int firstCount, int secondCount) {
216
217 float narrow = 360 / 36;
218 float wide = narrow * 3;
219
220 float base = 0;
221
222 for (int i = 0; i < firstCount; i++) {
223 s->addToothFallRise(base + narrow, narrow / 2);
224 base += narrow;
225 }
226
227 s->addToothFallRise(base + wide, wide / 2);
228 base += wide;
229
230 for (int i = 0; i < secondCount; i++) {
231 s->addToothFallRise(base + narrow, narrow / 2);
232 base += narrow;
233 }
234
235 s->addToothFallRise(360, narrow/2);
236}
237
239 initialize_one_of_36_2_2(s, 9, 21);
240
241 size_t count = 9;
242
243 s->tdcPosition = 155 + 360;
244
245 s->setTriggerSynchronizationGap3(/*gapIndex*/0, 1.7, 5);
246 for (size_t i = 1 ; i < count ; i++) {
247 s->setTriggerSynchronizationGap3(/*gapIndex*/i, 0.6, 1.5);
248 }
249 s->setTriggerSynchronizationGap3(/*gapIndex*/count, 0.1, 0.5);
250 }
251
252
255
256
257 s->addToothRiseFall(120);
258 s->addToothRiseFall(120 + 22);
259 s->addToothRiseFall(240);
260 s->addToothRiseFall(360);
261
262 s->setTriggerSynchronizationGap3(/*gapIndex*/0, 0.1, 0.3);
263}
264
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)
void setTriggerSynchronizationGap(float syncRatio)
void addToothFallRise(angle_t angle, angle_t width=10, TriggerWheel const channelIndex=TriggerWheel::T_PRIMARY)
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 setSecondTriggerSynchronizationGap2(float syncRatioFrom, float syncRatioTo)
void setTriggerSynchronizationGap4(int index, float syncRatio)
void setTriggerSynchronizationGap2(float syncRatioFrom, float syncRatioTo)
void setTriggerSynchronizationGap3(int index, float syncRatioFrom, float syncRatioTo)
@ FOUR_STROKE_SYMMETRICAL_CRANK_SENSOR
@ FOUR_STROKE_THREE_TIMES_CRANK_SENSOR
@ FOUR_STROKE_CRANK_SENSOR
@ FOUR_STROKE_CAM_SENSOR
void initializeNissanVQvvt(TriggerWaveform *s)
static void addvq30tooth(TriggerWaveform *s, float angle)
void initializeNissanSR20VE_4(TriggerWaveform *s)
void initializeNissanQR25crank(TriggerWaveform *s)
void makeNissanPattern(TriggerWaveform *s, size_t halfCylinderCount, size_t totalWheel, size_t missing)
void initializeNissanVQ35crank(TriggerWaveform *s)
void initializeNissanHRvvtIn(TriggerWaveform *s)
void initialize_one_of_36_2_2(TriggerWaveform *s, int firstCount, int secondCount)
void initializeNissanVQ30cam(TriggerWaveform *s)
void initializeNissanMR18crank(TriggerWaveform *s)
void initializeNissanHRcrank(TriggerWaveform *s)
void initializeNissanMRvvt(TriggerWaveform *s)
void initializeNissanK11(TriggerWaveform *s)
uint16_t offset
Definition tunerstudio.h:0
uint16_t count
Definition tunerstudio.h:1