2019-12-26 18:33:12 -08:00
|
|
|
/*
|
|
|
|
* @file vw_b6.cpp
|
|
|
|
*
|
|
|
|
* @date Dec 26, 2019
|
2020-01-07 21:02:40 -08:00
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2020
|
2019-12-26 18:33:12 -08:00
|
|
|
*/
|
|
|
|
|
2021-08-03 19:05:01 -07:00
|
|
|
#include "pch.h"
|
|
|
|
|
2019-12-26 18:33:12 -08:00
|
|
|
#include "vw_b6.h"
|
2020-10-12 21:35:04 -07:00
|
|
|
#include "custom_engine.h"
|
2020-10-21 21:57:11 -07:00
|
|
|
#include "table_helper.h"
|
2021-10-10 19:23:33 -07:00
|
|
|
#include "electronic_throttle_impl.h"
|
2021-12-30 22:44:28 -08:00
|
|
|
#include "mre_meta.h"
|
2022-05-20 23:25:43 -07:00
|
|
|
#include "proteus_meta.h"
|
2019-12-26 18:33:12 -08:00
|
|
|
|
2022-05-20 23:25:43 -07:00
|
|
|
static void commonPassatB6() {
|
2022-04-02 23:21:37 -07:00
|
|
|
setCrankOperationMode();
|
2020-08-29 07:06:28 -07:00
|
|
|
engineConfiguration->trigger.type = TT_TOOTHED_WHEEL_60_2;
|
2021-02-08 18:50:31 -08:00
|
|
|
engineConfiguration->vvtMode[0] = VVT_BOSCH_QUICK_START;
|
2020-10-22 21:39:22 -07:00
|
|
|
engineConfiguration->map.sensor.type = MT_BOSCH_2_5;
|
2019-12-26 18:33:12 -08:00
|
|
|
|
2022-06-01 21:34:02 -07:00
|
|
|
engineConfiguration->specs.cylindersCount = 4;
|
|
|
|
engineConfiguration->specs.firingOrder = FO_1_3_4_2;
|
|
|
|
|
|
|
|
for (int i = 4; i < MAX_CYLINDER_COUNT;i++) {
|
|
|
|
engineConfiguration->injectionPins[i] = Gpio::Unassigned;
|
|
|
|
engineConfiguration->ignitionPins[i] = Gpio::Unassigned;
|
|
|
|
}
|
|
|
|
|
2022-01-09 18:16:11 -08:00
|
|
|
engineConfiguration->canNbcType = CAN_BUS_NBC_VAG;
|
2021-12-30 22:20:25 -08:00
|
|
|
|
2021-03-28 05:39:26 -07:00
|
|
|
// Injectors flow 1214 cc/min at 100 bar pressure
|
2021-01-23 17:08:57 -08:00
|
|
|
engineConfiguration->injector.flow = 1214;
|
2021-03-28 05:39:26 -07:00
|
|
|
// Use high pressure sensor
|
2021-01-23 17:08:57 -08:00
|
|
|
engineConfiguration->injectorPressureType = IPT_High;
|
2021-03-28 05:39:26 -07:00
|
|
|
// Automatic compensation of injector flow based on rail pressure
|
2021-01-23 17:08:57 -08:00
|
|
|
engineConfiguration->injectorCompensationMode = ICM_SensedRailPressure;
|
2021-03-28 05:39:26 -07:00
|
|
|
// Reference rail pressure is 10 000 kPa = 100 bar
|
|
|
|
engineConfiguration->fuelReferencePressure = 10000;
|
2021-01-23 17:08:57 -08:00
|
|
|
//setting "flat" 0.2 ms injector's lag time
|
|
|
|
setArrayValues(engineConfiguration->injector.battLagCorr, 0.2);
|
|
|
|
|
2021-11-17 00:54:21 -08:00
|
|
|
strcpy(engineConfiguration->engineMake, ENGINE_MAKE_VAG);
|
|
|
|
strcpy(engineConfiguration->engineCode, "BPY");
|
2022-01-10 10:53:02 -08:00
|
|
|
strcpy(engineConfiguration->vehicleName, "test");
|
2020-08-29 16:01:44 -07:00
|
|
|
|
2021-12-30 23:17:42 -08:00
|
|
|
engineConfiguration->throttlePedalUpVoltage = 0.36;
|
|
|
|
engineConfiguration->throttlePedalWOTVoltage = 2.13;
|
|
|
|
engineConfiguration->throttlePedalSecondaryUpVoltage = 0.73;
|
|
|
|
engineConfiguration->throttlePedalSecondaryWOTVoltage = 4.30;
|
2020-08-29 16:01:44 -07:00
|
|
|
|
2020-08-29 14:05:54 -07:00
|
|
|
engineConfiguration->verboseVVTDecoding = true;
|
2020-08-29 16:01:44 -07:00
|
|
|
engineConfiguration->invertCamVVTSignal = true;
|
|
|
|
engineConfiguration->vvtCamSensorUseRise = true;
|
2020-10-12 21:35:04 -07:00
|
|
|
|
2020-10-31 21:33:18 -07:00
|
|
|
/**
|
|
|
|
* PSS-140
|
|
|
|
*/
|
2020-10-27 22:01:54 -07:00
|
|
|
// todo: calibration
|
|
|
|
engineConfiguration->highPressureFuel.v1 = 0.5; /* volts */;
|
2020-10-31 21:33:18 -07:00
|
|
|
engineConfiguration->highPressureFuel.value1 = 0;
|
2020-10-27 22:01:54 -07:00
|
|
|
engineConfiguration->highPressureFuel.v2 = 4.5; /* volts */;
|
2020-10-31 21:33:18 -07:00
|
|
|
engineConfiguration->highPressureFuel.value2 = BAR2KPA(140);
|
2020-10-27 22:01:54 -07:00
|
|
|
|
2022-06-01 21:34:02 -07:00
|
|
|
engineConfiguration->lowPressureFuel.v1 = 0.5; /* volts */;
|
|
|
|
engineConfiguration->lowPressureFuel.value1 = PSI2KPA(0);
|
|
|
|
engineConfiguration->lowPressureFuel.v2 = 4.5; /* volts */;
|
|
|
|
// todo: what's the proper calibration of this Bosch sensor? is it really 200psi?
|
|
|
|
engineConfiguration->lowPressureFuel.value2 = PSI2KPA(200);
|
|
|
|
|
2022-05-20 23:25:43 -07:00
|
|
|
gppwm_channel *lowPressureFuelPumpControl = &engineConfiguration->gppwm[1];
|
|
|
|
strcpy(engineConfiguration->gpPwmNote[1], "LPFP");
|
|
|
|
lowPressureFuelPumpControl->pwmFrequency = 20;
|
|
|
|
lowPressureFuelPumpControl->loadAxis = GPPWM_FuelLoad;
|
|
|
|
lowPressureFuelPumpControl->dutyIfError = 50;
|
|
|
|
setTable(lowPressureFuelPumpControl->table, (uint8_t)50);
|
|
|
|
|
|
|
|
gppwm_channel *coolantControl = &engineConfiguration->gppwm[0];
|
|
|
|
strcpy(engineConfiguration->gpPwmNote[0], "Rad Fan");
|
|
|
|
|
|
|
|
coolantControl->pwmFrequency = 25;
|
|
|
|
coolantControl->loadAxis = GPPWM_FuelLoad;
|
|
|
|
// Volkswage wants 10% for fan to be OFF, between pull-up and low side control we need to invert that value
|
|
|
|
// todo system lua for duty driven by CLT? (3, Gpio::E0, "0.15 90 coolant 120 min max 90 - 30 / 0.8 * +", 25);
|
|
|
|
int value = 100 - 10;
|
|
|
|
coolantControl->dutyIfError = value;
|
|
|
|
setTable(coolantControl->table, (uint8_t)value);
|
|
|
|
// for now I just want to stop radiator whine
|
|
|
|
// todo: enable cooling!
|
|
|
|
/*
|
|
|
|
for (int load = 0; load < GPPWM_LOAD_COUNT; load++) {
|
|
|
|
for (int r = 0; r < GPPWM_RPM_COUNT; r++) {
|
|
|
|
engineConfiguration->gppwm[0].table[load][r] = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
engineConfiguration->hpfpCamLobes = 3;
|
|
|
|
engineConfiguration->hpfpPumpVolume = 0.290;
|
|
|
|
engineConfiguration->hpfpMinAngle = 10;
|
|
|
|
engineConfiguration->hpfpActivationAngle = 30;
|
|
|
|
engineConfiguration->hpfpTargetDecay = 2000;
|
|
|
|
engineConfiguration->hpfpPidP = 0.01;
|
|
|
|
engineConfiguration->hpfpPidI = 0.0003;
|
|
|
|
|
|
|
|
engineConfiguration->hpfpPeakPos = 10;
|
|
|
|
|
|
|
|
setTable(config->veTable, 55);
|
|
|
|
setBoschVAGETB();
|
|
|
|
|
|
|
|
// random number just to take position away from zero
|
|
|
|
engineConfiguration->vvtOffsets[0] = 180;
|
|
|
|
|
|
|
|
// https://rusefi.com/forum/viewtopic.php?p=38235#p38235
|
|
|
|
engineConfiguration->injector.flow = 1200;
|
|
|
|
|
|
|
|
engineConfiguration->idle.solenoidPin = Gpio::Unassigned;
|
|
|
|
engineConfiguration->fanPin = Gpio::Unassigned;
|
|
|
|
|
|
|
|
engineConfiguration->useETBforIdleControl = true;
|
|
|
|
engineConfiguration->injectionMode = IM_SEQUENTIAL;
|
2022-06-01 21:34:02 -07:00
|
|
|
engineConfiguration->crankingInjectionMode = IM_SEQUENTIAL;
|
|
|
|
}
|
2022-05-20 23:25:43 -07:00
|
|
|
|
2022-06-01 21:34:02 -07:00
|
|
|
/**
|
|
|
|
* set engine_type 39
|
|
|
|
*/
|
2022-05-20 23:25:43 -07:00
|
|
|
void setProteusVwPassatB6() {
|
|
|
|
#if HW_PROTEUS
|
|
|
|
commonPassatB6();
|
2022-05-31 20:02:04 -07:00
|
|
|
|
2022-06-01 21:34:02 -07:00
|
|
|
engineConfiguration->lowPressureFuel.hwChannel = PROTEUS_IN_ANALOG_VOLT_5;
|
|
|
|
engineConfiguration->highPressureFuel.hwChannel = PROTEUS_IN_ANALOG_VOLT_4;
|
|
|
|
|
2022-05-31 19:26:18 -07:00
|
|
|
gppwm_channel *coolantControl = &engineConfiguration->gppwm[0];
|
|
|
|
coolantControl->pin = PROTEUS_LS_5;
|
|
|
|
|
|
|
|
engineConfiguration->mainRelayPin = PROTEUS_LS_6;
|
|
|
|
|
|
|
|
gppwm_channel *lowPressureFuelPumpControl = &engineConfiguration->gppwm[1];
|
|
|
|
lowPressureFuelPumpControl->pin = PROTEUS_LS_7;
|
2022-05-31 20:02:04 -07:00
|
|
|
#endif
|
2022-05-20 23:25:43 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* set engine_type 62
|
|
|
|
* VW_B6
|
|
|
|
* has to be microRusEFI 0.5.2
|
|
|
|
*/
|
|
|
|
void setMreVwPassatB6() {
|
|
|
|
#if HW_MICRO_RUSEFI
|
|
|
|
commonPassatB6();
|
|
|
|
|
|
|
|
engineConfiguration->tps1_2AdcChannel = MRE_IN_ANALOG_VOLT_9;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// EFI_ADC_7: "31 - AN volt 3" - PA7
|
|
|
|
engineConfiguration->throttlePedalPositionAdcChannel = MRE_IN_ANALOG_VOLT_3;
|
|
|
|
// 36 - AN volt 8
|
|
|
|
engineConfiguration->throttlePedalPositionSecondAdcChannel = MRE_IN_ANALOG_VOLT_8;
|
|
|
|
|
|
|
|
// "26 - AN volt 2"
|
|
|
|
engineConfiguration->highPressureFuel.hwChannel = MRE_IN_ANALOG_VOLT_2;
|
|
|
|
|
|
|
|
|
2020-10-17 11:53:56 -07:00
|
|
|
// "19 - AN volt 4"
|
2020-10-23 04:31:47 -07:00
|
|
|
engineConfiguration->lowPressureFuel.hwChannel = EFI_ADC_12;
|
2020-10-12 21:35:04 -07:00
|
|
|
|
2021-11-17 00:54:21 -08:00
|
|
|
engineConfiguration->isSdCardEnabled = false;
|
2020-10-12 21:35:04 -07:00
|
|
|
|
2021-11-17 00:54:21 -08:00
|
|
|
engineConfiguration->mc33816spiDevice = SPI_DEVICE_3;
|
2020-10-17 17:17:53 -07:00
|
|
|
// RED
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->spi3mosiPin = Gpio::C12;
|
2020-10-17 17:17:53 -07:00
|
|
|
// YELLOW
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->spi3misoPin = Gpio::C11;
|
2020-10-17 17:17:53 -07:00
|
|
|
// BROWN
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->spi3sckPin = Gpio::C10;
|
|
|
|
engineConfiguration->sdCardCsPin = Gpio::Unassigned;
|
2021-11-17 00:54:21 -08:00
|
|
|
engineConfiguration->is_enabled_spi_3 = true;
|
2020-10-12 21:35:04 -07:00
|
|
|
|
|
|
|
|
2020-10-17 17:17:53 -07:00
|
|
|
// J8 orange
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->mc33816_cs = Gpio::B8;
|
2020-10-17 17:17:53 -07:00
|
|
|
// J8 Grey
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->mc33816_rstb = Gpio::A15;
|
2020-10-17 17:17:53 -07:00
|
|
|
// J8 Dark BLUE
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->mc33816_driven = Gpio::B9;
|
2020-10-17 17:17:53 -07:00
|
|
|
// J9 violet
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->mc33816_flag0 = Gpio::C13;
|
2020-10-12 21:35:04 -07:00
|
|
|
|
2020-10-17 17:17:53 -07:00
|
|
|
// J10 Dark BLUE
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->injectionPins[0] = Gpio::E6;
|
2020-10-17 17:17:53 -07:00
|
|
|
// J11 green
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->injectionPins[1] = Gpio::E5;
|
2020-10-17 17:17:53 -07:00
|
|
|
// J18 grey
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->injectionPins[2] = Gpio::B7;
|
2020-10-17 17:17:53 -07:00
|
|
|
// J6 white
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->injectionPins[3] = Gpio::E0;
|
2020-10-19 20:25:23 -07:00
|
|
|
|
|
|
|
|
2020-10-21 22:48:28 -07:00
|
|
|
gppwm_channel *lowPressureFuelPumpControl = &engineConfiguration->gppwm[1];
|
2022-05-20 23:25:43 -07:00
|
|
|
|
2020-11-15 17:56:16 -08:00
|
|
|
// "42 - Injector 4", somehow GP4 did not work? not enough current? not happy with diode?
|
2022-04-28 14:32:39 -07:00
|
|
|
lowPressureFuelPumpControl->pin = Gpio::TLE8888_PIN_4;
|
2020-10-21 22:48:28 -07:00
|
|
|
|
|
|
|
|
|
|
|
gppwm_channel *coolantControl = &engineConfiguration->gppwm[0];
|
|
|
|
|
2022-04-28 14:32:39 -07:00
|
|
|
coolantControl->pin = Gpio::TLE8888_PIN_5; // "3 - Lowside 2"
|
2020-11-15 12:37:53 -08:00
|
|
|
// "7 - Lowside 1"
|
2022-01-08 22:29:39 -08:00
|
|
|
//engineConfiguration->hpfpValvePin = MRE_LS_1;
|
|
|
|
engineConfiguration->disablePrimaryUart = true;
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->hpfpValvePin = Gpio::B10; // AUX J13
|
2022-01-13 19:46:17 -08:00
|
|
|
|
2020-10-19 20:25:23 -07:00
|
|
|
|
2022-02-01 18:46:06 -08:00
|
|
|
#endif /* HW_MICRO_RUSEFI */
|
2020-08-29 07:06:28 -07:00
|
|
|
}
|