2015-07-10 06:01:56 -07:00
|
|
|
/**
|
|
|
|
* @file bmw_e34.cpp
|
|
|
|
*
|
2017-01-06 07:04:41 -08:00
|
|
|
* set engine_type 25
|
2015-07-10 06:01:56 -07:00
|
|
|
*
|
|
|
|
* Coil pairs: 1-6, 2-5, 3-4
|
|
|
|
*
|
|
|
|
* Injector groups: 1,2,3 & 4,5,6
|
|
|
|
*
|
|
|
|
* @date Nov 5, 2014
|
2020-01-13 18:57:43 -08:00
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2020
|
2015-07-10 06:01:56 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "global.h"
|
|
|
|
#include "bmw_e34.h"
|
|
|
|
#include "thermistors.h"
|
|
|
|
#include "engine_math.h"
|
|
|
|
|
2019-05-03 15:41:43 -07:00
|
|
|
EXTERN_CONFIG
|
2015-07-10 06:01:56 -07:00
|
|
|
;
|
|
|
|
|
2019-05-03 15:41:43 -07:00
|
|
|
void setBmwE34(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
|
2019-11-03 16:36:56 -08:00
|
|
|
setDefaultFrankensoConfiguration(PASS_CONFIG_PARAMETER_SIGNATURE);
|
2015-07-10 06:01:56 -07:00
|
|
|
// chartsize 450
|
|
|
|
engineConfiguration->engineChartSize = 450;
|
|
|
|
|
|
|
|
// setOperationMode(engineConfiguration, FOUR_STROKE_CAM_SENSOR);
|
|
|
|
// engineConfiguration->trigger.type = TT_ONE_PLUS_TOOTHED_WHEEL_60_2;
|
|
|
|
// engineConfiguration->injectionMode = IM_SEQUENTIAL;
|
2019-12-11 14:48:55 -08:00
|
|
|
// engineConfiguration->triggerInputPins[0] = GPIOC_6;
|
|
|
|
// engineConfiguration->triggerInputPins[1] = GPIOA_5;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
//Base engine setting
|
|
|
|
engineConfiguration->specs.cylindersCount = 6;
|
|
|
|
engineConfiguration->specs.displacement = 2.91;
|
2016-07-20 16:04:27 -07:00
|
|
|
engineConfiguration->specs.firingOrder = FO_1_5_3_6_2_4;
|
2015-07-10 06:01:56 -07:00
|
|
|
engineConfiguration->injectionMode = IM_BATCH;
|
2016-01-03 07:01:32 -08:00
|
|
|
engineConfiguration->twoWireBatchInjection = true;
|
2015-07-10 06:01:56 -07:00
|
|
|
engineConfiguration->ignitionMode = IM_WASTED_SPARK;
|
2016-02-27 20:03:34 -08:00
|
|
|
engineConfiguration->useOnlyRisingEdgeForTrigger = true;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->tachOutputPin = GPIOC_8;
|
2015-08-19 19:01:27 -07:00
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
// Trigger configuration
|
|
|
|
// engineConfiguration->trigger.type = TT_TOOTHED_WHEEL_60_2;
|
|
|
|
setOperationMode(engineConfiguration, FOUR_STROKE_CRANK_SENSOR);
|
2017-01-06 07:04:41 -08:00
|
|
|
// set global_trigger_offset_angle 84
|
2015-07-10 06:01:56 -07:00
|
|
|
engineConfiguration->globalTriggerAngleOffset = 84;
|
|
|
|
|
|
|
|
engineConfiguration->trigger.type = TT_TOOTHED_WHEEL;
|
|
|
|
engineConfiguration->trigger.customTotalToothCount = 30;
|
|
|
|
engineConfiguration->trigger.customSkippedToothCount = 1;
|
|
|
|
|
|
|
|
|
|
|
|
// Injection settings
|
2019-01-10 16:25:07 -08:00
|
|
|
setFlatInjectorLag(1.15 PASS_CONFIG_PARAMETER_SUFFIX);
|
2016-07-24 20:02:52 -07:00
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
engineConfiguration->injector.flow = 750;
|
|
|
|
|
|
|
|
// General settings
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->tunerStudioSerialSpeed = 57600;
|
2015-07-10 06:01:56 -07:00
|
|
|
engineConfiguration->rpmHardLimit = 7000;
|
2019-01-10 16:25:07 -08:00
|
|
|
setAlgorithm(LM_SPEED_DENSITY PASS_CONFIG_PARAMETER_SUFFIX);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
// for best performance at high RPM, we need to turn off 'Engine Sniffer' and 'Sensor Sniffer'
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->sensorChartMode = SC_OFF;
|
2015-07-10 06:01:56 -07:00
|
|
|
engineConfiguration->isEngineChartEnabled = false;
|
|
|
|
|
|
|
|
engineConfiguration->isCylinderCleanupEnabled = false;
|
|
|
|
engineConfiguration->isInjectionEnabled = true;
|
|
|
|
engineConfiguration->isIgnitionEnabled = true;
|
|
|
|
|
2019-05-03 15:41:43 -07:00
|
|
|
setConstantDwell(3 PASS_CONFIG_PARAMETER_SUFFIX); // a bit shorter dwell
|
2015-07-10 06:01:56 -07:00
|
|
|
engineConfiguration->ignMathCalculateAtIndex = 14;
|
|
|
|
|
|
|
|
engineConfiguration->mapAveragingSchedulingAtIndex = 6;
|
|
|
|
|
|
|
|
// Cranking
|
|
|
|
engineConfiguration->cranking.rpm = 600;
|
|
|
|
engineConfiguration->crankingInjectionMode = IM_BATCH;
|
2016-10-27 21:02:10 -07:00
|
|
|
// enable constant_dwell
|
2015-07-10 06:01:56 -07:00
|
|
|
engineConfiguration->useConstantDwellDuringCranking = true;
|
|
|
|
engineConfiguration->ignitionDwellForCrankingMs = 6;
|
|
|
|
|
|
|
|
// Inputs configuration
|
|
|
|
engineConfiguration->analogInputDividerCoefficient = 1.52;
|
|
|
|
engineConfiguration->vbattDividerCoeff = 5.33;
|
|
|
|
engineConfiguration->vbattAdcChannel = EFI_ADC_15; // PC5
|
|
|
|
|
2019-06-30 11:28:47 -07:00
|
|
|
engineConfiguration->tps1_1AdcChannel = EFI_ADC_3;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->triggerInputPins[0] = GPIOA_5;
|
|
|
|
engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2019-01-10 18:10:46 -08:00
|
|
|
setWholeTimingTable(25);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->malfunctionIndicatorPin = GPIO_UNASSIGNED;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
// bc->isFastAdcEnabled = true;
|
|
|
|
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->injectionPinMode = OM_INVERTED;
|
|
|
|
engineConfiguration->injectionPins[0] = GPIOB_8; // #1
|
|
|
|
engineConfiguration->injectionPins[1] = GPIOE_2; // #2
|
|
|
|
engineConfiguration->injectionPins[2] = GPIOE_3; // #3
|
|
|
|
engineConfiguration->injectionPins[3] = GPIOE_4; // #4
|
|
|
|
engineConfiguration->injectionPins[4] = GPIOE_5; // #5
|
|
|
|
engineConfiguration->injectionPins[5] = GPIOE_6; // #6
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->ignitionPinMode = OM_INVERTED;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->ignitionPins[0] = GPIOB_5; // #1
|
|
|
|
engineConfiguration->ignitionPins[2] = GPIOB_6; // #3
|
|
|
|
engineConfiguration->ignitionPins[4] = GPIOB_7; // #5
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->canRxPin = GPIO_UNASSIGNED;
|
|
|
|
engineConfiguration->canTxPin = GPIO_UNASSIGNED;
|
2016-12-19 19:01:59 -08:00
|
|
|
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->triggerErrorPin = GPIO_UNASSIGNED;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
// clutch up
|
2019-11-30 07:24:37 -08:00
|
|
|
engineConfiguration->clutchUpPin = GPIOD_3;
|
|
|
|
engineConfiguration->clutchUpPinMode = PI_PULLUP;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
// fuel pump
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->fuelPumpPin = GPIOD_4;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
// idle
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->idle.solenoidPin = GPIOC_14;
|
|
|
|
engineConfiguration->idle.solenoidPinMode = OM_INVERTED;
|
|
|
|
engineConfiguration->idle.solenoidFrequency = 300;
|
|
|
|
engineConfiguration->manIdlePosition = 50; // set_idle_pwm 50
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
// disable sd_card
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->sdCardCsPin = GPIO_UNASSIGNED;
|
|
|
|
engineConfiguration->is_enabled_spi_2 = false;
|
|
|
|
engineConfiguration->is_enabled_spi_3 = false;
|
|
|
|
engineConfiguration->max31855spiDevice = SPI_NONE;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
// turbocharger boost control solenoid: TODO output: GPIOE_6
|
|
|
|
// water injection #1 TODO GPIOD_7
|
|
|
|
// water injection #2 TODO GPIOE_2
|
|
|
|
|
|
|
|
/**
|
|
|
|
* emulating the 60-0 trigger takes some resources, let's keep it slow by default
|
|
|
|
* rpm 200
|
|
|
|
*/
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->triggerSimulatorFrequency = 200;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
// Configurating sensors:
|
|
|
|
|
|
|
|
// map
|
|
|
|
engineConfiguration->map.sensor.type = MT_MPX4250;
|
|
|
|
|
|
|
|
// thermistors
|
2019-10-02 18:00:10 -07:00
|
|
|
engineConfiguration->clt.config = {-10, 20, 80, 9300, 2500, 335, 2200};
|
|
|
|
engineConfiguration->iat.config = {-10, 20, 80, 9300, 2500, 335, 2200};
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
// /**
|
|
|
|
// * This saves a couple of ticks in trigger emulation methods
|
|
|
|
// * TODO: add some smart logic to detect unneeded trigger simulation pins?
|
|
|
|
// * TODO: but probably not worth it
|
|
|
|
// */
|
|
|
|
// bc->triggerSimulatorPins[1] = GPIO_UNASSIGNED;
|
|
|
|
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->triggerSimulatorPins[0] = GPIOD_1;
|
|
|
|
engineConfiguration->triggerSimulatorPins[1] = GPIOD_2;
|
|
|
|
engineConfiguration->triggerSimulatorPins[2] = GPIO_UNASSIGNED;
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|