2021-05-01 16:15:23 -07:00
|
|
|
/**
|
2021-05-01 16:45:09 -07:00
|
|
|
* @file boards/hellen/hellen121nissan/board_configuration.cpp
|
2021-05-01 16:15:23 -07:00
|
|
|
*
|
2022-01-12 10:34:21 -08:00
|
|
|
* All fabricated boards use 144 pin MCU
|
2021-05-01 16:15:23 -07:00
|
|
|
*
|
2021-05-01 16:45:09 -07:00
|
|
|
* @brief Configuration defaults for the hellen121nissan board
|
2021-05-01 16:15:23 -07:00
|
|
|
*
|
2021-05-01 16:45:09 -07:00
|
|
|
* See https://rusefi.com/s/hellen121nissan
|
2021-05-01 16:15:23 -07:00
|
|
|
*
|
|
|
|
* @author andreika <prometheus.pcb@gmail.com>
|
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2020
|
|
|
|
*/
|
|
|
|
|
2021-08-03 19:05:01 -07:00
|
|
|
#include "pch.h"
|
2022-10-29 20:46:54 -07:00
|
|
|
#include "defaults.h"
|
2021-12-30 16:14:32 -08:00
|
|
|
#include "hellen_meta.h"
|
2021-05-01 16:15:23 -07:00
|
|
|
|
|
|
|
static void setInjectorPins() {
|
2021-10-02 22:08:35 -07:00
|
|
|
engineConfiguration->injectionPins[0] = H144_LS_1;
|
|
|
|
engineConfiguration->injectionPins[1] = H144_LS_2;
|
|
|
|
engineConfiguration->injectionPins[2] = H144_LS_3;
|
|
|
|
engineConfiguration->injectionPins[3] = H144_LS_4;
|
|
|
|
engineConfiguration->injectionPins[4] = H144_LS_5;
|
|
|
|
engineConfiguration->injectionPins[5] = H144_LS_6;
|
2021-05-01 16:15:23 -07:00
|
|
|
|
|
|
|
// Disable remainder
|
2021-07-06 17:14:08 -07:00
|
|
|
for (int i = 6; i < MAX_CYLINDER_COUNT;i++) {
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->injectionPins[i] = Gpio::Unassigned;
|
2021-05-01 16:15:23 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
engineConfiguration->injectionPinMode = OM_DEFAULT;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setIgnitionPins() {
|
2021-10-11 20:47:40 -07:00
|
|
|
engineConfiguration->ignitionPins[0] = H144_IGN_1;
|
|
|
|
engineConfiguration->ignitionPins[1] = H144_IGN_2;
|
|
|
|
engineConfiguration->ignitionPins[2] = H144_IGN_3;
|
|
|
|
engineConfiguration->ignitionPins[3] = H144_IGN_4;
|
|
|
|
engineConfiguration->ignitionPins[4] = H144_IGN_5;
|
|
|
|
engineConfiguration->ignitionPins[5] = H144_IGN_6;
|
2021-05-01 16:15:23 -07:00
|
|
|
|
|
|
|
// disable remainder
|
2021-07-06 17:14:08 -07:00
|
|
|
for (int i = 6; i < MAX_CYLINDER_COUNT; i++) {
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->ignitionPins[i] = Gpio::Unassigned;
|
2021-05-01 16:15:23 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
engineConfiguration->ignitionPinMode = OM_DEFAULT;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setupVbatt() {
|
|
|
|
// 4.7k high side/4.7k low side = 2.0 ratio divider
|
|
|
|
engineConfiguration->analogInputDividerCoefficient = 2.0f;
|
|
|
|
|
|
|
|
// set vbatt_divider 5.835
|
|
|
|
// 33k / 6.8k
|
|
|
|
engineConfiguration->vbattDividerCoeff = (33 + 6.8) / 6.8; // 5.835
|
|
|
|
|
|
|
|
// pin input +12 from Main Relay
|
|
|
|
engineConfiguration->vbattAdcChannel = EFI_ADC_5; // 4T
|
|
|
|
|
|
|
|
engineConfiguration->adcVcc = 3.29f;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setupDefaultSensorInputs() {
|
|
|
|
// trigger inputs
|
2021-10-10 18:46:26 -07:00
|
|
|
engineConfiguration->triggerInputPins[0] = H144_IN_CRANK;
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->triggerInputPins[1] = Gpio::Unassigned;
|
2021-05-01 16:15:23 -07:00
|
|
|
// Direct hall-only cam input
|
2021-10-10 18:46:26 -07:00
|
|
|
engineConfiguration->camInputs[0] = H144_IN_CAM;
|
2021-08-11 15:29:02 -07:00
|
|
|
// todo: remove from default since 4 cylinder does not use it
|
|
|
|
// todo: this requires unit test change
|
2021-10-10 18:46:26 -07:00
|
|
|
engineConfiguration->camInputs[1 * CAMS_PER_BANK] = H144_IN_D_AUX4;
|
2021-05-01 16:15:23 -07:00
|
|
|
|
2022-10-29 21:17:42 -07:00
|
|
|
setTPS1Inputs(H144_IN_TPS, H144_IN_AUX1);
|
2021-05-01 16:15:23 -07:00
|
|
|
|
2022-10-29 20:46:54 -07:00
|
|
|
setPPSInputs(H144_IN_PPS, EFI_ADC_14);
|
2021-05-01 16:15:23 -07:00
|
|
|
engineConfiguration->mafAdcChannel = EFI_ADC_10;
|
2022-01-12 10:34:21 -08:00
|
|
|
engineConfiguration->map.sensor.hwChannel = H144_IN_MAP2;
|
2021-05-01 16:15:23 -07:00
|
|
|
|
|
|
|
engineConfiguration->afr.hwChannel = EFI_ADC_1;
|
|
|
|
|
2021-10-09 20:34:33 -07:00
|
|
|
engineConfiguration->clt.adcChannel = H144_IN_CLT;
|
2021-05-01 16:15:23 -07:00
|
|
|
|
2021-10-09 20:34:33 -07:00
|
|
|
engineConfiguration->iat.adcChannel = H144_IN_IAT;
|
2021-05-01 16:15:23 -07:00
|
|
|
|
|
|
|
engineConfiguration->auxTempSensor1.adcChannel = EFI_ADC_NONE;
|
|
|
|
engineConfiguration->auxTempSensor2.adcChannel = EFI_ADC_NONE;
|
|
|
|
}
|
|
|
|
|
2022-01-11 19:26:24 -08:00
|
|
|
void setBoardConfigOverrides() {
|
2021-09-29 08:47:04 -07:00
|
|
|
setHellen144LedPins();
|
2021-05-01 16:15:23 -07:00
|
|
|
setupVbatt();
|
2022-06-23 12:02:13 -07:00
|
|
|
setHellenSdCardSpi3();
|
2021-05-01 16:15:23 -07:00
|
|
|
|
2022-07-08 16:32:16 -07:00
|
|
|
engineConfiguration->etbIo[0].directionPin1 = H144_OUT_PWM7;
|
|
|
|
engineConfiguration->etbIo[0].directionPin2 = H144_OUT_PWM6;
|
|
|
|
engineConfiguration->etbIo[0].controlPin = Gpio::D13; // ETB_EN out_pwm1
|
|
|
|
engineConfiguration->etb_use_two_wires = true;
|
|
|
|
|
2021-05-01 16:15:23 -07:00
|
|
|
engineConfiguration->clt.config.bias_resistor = 4700;
|
|
|
|
engineConfiguration->iat.config.bias_resistor = 4700;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Board-specific configuration defaults.
|
|
|
|
*
|
|
|
|
* See also setDefaultEngineConfiguration
|
|
|
|
*
|
|
|
|
* @todo Add your board-specific code, if any.
|
|
|
|
*/
|
2022-01-11 19:26:24 -08:00
|
|
|
void setBoardDefaultConfiguration() {
|
2021-05-01 16:15:23 -07:00
|
|
|
setInjectorPins();
|
|
|
|
setIgnitionPins();
|
|
|
|
|
2021-07-15 14:49:58 -07:00
|
|
|
engineConfiguration->displayLogicLevelsInEngineSniffer = true;
|
2021-05-01 16:15:23 -07:00
|
|
|
engineConfiguration->isSdCardEnabled = true;
|
|
|
|
|
2021-11-17 00:54:21 -08:00
|
|
|
engineConfiguration->enableSoftwareKnock = true;
|
2022-08-05 12:24:12 -07:00
|
|
|
engineConfiguration->canNbcType = CAN_BUS_NBC_NONE; // none because handled by Lua!
|
2021-05-01 16:15:23 -07:00
|
|
|
|
2022-09-29 21:37:05 -07:00
|
|
|
setHellenCan();
|
2021-05-01 16:15:23 -07:00
|
|
|
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->fuelPumpPin = Gpio::D12; // OUT_IO9 // 113 Fuel Pump Relay
|
|
|
|
engineConfiguration->idle.solenoidPin = Gpio::Unassigned;
|
|
|
|
// engineConfiguration->fanPin = Gpio::D12; // OUT_PWM8
|
|
|
|
engineConfiguration->mainRelayPin = Gpio::G14; // pin: 111a, OUT_IO3
|
2021-05-01 16:15:23 -07:00
|
|
|
|
|
|
|
// "required" hardware is done - set some reasonable defaults
|
|
|
|
setupDefaultSensorInputs();
|
|
|
|
|
2021-07-22 20:44:25 -07:00
|
|
|
|
2021-05-01 16:15:23 -07:00
|
|
|
// Some sensible defaults for other options
|
2022-04-02 23:21:37 -07:00
|
|
|
setCrankOperationMode();
|
2021-07-02 13:26:23 -07:00
|
|
|
|
2021-07-15 14:53:38 -07:00
|
|
|
engineConfiguration->vvtCamSensorUseRise = true;
|
2021-05-01 16:15:23 -07:00
|
|
|
engineConfiguration->useOnlyRisingEdgeForTrigger = true;
|
2022-04-23 18:11:30 -07:00
|
|
|
// setAlgorithm(LM_SPEED_DENSITY);
|
|
|
|
// at least this starts
|
|
|
|
engineConfiguration->fuelAlgorithm = LM_ALPHA_N;
|
2021-05-01 16:15:23 -07:00
|
|
|
|
2022-08-05 18:01:06 -07:00
|
|
|
engineConfiguration->cranking.rpm = 400;
|
|
|
|
engineConfiguration->fanOnTemperature = 85;
|
|
|
|
engineConfiguration->fanOffTemperature = 81;
|
|
|
|
|
|
|
|
engineConfiguration->useETBforIdleControl = true;
|
|
|
|
engineConfiguration->etbIdleThrottleRange = 10;
|
|
|
|
engineConfiguration->cutFuelOnHardLimit = false;
|
|
|
|
engineConfiguration->idlePidRpmUpperLimit = 300;
|
|
|
|
engineConfiguration->mapErrorDetectionTooLow = 10;
|
|
|
|
|
2021-07-01 14:02:18 -07:00
|
|
|
|
|
|
|
// Bosch VQ40 VR56 VK56 0280158007
|
|
|
|
engineConfiguration->injector.flow = 296.2;
|
|
|
|
|
2021-11-17 00:54:21 -08:00
|
|
|
strcpy(engineConfiguration->engineMake, ENGINE_MAKE_NISSAN);
|
2021-05-01 16:15:23 -07:00
|
|
|
|
|
|
|
engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; // IM_WASTED_SPARK
|
2022-08-06 06:13:23 -07:00
|
|
|
engineConfiguration->injectionMode = IM_SEQUENTIAL;
|
2021-07-11 08:26:19 -07:00
|
|
|
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->luaOutputPins[0] = Gpio::G5; // 104 ETB Relay
|
2021-09-13 18:30:45 -07:00
|
|
|
|
2022-10-29 20:55:14 -07:00
|
|
|
setPPSCalibration(0.75, 4.45, 0.43, 2.20);
|
2021-09-15 12:50:48 -07:00
|
|
|
|
2022-08-06 06:13:23 -07:00
|
|
|
engineConfiguration->startUpFuelPumpDuration = 4;
|
|
|
|
engineConfiguration->postCrankingFactor = 1.05;
|
|
|
|
|
|
|
|
engineConfiguration->etb.pFactor = 6.1350;
|
|
|
|
engineConfiguration->etb.iFactor = 87.7182;
|
|
|
|
engineConfiguration->etb.dFactor = 0.0702;
|
|
|
|
|
2021-10-10 19:23:33 -07:00
|
|
|
// this calibration reminds me of VAG just flipped?
|
2021-09-15 12:50:48 -07:00
|
|
|
engineConfiguration->tpsMin = 100;
|
|
|
|
engineConfiguration->tpsMax = 889;
|
|
|
|
|
|
|
|
engineConfiguration->tps1SecondaryMin = 891;
|
|
|
|
engineConfiguration->tps1SecondaryMax = 102;
|
2021-07-11 08:26:19 -07:00
|
|
|
hellenWbo();
|
2021-05-01 16:15:23 -07:00
|
|
|
}
|