2021-07-02 11:56:12 -07:00
|
|
|
/*
|
|
|
|
* @file nissan_vq.cpp
|
|
|
|
*
|
|
|
|
* Created on: Jul 2, 2021
|
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2021
|
|
|
|
*/
|
|
|
|
|
2022-08-05 13:55:49 -07:00
|
|
|
#include "pch.h"
|
|
|
|
|
2021-07-02 11:56:12 -07:00
|
|
|
#include "nissan_vq.h"
|
2022-11-02 08:17:24 -07:00
|
|
|
#include "hellen_meta.h"
|
|
|
|
|
|
|
|
#define NISSAN_VQ_VVT_OFFSET 157
|
2021-07-02 11:56:12 -07:00
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
void setHellen121nissanQR() {
|
2021-08-08 04:04:18 -07:00
|
|
|
engineConfiguration->trigger.type = TT_NISSAN_QR25;
|
|
|
|
|
2023-03-27 00:58:18 -07:00
|
|
|
engineConfiguration->cylindersCount = 4;
|
|
|
|
engineConfiguration->firingOrder = FO_1_3_4_2;
|
|
|
|
engineConfiguration->displacement = 2;
|
2021-11-17 00:54:21 -08:00
|
|
|
strcpy(engineConfiguration->engineCode, "QR");
|
2021-08-08 04:04:18 -07:00
|
|
|
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->camInputs[1 * CAMS_PER_BANK] = Gpio::Unassigned;
|
2021-08-11 15:29:02 -07:00
|
|
|
|
2021-08-08 04:04:18 -07:00
|
|
|
engineConfiguration->vvtMode[0] = VVT_NISSAN_VQ;
|
|
|
|
|
|
|
|
// we have this here and not in board_configuration.cpp so that unit test would get this value
|
|
|
|
engineConfiguration->invertCamVVTSignal = true;
|
|
|
|
|
2022-11-02 08:17:24 -07:00
|
|
|
engineConfiguration->vvtOffsets[0] = 157;
|
2021-08-08 03:15:37 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-03-26 09:47:04 -07:00
|
|
|
static void setNissanVqEngineConfig() {
|
2022-11-09 17:57:46 -08:00
|
|
|
setNissanMAF0031(config);
|
2023-03-26 09:47:04 -07:00
|
|
|
engineConfiguration->trigger.type = TT_NISSAN_VQ35;
|
2022-11-09 17:57:46 -08:00
|
|
|
|
2023-03-27 00:58:18 -07:00
|
|
|
engineConfiguration->cylindersCount = 6;
|
|
|
|
engineConfiguration->firingOrder = FO_1_2_3_4_5_6;
|
|
|
|
engineConfiguration->displacement = 4;
|
2021-11-17 00:54:21 -08:00
|
|
|
strcpy(engineConfiguration->engineCode, "VQ");
|
2021-08-08 04:04:18 -07:00
|
|
|
|
2021-07-02 11:56:12 -07:00
|
|
|
engineConfiguration->vvtMode[0] = VVT_NISSAN_VQ;
|
2021-07-03 09:43:01 -07:00
|
|
|
|
2022-11-02 08:17:24 -07:00
|
|
|
engineConfiguration->vvtOffsets[0 * CAMS_PER_BANK] = NISSAN_VQ_VVT_OFFSET;
|
|
|
|
engineConfiguration->vvtOffsets[1 * CAMS_PER_BANK] = NISSAN_VQ_VVT_OFFSET + NISSAN_VQ_CAM_OFFSET;
|
|
|
|
|
|
|
|
// VVT closed loop
|
|
|
|
engineConfiguration->auxPid[0].pFactor = 2;
|
|
|
|
engineConfiguration->auxPid[0].iFactor = 0.5;
|
|
|
|
engineConfiguration->auxPid[0].dFactor = 0.05;
|
|
|
|
engineConfiguration->auxPid[0].offset = 50;
|
|
|
|
// engineConfiguration->auxPid[0].minValue = 20;
|
|
|
|
// engineConfiguration->auxPid[0].maxValue = 90;
|
|
|
|
|
2023-03-26 09:47:04 -07:00
|
|
|
engineConfiguration->cranking.baseFuel = 35;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setHellen121nissanVQ() {
|
|
|
|
#include "nissan_vq.lua"
|
|
|
|
|
|
|
|
setNissanVqEngineConfig();
|
|
|
|
|
|
|
|
// we have this here and not in board_configuration.cpp so that unit test would get this value
|
|
|
|
engineConfiguration->invertCamVVTSignal = true;
|
|
|
|
|
2022-11-02 08:17:24 -07:00
|
|
|
#if HW_HELLEN
|
|
|
|
engineConfiguration->vvtPins[0 * CAMS_PER_BANK] = H176_LS_7;
|
|
|
|
engineConfiguration->vvtPins[1 * CAMS_PER_BANK] = H176_LS_8;
|
|
|
|
#endif
|
2023-03-26 09:47:04 -07:00
|
|
|
}
|
2022-08-05 18:01:06 -07:00
|
|
|
|
2023-03-26 09:47:04 -07:00
|
|
|
void setProteusNissanVQ() {
|
|
|
|
setNissanVqEngineConfig();
|
|
|
|
|
|
|
|
// open question if that's a board setting or engine setting
|
|
|
|
engineConfiguration->invertCamVVTSignal = true;
|
2021-07-02 11:56:12 -07:00
|
|
|
}
|
2021-08-16 07:56:31 -07:00
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
void setHellen121nissanAltimaN16() {
|
2021-08-16 07:56:31 -07:00
|
|
|
// https://en.wikipedia.org/wiki/Nissan_QG_engine
|
|
|
|
// https://en.wikipedia.org/wiki/N-VCT
|
2021-11-16 01:15:29 -08:00
|
|
|
setHellen121nissanQR();
|
2023-03-27 00:58:18 -07:00
|
|
|
engineConfiguration->displacement = 1.8;
|
2021-11-17 00:54:21 -08:00
|
|
|
strcpy(engineConfiguration->engineCode, "N16");
|
2021-08-16 07:56:31 -07:00
|
|
|
|
|
|
|
}
|