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
16/**
17 * 8,2,2,2 Nissan pattern
18 */
21
22 s->tdcPosition = 630;
23
24 s->setTriggerSynchronizationGap2(9.67 * 0.75, 16);
25
26 float width = 4;
27
28 s->addEvent720(1 * 180 - 4 * width, TriggerValue::RISE);
30
31 s->addEvent720(2 * 180 - width, TriggerValue::RISE);
33
34 s->addEvent720(3 * 180 - width, TriggerValue::RISE);
36
37 s->addEvent720(4 * 180 - width, TriggerValue::RISE);
39}
40
56
57void makeNissanPattern(TriggerWaveform* s, size_t halfCylinderCount, size_t totalWheel, size_t missing) {
58
59 auto toothAngle = 360.0f / totalWheel;
60
61 auto patternTeeth = totalWheel / halfCylinderCount;
62 auto toothCount = patternTeeth - missing;
63
64 float currentAngle = missing * toothAngle;
65 for (size_t i = 0; i < toothCount; i++) {
66 currentAngle += toothAngle;
67 s->addEventAngle(currentAngle - 5, TriggerValue::RISE);
68 s->addEventAngle(currentAngle, TriggerValue::FALL);
69 }
70}
71
74
75 s->tdcPosition = 675;
76
77 // 6 cylinder = 36 tooth wheel, missing 2 teeth in 3 spots
78 makeNissanPattern(s, 3, 36, 2);
79 s->setTriggerSynchronizationGap3(/*gapIndex*/0, 0.2, 0.5);
80 s->setTriggerSynchronizationGap3(/*gapIndex*/1, 2, 4);
81 s->setTriggerSynchronizationGap3(/*gapIndex*/2, 0.6, 1.4);
82}
83
86
87 s->tdcPosition = 80;
88
89 // 4 cylinder = 36 tooth wheel, missing 2 teeth in 2 spots
90 makeNissanPattern(s, 2, 36, 2);
92}
93
98
99 s->tdcPosition = 585;
100
101 float currentAngle = 20;
102 for (int i = 0;i < 16;i++) {
103 currentAngle += 10;
104 s->addEventAngle(currentAngle - 5, TriggerValue::RISE);
105 s->addEventAngle(currentAngle, TriggerValue::FALL);
106 }
107}
108
109static void addvq30tooth(TriggerWaveform *s, float angle) {
110 s->addEvent360(angle - 4, TriggerValue::RISE);
112}
113
114// yes, this is CAM shaft shape NOT crank shaft shape!
115// we will add crank shape once Pavel makes progress
118
119 s->tdcPosition = 120;
120
121 int x = 360 + 52;
122
123 addvq30tooth(s, x - (360 - 9 * 0));
124 addvq30tooth(s, x - (360 - 9 * 1));
125 addvq30tooth(s, x - (360 - 9 * 2));
126
127 addvq30tooth(s, x - (252 + 9 * 5));
128 addvq30tooth(s, x - (252 + 9 * 4));
129 addvq30tooth(s, x - (252 + 9 * 3));
130 addvq30tooth(s, x - (252 + 9 * 2));
131 addvq30tooth(s, x - (252 + 9 * 1));
132 addvq30tooth(s, x - (252 + 9 * 0));
133
134 addvq30tooth(s, x - (236 ));
135
136 addvq30tooth(s, x - (152 + 9 * 3));
137 addvq30tooth(s, x - (152 + 9 * 2));
138 addvq30tooth(s, x - (152 + 9 * 1));
139 addvq30tooth(s, x - (152 + 9 * 0));
140
141 addvq30tooth(s, x - (85 + 9 * 4));
142 addvq30tooth(s, x - (85 + 9 * 3));
143 addvq30tooth(s, x - (85 + 9 * 2));
144 addvq30tooth(s, x - (85 + 9 * 1));
145 addvq30tooth(s, x - (85 + 9 * 0));
146
147 addvq30tooth(s, x - (52 + 9 * 1));
148 addvq30tooth(s, x - (52 + 9 * 0));
149
150 s->setTriggerSynchronizationGap4(/*gapIndex*/0, 5.78);
151 s->setTriggerSynchronizationGap4(/*gapIndex*/1, 0.38);
152 s->setTriggerSynchronizationGap4(/*gapIndex*/2, 2.67);
153}
154
157 s->tdcPosition = 0;
158
159 int x = 73;
160
161 // All "groups" start every 90 degrees of cam rotation
162 // The groups have 1, 3, 4, 2 teeth each (which is the firing order?)
163
164 // Teeth within a group are spaced 17 cam degrees apart
165 int toothSpacing = 17;
166
167 // "1"
168 addvq30tooth(s, x + 0); // <-- sync point here
169
170 // "3"
171 addvq30tooth(s, x + 90 + 0 * toothSpacing);
172 addvq30tooth(s, x + 90 + 1 * toothSpacing);
173 addvq30tooth(s, x + 90 + 2 * toothSpacing);
174
175 // "4"
176 addvq30tooth(s, x + 180 + 0 * toothSpacing);
177 addvq30tooth(s, x + 180 + 1 * toothSpacing);
178 addvq30tooth(s, x + 180 + 2 * toothSpacing);
179 addvq30tooth(s, x + 180 + 3 * toothSpacing);
180
181 // "2"
182 addvq30tooth(s, x + 270 + 0 * toothSpacing);
183 addvq30tooth(s, x + 270 + 1 * toothSpacing);
184
185 // nominal gap 4.31
187
188 // nominal gap 0.44
190}
191
192void initialize_one_of_36_2_2(TriggerWaveform *s, int firstCount, int secondCount) {
194
195 float narrow = 360 / 36;
196 float wide = narrow * 3;
197
198 float base = 0;
199
200 for (int i = 0; i < firstCount; i++) {
201 s->addToothFallRise(base + narrow, narrow / 2);
202 base += narrow;
203 }
204
205 s->addToothFallRise(base + wide, wide / 2);
206 base += wide;
207
208 for (int i = 0; i < secondCount; i++) {
209 s->addToothFallRise(base + narrow, narrow / 2);
210 base += narrow;
211 }
212
213 s->addToothFallRise(360, narrow/2);
214}
215
217 initialize_one_of_36_2_2(s, 9, 21);
218
219 size_t count = 9;
220
221 s->tdcPosition = 155 + 360;
222
223 s->setTriggerSynchronizationGap3(/*gapIndex*/0, 1.7, 5);
224 for (size_t i = 1 ; i < count ; i++) {
225 s->setTriggerSynchronizationGap3(/*gapIndex*/i, 0.6, 1.5);
226 }
227 s->setTriggerSynchronizationGap3(/*gapIndex*/count, 0.1, 0.5);
228 }
229
230
233
234
235 s->addToothRiseFall(120);
236 s->addToothRiseFall(120 + 22);
237 s->addToothRiseFall(240);
238 s->addToothRiseFall(360);
239
240 s->setTriggerSynchronizationGap3(/*gapIndex*/0, 0.1, 0.3);
241}
242
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)
uint16_t offset
Definition tunerstudio.h:0
uint16_t count
Definition tunerstudio.h:1