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"
|
2019-12-26 18:33:12 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* set engine_type 62
|
2020-08-29 07:06:28 -07:00
|
|
|
* VW_B6
|
2020-10-12 21:35:04 -07:00
|
|
|
* has to be microRusEFI 0.5.2
|
2019-12-26 18:33:12 -08:00
|
|
|
*/
|
2021-11-16 01:15:29 -08:00
|
|
|
void setVwPassatB6() {
|
2020-10-21 22:48:28 -07:00
|
|
|
#if (BOARD_TLE8888_COUNT > 0)
|
2020-08-29 07:06:28 -07:00
|
|
|
setOperationMode(engineConfiguration, FOUR_STROKE_CRANK_SENSOR);
|
|
|
|
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
|
|
|
|
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);
|
|
|
|
|
2020-08-29 16:01:44 -07:00
|
|
|
strcpy(CONFIG(engineMake), ENGINE_MAKE_VAG);
|
|
|
|
strcpy(CONFIG(engineCode), "BPY");
|
|
|
|
|
|
|
|
|
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-17 11:53:56 -07:00
|
|
|
// EFI_ADC_7: "31 - AN volt 3" - PA7
|
|
|
|
engineConfiguration->throttlePedalPositionAdcChannel = EFI_ADC_7;
|
2020-10-12 21:35:04 -07:00
|
|
|
|
2020-10-17 11:53:56 -07:00
|
|
|
// "26 - AN volt 2"
|
2020-10-23 04:31:47 -07:00
|
|
|
engineConfiguration->highPressureFuel.hwChannel = EFI_ADC_6;
|
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
|
|
|
|
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-27 22:01:54 -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);
|
2020-10-12 21:35:04 -07:00
|
|
|
|
|
|
|
CONFIG(isSdCardEnabled) = false;
|
|
|
|
|
|
|
|
CONFIG(mc33816spiDevice) = SPI_DEVICE_3;
|
2021-11-16 01:15:29 -08:00
|
|
|
setBoschHDEV_5_injectors();
|
2020-10-17 17:17:53 -07:00
|
|
|
// RED
|
2020-10-12 21:35:04 -07:00
|
|
|
engineConfiguration->spi3mosiPin = GPIOC_12;
|
2020-10-17 17:17:53 -07:00
|
|
|
// YELLOW
|
2020-10-12 21:35:04 -07:00
|
|
|
engineConfiguration->spi3misoPin = GPIOC_11;
|
2020-10-17 17:17:53 -07:00
|
|
|
// BROWN
|
2020-10-12 21:35:04 -07:00
|
|
|
engineConfiguration->spi3sckPin = GPIOC_10;
|
|
|
|
engineConfiguration->sdCardCsPin = GPIO_UNASSIGNED;
|
|
|
|
CONFIG(is_enabled_spi_3) = true;
|
|
|
|
|
|
|
|
|
2020-10-17 17:17:53 -07:00
|
|
|
// J8 orange
|
|
|
|
CONFIG(mc33816_cs) = GPIOB_8;
|
|
|
|
// J8 Grey
|
|
|
|
CONFIG(mc33816_rstb) = GPIOA_15;
|
|
|
|
// J8 Dark BLUE
|
|
|
|
CONFIG(mc33816_driven) = GPIOB_9;
|
|
|
|
// J9 violet
|
|
|
|
CONFIG(mc33816_flag0) = GPIOC_13;
|
2020-10-12 21:35:04 -07:00
|
|
|
|
2020-10-17 17:17:53 -07:00
|
|
|
// J10 Dark BLUE
|
2020-10-12 21:35:04 -07:00
|
|
|
engineConfiguration->injectionPins[0] = GPIOE_6;
|
2020-10-17 17:17:53 -07:00
|
|
|
// J11 green
|
2020-10-12 21:35:04 -07:00
|
|
|
engineConfiguration->injectionPins[1] = GPIOE_5;
|
2020-10-17 17:17:53 -07:00
|
|
|
// J18 grey
|
|
|
|
engineConfiguration->injectionPins[2] = GPIOB_7;
|
|
|
|
// J6 white
|
|
|
|
engineConfiguration->injectionPins[3] = GPIOE_0;
|
2020-10-19 20:25:23 -07:00
|
|
|
|
|
|
|
|
2020-10-21 22:48:28 -07:00
|
|
|
gppwm_channel *lowPressureFuelPumpControl = &engineConfiguration->gppwm[1];
|
|
|
|
lowPressureFuelPumpControl->pwmFrequency = 20;
|
|
|
|
lowPressureFuelPumpControl->loadAxis = GPPWM_FuelLoad;
|
|
|
|
lowPressureFuelPumpControl->dutyIfError = 50;
|
|
|
|
setTable(lowPressureFuelPumpControl->table, (uint8_t)50);
|
2020-11-15 17:56:16 -08:00
|
|
|
// "42 - Injector 4", somehow GP4 did not work? not enough current? not happy with diode?
|
|
|
|
lowPressureFuelPumpControl->pin = TLE8888_PIN_4;
|
2020-10-21 22:48:28 -07:00
|
|
|
|
|
|
|
|
|
|
|
gppwm_channel *coolantControl = &engineConfiguration->gppwm[0];
|
|
|
|
|
|
|
|
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
|
|
|
|
int value = 100 - 10;
|
|
|
|
coolantControl->dutyIfError = value;
|
|
|
|
setTable(coolantControl->table, (uint8_t)value);
|
2020-10-19 20:25:23 -07:00
|
|
|
// for now I just want to stop radiator whine
|
|
|
|
// todo: enable cooling!
|
2021-01-23 17:08:57 -08:00
|
|
|
/*
|
2020-10-21 22:48:28 -07:00
|
|
|
for (int load = 0; load < GPPWM_LOAD_COUNT; load++) {
|
2020-10-19 20:25:23 -07:00
|
|
|
for (int r = 0; r < GPPWM_RPM_COUNT; r++) {
|
2020-10-21 22:48:28 -07:00
|
|
|
engineConfiguration->gppwm[0].table[load][r] = value;
|
2020-10-19 20:25:23 -07:00
|
|
|
}
|
|
|
|
}
|
2020-10-21 22:48:28 -07:00
|
|
|
*/
|
2020-10-23 09:25:30 -07:00
|
|
|
coolantControl->pin = TLE8888_PIN_5; // "3 - Lowside 2"
|
2020-11-15 12:37:53 -08:00
|
|
|
// "7 - Lowside 1"
|
2021-11-05 20:15:35 -07:00
|
|
|
// engineConfiguration->hpfpValvePin = TLE8888_PIN_6; // Disable for now
|
2020-11-15 12:37:53 -08:00
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
setBoschVAGETB();
|
2020-11-15 12:37:53 -08:00
|
|
|
|
2020-10-19 20:25:23 -07:00
|
|
|
|
2020-10-28 15:53:30 -07:00
|
|
|
engineConfiguration->injector.flow = 300;
|
|
|
|
|
2020-10-19 20:25:23 -07:00
|
|
|
engineConfiguration->idle.solenoidPin = GPIO_UNASSIGNED;
|
|
|
|
engineConfiguration->fanPin = GPIO_UNASSIGNED;
|
2020-10-21 21:57:11 -07:00
|
|
|
|
|
|
|
CONFIG(useETBforIdleControl) = true;
|
|
|
|
engineConfiguration->crankingInjectionMode = IM_SEQUENTIAL;
|
2020-10-21 22:48:28 -07:00
|
|
|
#endif /* BOARD_TLE8888_COUNT */
|
2020-08-29 07:06:28 -07:00
|
|
|
}
|