2015-07-10 06:01:56 -07:00
|
|
|
/**
|
|
|
|
* @file trigger_mazda.cpp
|
|
|
|
*
|
|
|
|
* @date Feb 18, 2014
|
2020-01-13 18:57:43 -08:00
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2020
|
2015-07-10 06:01:56 -07:00
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2021-07-25 22:05:17 -07:00
|
|
|
#include "pch.h"
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
#include "trigger_mazda.h"
|
|
|
|
|
2021-04-15 15:44:37 -07:00
|
|
|
#define NB_CRANK_MAGIC 70
|
|
|
|
|
2019-12-07 22:09:39 -08:00
|
|
|
void initializeMazdaMiataNaShape(TriggerWaveform *s) {
|
2020-01-12 07:43:02 -08:00
|
|
|
s->initialize(FOUR_STROKE_CAM_SENSOR);
|
2022-04-01 18:10:08 -07:00
|
|
|
s->isSecondWheelCam = true;
|
2021-07-01 18:29:04 -07:00
|
|
|
|
|
|
|
// nominal gap is 0.325
|
2022-01-01 18:39:04 -08:00
|
|
|
s->setTriggerSynchronizationGap2(0.1, 0.5);
|
2021-11-18 23:30:05 -08:00
|
|
|
// nominal gap is ~1.52
|
2022-03-21 16:23:48 -07:00
|
|
|
s->setSecondTriggerSynchronizationGap2(0.5, 2.3);
|
2021-07-01 18:29:04 -07:00
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
s->useRiseEdge = false;
|
|
|
|
|
2019-08-08 19:57:22 -07:00
|
|
|
s->bothFrontsRequired = true;
|
2021-06-25 11:12:18 -07:00
|
|
|
s->gapBothDirections = true;
|
2019-08-08 19:57:22 -07:00
|
|
|
|
2021-07-01 18:29:04 -07:00
|
|
|
s->tdcPosition = 5.181;
|
2016-05-01 07:10:49 -07:00
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
/**
|
|
|
|
* http://rusefi.com/forum/viewtopic.php?f=3&t=729&p=12983#p12983
|
|
|
|
*/
|
2018-12-25 07:33:28 -08:00
|
|
|
s->addEvent720(52.960405, T_SECONDARY, TV_RISE);
|
|
|
|
s->addEvent720(122.635956, T_SECONDARY, TV_FALL);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2018-12-25 07:33:28 -08:00
|
|
|
s->addEvent720(216.897031, T_PRIMARY, TV_RISE);
|
|
|
|
s->addEvent720(232.640068, T_SECONDARY, TV_RISE);
|
2021-07-01 18:29:04 -07:00
|
|
|
s->addEvent720(288.819688, T_PRIMARY, TV_FALL); // <-- This edge is the sync point
|
2018-12-25 07:33:28 -08:00
|
|
|
s->addEvent720(302.646323, T_SECONDARY, TV_FALL);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2018-12-25 07:33:28 -08:00
|
|
|
s->addEvent720(412.448056, T_SECONDARY, TV_RISE);
|
|
|
|
s->addEvent720(482.816719, T_SECONDARY, TV_FALL);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2018-12-25 07:33:28 -08:00
|
|
|
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);
|
2016-06-11 21:00:15 -07:00
|
|
|
s->useOnlyPrimaryForSync = true;
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2017-02-12 10:02:00 -08:00
|
|
|
// TT_MIATA_VVT
|
2019-12-07 22:09:39 -08:00
|
|
|
void initializeMazdaMiataNb2Crank(TriggerWaveform *s) {
|
2020-12-04 10:54:16 -08:00
|
|
|
/**
|
|
|
|
* Note how we use 0..180 range while defining FOUR_STROKE_SYMMETRICAL_CRANK_SENSOR trigger
|
2020-12-04 12:22:53 -08:00
|
|
|
* Note that only half of the physical wheel is defined here!
|
2020-12-04 10:54:16 -08:00
|
|
|
*/
|
2020-01-12 07:43:02 -08:00
|
|
|
s->initialize(FOUR_STROKE_SYMMETRICAL_CRANK_SENSOR);
|
2016-11-13 19:03:03 -08:00
|
|
|
|
2017-02-12 10:02:00 -08:00
|
|
|
s->tdcPosition = 60 + 655;
|
2016-11-14 18:02:28 -08:00
|
|
|
|
2021-07-23 13:43:24 -07:00
|
|
|
// Nominal gap 70/110 = 0.636
|
2021-12-31 12:47:25 -08:00
|
|
|
s->setTriggerSynchronizationGap2(0.35f, 1.15f);
|
2021-07-23 13:43:24 -07:00
|
|
|
// Nominal gap 110/70 = 1.571
|
2021-12-31 12:47:25 -08:00
|
|
|
s->setSecondTriggerSynchronizationGap2(0.8f, 1.8f);
|
2021-07-23 13:43:24 -07:00
|
|
|
|
2021-04-15 16:12:09 -07:00
|
|
|
// 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);
|
2020-12-04 10:54:16 -08:00
|
|
|
s->addEventAngle(180.0f, T_PRIMARY, TV_RISE);
|
2016-11-13 19:03:03 -08:00
|
|
|
}
|
|
|
|
|
2021-04-15 15:44:37 -07:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2019-12-07 22:09:39 -08:00
|
|
|
static void initializeMazdaMiataNb1ShapeWithOffset(TriggerWaveform *s, float offset) {
|
2020-01-12 07:43:02 -08:00
|
|
|
s->initialize(FOUR_STROKE_CAM_SENSOR);
|
2019-10-30 18:01:23 -07:00
|
|
|
s->setTriggerSynchronizationGap3(0, 0.065, 0.17f);
|
2015-07-10 06:01:56 -07:00
|
|
|
s->useRiseEdge = false;
|
2019-10-29 18:19:00 -07:00
|
|
|
s->useOnlyPrimaryForSync = true;
|
|
|
|
efiAssertVoid(OBD_PCM_Processor_Fault, s->gapBothDirections == false, "NB1 trigger measures on FALL events");
|
2019-08-08 19:57:22 -07:00
|
|
|
|
2016-11-14 18:02:28 -08:00
|
|
|
s->tdcPosition = 276;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* cam sensor is primary, crank sensor is secondary
|
|
|
|
*/
|
2019-10-29 18:19:00 -07:00
|
|
|
s->addEvent720(20.0f, T_PRIMARY, TV_FALL);
|
|
|
|
|
2021-04-15 15:44:37 -07:00
|
|
|
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);
|
2019-10-29 18:19:00 -07:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2021-04-15 16:12:09 -07:00
|
|
|
addNBCrankTooth(s, offset + 66.0f + 360, T_SECONDARY);
|
|
|
|
addNBCrankTooth(s, offset + 66.0f + 360 + NB_CRANK_MAGIC, T_SECONDARY);
|
2021-04-15 15:44:37 -07:00
|
|
|
addNBCrankTooth(s, offset + 66.0f + 540, T_SECONDARY);
|
|
|
|
addNBCrankTooth(s, offset + 66.0f + 540 + NB_CRANK_MAGIC, T_SECONDARY);
|
2019-10-29 18:19:00 -07:00
|
|
|
|
|
|
|
s->addEvent720(720.0f, T_PRIMARY, TV_RISE);
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2019-12-07 22:09:39 -08:00
|
|
|
void initializeMazdaMiataVVtTestShape(TriggerWaveform *s) {
|
2018-12-25 09:27:34 -08:00
|
|
|
initializeMazdaMiataNb1ShapeWithOffset(s, -22);
|
2016-11-14 16:03:22 -08:00
|
|
|
}
|
|
|
|
|
2019-12-07 22:09:39 -08:00
|
|
|
void configureMazdaProtegeSOHC(TriggerWaveform *s) {
|
2020-01-12 07:43:02 -08:00
|
|
|
s->initialize(FOUR_STROKE_CAM_SENSOR);
|
2015-07-10 06:01:56 -07:00
|
|
|
// s->initialState[0] = 1;
|
|
|
|
|
|
|
|
// float w = 720 / 4 * 0.215;
|
|
|
|
float a = 5;
|
|
|
|
|
2019-08-08 19:57:22 -07:00
|
|
|
s->bothFrontsRequired = true;
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
float z = 0.093;
|
|
|
|
a = 180;
|
2018-12-25 08:51:49 -08:00
|
|
|
s->addEvent720(a - z * 720, T_PRIMARY, TV_RISE);
|
|
|
|
s->addEvent720(a, T_PRIMARY, TV_FALL);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
a += 180;
|
2018-12-25 08:51:49 -08:00
|
|
|
s->addEvent720(a - z * 720, T_PRIMARY, TV_RISE);
|
|
|
|
s->addEvent720(a, T_PRIMARY, TV_FALL);
|
2015-07-10 06:01:56 -07:00
|
|
|
a += 180;
|
2018-12-25 08:51:49 -08:00
|
|
|
s->addEvent720(a - z * 720, T_PRIMARY, TV_RISE);
|
|
|
|
s->addEvent720(a, T_PRIMARY, TV_FALL);
|
2015-07-10 06:01:56 -07:00
|
|
|
a += 180;
|
2018-12-25 08:51:49 -08:00
|
|
|
s->addEvent720(a - z * 720, T_PRIMARY, TV_RISE);
|
|
|
|
s->addEvent720(a, T_PRIMARY, TV_FALL);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
s->isSynchronizationNeeded = false;
|
2020-01-14 00:54:46 -08:00
|
|
|
s->shapeWithoutTdc = true;
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2019-12-07 22:09:39 -08:00
|
|
|
void configureMazdaProtegeLx(TriggerWaveform *s) {
|
2020-01-12 07:43:02 -08:00
|
|
|
s->initialize(FOUR_STROKE_CAM_SENSOR);
|
2022-04-01 18:10:08 -07:00
|
|
|
s->isSecondWheelCam = true;
|
2015-07-10 06:01:56 -07:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2018-12-25 08:51:49 -08:00
|
|
|
s->addEvent720(95.329254, T_PRIMARY, TV_RISE);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2018-12-25 08:51:49 -08:00
|
|
|
s->addEvent720(95.329254 + 14.876692, T_SECONDARY, TV_RISE);
|
|
|
|
s->addEvent720(95.329254 + 82.693557, T_SECONDARY, TV_FALL);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2018-12-25 08:51:49 -08:00
|
|
|
s->addEvent720(95.329254 + 137.119154, T_PRIMARY, TV_FALL);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2018-12-25 08:51:49 -08:00
|
|
|
s->addEvent720(95.329254 + 192.378308, T_SECONDARY, TV_RISE);
|
|
|
|
s->addEvent720(95.329254 + 261.556418, T_SECONDARY, TV_FALL);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2018-12-25 08:51:49 -08:00
|
|
|
s->addEvent720(95.329254 + 373.060597, T_SECONDARY, TV_RISE);
|
|
|
|
s->addEvent720(95.329254 + 443.503184, T_SECONDARY, TV_FALL);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2018-12-25 08:51:49 -08:00
|
|
|
s->addEvent720(95.329254 + 555.349776, T_SECONDARY, TV_RISE);
|
|
|
|
s->addEvent720(720, T_SECONDARY, TV_FALL);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
s->tdcPosition = 137.119154;
|
|
|
|
s->isSynchronizationNeeded = false;
|
|
|
|
}
|
2020-02-04 22:49:33 -08:00
|
|
|
|
|
|
|
void initializeMazdaMiataVVtCamShape(TriggerWaveform *s) {
|
|
|
|
s->initialize(FOUR_STROKE_CAM_SENSOR);
|
|
|
|
|
2021-07-21 17:07:28 -07:00
|
|
|
// Nominal gap is 8.92
|
2022-01-01 18:39:04 -08:00
|
|
|
s->setTriggerSynchronizationGap2(6, 20);
|
2021-07-21 17:07:28 -07:00
|
|
|
// Nominal gap is 0.128
|
2022-01-01 18:39:04 -08:00
|
|
|
s->setSecondTriggerSynchronizationGap2(0.04f, 0.2f);
|
2020-02-04 22:49:33 -08:00
|
|
|
|
|
|
|
s->addEvent720(325, T_PRIMARY, TV_FALL);
|
|
|
|
s->addEvent720(360, T_PRIMARY, TV_RISE);
|
|
|
|
|
|
|
|
s->addEvent720(641, T_PRIMARY, TV_FALL);
|
2021-07-21 17:07:28 -07:00
|
|
|
s->addEvent720(679, T_PRIMARY, TV_RISE);
|
2020-02-04 22:49:33 -08:00
|
|
|
|
|
|
|
s->addEvent720(700, T_PRIMARY, TV_FALL);
|
|
|
|
s->addEvent720(720, T_PRIMARY, TV_RISE);
|
|
|
|
}
|
2022-08-28 19:42:53 -07:00
|
|
|
|
|
|
|
// https://rusefi.com/forum/viewtopic.php?f=17&t=2417
|
2022-08-31 19:12:45 -07:00
|
|
|
// Cam pattern for intake/exhaust on all Skyactiv-G (and maybe -D/-X)
|
|
|
|
void initializeMazdaSkyactivCam(TriggerWaveform *s) {
|
2022-08-28 19:42:53 -07:00
|
|
|
s->initialize(FOUR_STROKE_CAM_SENSOR);
|
|
|
|
|
|
|
|
// wide
|
|
|
|
s->addEvent360(50, T_PRIMARY, TV_RISE);
|
|
|
|
s->addEvent360(70, T_PRIMARY, TV_FALL);
|
|
|
|
// narrow
|
|
|
|
s->addEvent360(80, T_PRIMARY, TV_RISE);
|
|
|
|
s->addEvent360(90, T_PRIMARY, TV_FALL);
|
|
|
|
|
|
|
|
// wide
|
|
|
|
s->addEvent360(140, T_PRIMARY, TV_RISE);
|
|
|
|
s->addEvent360(160, T_PRIMARY, TV_FALL);
|
|
|
|
// narrow
|
|
|
|
s->addEvent360(170, T_PRIMARY, TV_RISE);
|
|
|
|
s->addEvent360(180, T_PRIMARY, TV_FALL);
|
|
|
|
|
|
|
|
// wide
|
|
|
|
s->addEvent360(250, T_PRIMARY, TV_RISE);
|
|
|
|
s->addEvent360(270, T_PRIMARY, TV_FALL);
|
|
|
|
|
|
|
|
// wide
|
|
|
|
s->addEvent360(340, T_PRIMARY, TV_RISE);
|
|
|
|
s->addEvent360(360, T_PRIMARY, TV_FALL);
|
|
|
|
|
|
|
|
s->setTriggerSynchronizationGap(0.43);
|
|
|
|
s->setSecondTriggerSynchronizationGap(0.78);
|
|
|
|
s->setThirdTriggerSynchronizationGap(1.12); // 3rd gap is not required but let's have it for some resiliency
|
|
|
|
}
|