fome-fw/firmware/config/engines/bmw_m73.cpp

336 lines
11 KiB
C++
Raw Normal View History

2019-11-01 19:56:58 -07:00
/*
* @file bmw_m73.cpp
*
* https://github.com/rusefi/rusefi/wiki/BMW_e38_750
2019-11-01 19:56:58 -07:00
*
* https://rusefi.com/wiki/index.php?title=Hardware:OEM_connectors#134_pin
* https://github.com/rusefi/rusefi/wiki/HOWTO_electronic_throttle_body
2020-03-17 21:12:31 -07:00
* Ignition module https://rusefi.com/forum/viewtopic.php?f=4&t=286
2019-11-01 19:56:58 -07:00
*
2020-03-18 14:46:46 -07:00
*
2019-11-07 17:47:12 -08:00
* 1/2 plugs black
* 2/2 plugs grey
*
2019-11-01 19:56:58 -07:00
*
2019-11-09 15:40:06 -08:00
* ********* | | OEM | rusEfi | function
*
2019-11-08 17:53:51 -08:00
* Plug #1 9 pin
* ECU pin 4: GND BRN/ORG
* ECU pin 6: GND BRN
2019-11-09 15:40:06 -08:00
* ECU pin 7: IN RED +12v hot at all times
* ECU pin 8: IN RED/BLU +12v from ECU relay
2019-11-08 17:53:51 -08:00
*
* Plug #2 24 pin
2019-11-09 15:40:06 -08:00
* ECU pin 3: CAN xxx/xxx CAN low
* ECU pin 4: CAN xxx/xxx CAN high
* ECU pin 23: OUT BRN/BLK BLK ECU relay control, low-side
2019-11-01 19:56:58 -07:00
*
2019-11-08 17:53:51 -08:00
* Plug #3 52 pin
2019-11-30 17:24:31 -08:00
* ECU pin 2: OUT WHT injector #4
2019-11-09 15:40:06 -08:00
* ECU pin 6: GND ECU
2019-11-30 17:24:31 -08:00
* ECU pin 15: OUT BLK injector #2
2019-11-09 15:40:06 -08:00
* ECU pin 20: IN WHT hall effect camshaft sensor signal
2020-04-03 14:44:55 -07:00
* ECU pin 21: GND BRN BLK CLT sensor (only on first ECU)
* ECU pin 22: IN RED/BRN GRN CLT sensor (only on first ECU)
2019-11-30 17:24:31 -08:00
* ECU pin 27: OUT ORG injector #6
* ECU pin 28: OUT RED injector #5
2019-11-15 20:49:28 -08:00
* ECU pin 32: IN ORG VR positive crankshaft sensor - only 2x 5k per channel, R111 not installed, W1002 not installed
2020-08-21 11:59:24 -07:00
* ECU pin 34: IN IAT sensor (only on second ECU)
2019-11-30 17:24:31 -08:00
* ECU pin 40: OUT BRN/BLK GRN injector #3
* ECU pin 41: OUT BRN/WHT BLU injector #1
2019-11-09 15:40:06 -08:00
* ECU pin 45: GND crankshaft shield
2019-11-15 20:49:28 -08:00
* ECU pin 46: IN BLK BLU VR negative crankshaft sensor
2020-08-21 11:59:24 -07:00
* ECU pin 47: GND BRN BLK IAT sensor Ground (only on second ECU)
2019-11-01 19:56:58 -07:00
*
2019-11-08 17:53:51 -08:00
* Plug #4 40 pin
2019-11-09 15:40:06 -08:00
* ECU pin 6: IN start signal from ignition key
* ECU pin 17: OUT BLK engine speed output for gauge cluster
2020-03-19 21:36:22 -07:00
* ECU pin 26: IN GRN/BLK RED +12v hot in start & run
2019-11-09 15:40:06 -08:00
* ECU pin 40: OUT YEL/BRN BRN starter enable
2019-11-01 19:56:58 -07:00
*
*
2019-11-17 19:32:27 -08:00
* Plug #5 9 pin
2020-03-19 21:36:22 -07:00
* ECU pin 3: OUT BLK coil signal, low-side
* ECU pin 5: GND BRN ground
* ECU pin 6: OUT BLK coil signal, low-side
* ECU pin 9: OUT BLK RED coil signal, low-side
2019-11-17 19:32:27 -08:00
*
2019-11-18 21:04:44 -08:00
* Frankenso
2019-11-14 20:58:04 -08:00
* set engine_type 40
2019-11-18 21:04:44 -08:00
* Manhattan
* set engine_type 24
2020-02-01 14:55:58 -08:00
* Proteus
* set engine_type 63
2019-11-14 20:58:04 -08:00
*
2019-11-22 20:27:03 -08:00
* https://raw.githubusercontent.com/wiki/rusefi/rusefi_documentation/oem_docs/VAG/Bosch_0280750009_pinout.jpg
*
2019-11-01 19:56:58 -07:00
* @date Nov 1, 2019
2020-01-07 21:02:40 -08:00
* @author Andrey Belomutskiy, (c) 2012-2020
2019-11-01 19:56:58 -07:00
*/
2020-03-11 17:48:09 -07:00
#include "bmw_m73.h"
2019-11-01 19:56:58 -07:00
#include "custom_engine.h"
EXTERN_CONFIG;
2020-08-21 11:09:51 -07:00
static const float hardCodedetbHitachiBiasBins[8] = {0.0, 19.0, 21.0, 22.0, 23.0, 25.0, 30.0, 100.0};
static const float hardCodedetbHitachiBiasValues[8] = {-18.0, -17.0, -15.0, 0.0, 16.0, 20.0, 20.0, 20.0};
/* Generated by TS2C on Thu Aug 20 21:10:02 EDT 2020*/
static void setHitachiEtbBiasBins(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
MEMCPY(engineConfiguration->etbBiasBins, hardCodedetbHitachiBiasBins);
MEMCPY(engineConfiguration->etbBiasValues, hardCodedetbHitachiBiasValues);
}
2020-03-11 17:48:09 -07:00
void m73engine(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
2019-11-18 20:45:35 -08:00
// 13641435991 injector
engineConfiguration->injector.flow = 180; // cc/min, who knows if this number is real - no good source of info
2019-11-03 18:27:37 -08:00
engineConfiguration->specs.cylindersCount = 12;
engineConfiguration->specs.displacement = 5.4;
2020-05-08 14:31:03 -07:00
strcpy(CONFIG(engineMake), ENGINE_MAKE_BMW);
strcpy(CONFIG(engineCode), "M73");
2019-11-03 18:27:37 -08:00
engineConfiguration->specs.firingOrder = FO_1_7_5_11_3_9_6_12_2_8_4_10;
2020-04-02 18:49:31 -07:00
CONFIG(isFasterEngineSpinUpEnabled) = true;
2019-11-03 18:27:37 -08:00
2019-11-14 20:58:04 -08:00
engineConfiguration->vvtMode = VVT_FIRST_HALF;
2019-11-17 19:32:27 -08:00
engineConfiguration->globalTriggerAngleOffset = 90;
2019-11-14 20:58:04 -08:00
setOperationMode(engineConfiguration, FOUR_STROKE_CRANK_SENSOR);
2019-12-01 20:45:45 -08:00
// todo: that's not right, should be 60/2 without VW
2019-11-14 20:58:04 -08:00
engineConfiguration->trigger.type = TT_60_2_VW;
2019-12-01 20:45:45 -08:00
// this large engine seems to crank at around only 150 RPM? And happily idle at 400RPM?
engineConfiguration->cranking.rpm = 280;
2019-11-18 20:45:35 -08:00
engineConfiguration->ignitionMode = IM_TWO_COILS;
2019-12-01 19:37:26 -08:00
// set cranking_fuel 15
engineConfiguration->cranking.baseFuel = 15;
2019-11-18 20:45:35 -08:00
}
// BMW_M73_F
void setEngineBMW_M73_Frankenso(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
setFrankensoConfiguration(PASS_CONFIG_PARAMETER_SIGNATURE);
m73engine(PASS_CONFIG_PARAMETER_SIGNATURE);
engineConfiguration->triggerInputPins[0] = GPIOA_5;
engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED;
2019-11-18 20:45:35 -08:00
engineConfiguration->camInputs[0] = GPIOC_6;
CONFIG(idle).solenoidPin = GPIO_UNASSIGNED;
CONFIG(mainRelayPin) = GPIO_UNASSIGNED;
CONFIG(fanPin) = GPIO_UNASSIGNED;
CONFIG(fuelPumpPin) = GPIO_UNASSIGNED;
2019-11-16 13:00:50 -08:00
engineConfiguration->ignitionPins[ID2INDEX(1)] = GPIOE_14; // Frankenso high side - pin 1G - GREEN wire
engineConfiguration->ignitionPins[ID2INDEX(2)] = GPIO_UNASSIGNED;
engineConfiguration->ignitionPins[ID2INDEX(3)] = GPIO_UNASSIGNED;
engineConfiguration->ignitionPins[ID2INDEX(4)] = GPIO_UNASSIGNED;
engineConfiguration->ignitionPins[ID2INDEX(7)] = GPIOC_7; // Frankenso high side - pin 1H - ORANGE wire
2019-11-16 13:00:50 -08:00
engineConfiguration->injectionPins[0] = GPIOB_8; // BLU
engineConfiguration->injectionPins[1] = GPIOB_7; // BLK
engineConfiguration->injectionPins[2] = GPIOB_9; // GRN
engineConfiguration->injectionPins[3] = GPIOD_5; // WHT
engineConfiguration->injectionPins[4] = GPIOD_3; // RED
engineConfiguration->injectionPins[5] = GPIOE_2; // ORG
2019-11-16 13:00:50 -08:00
engineConfiguration->injectionPins[6] = GPIOE_3; // BLU
engineConfiguration->injectionPins[7] = GPIOE_4; // BLK
engineConfiguration->injectionPins[8] = GPIOE_5; // GRN
engineConfiguration->injectionPins[9] = GPIOE_6; // WHT
engineConfiguration->injectionPins[10] = GPIOC_13;//RED
engineConfiguration->injectionPins[11] = GPIOD_7;// ORG
2019-11-18 20:45:35 -08:00
}
2019-11-16 13:00:50 -08:00
2019-11-18 21:04:44 -08:00
// BMW_M73_M
2020-02-27 00:29:03 -08:00
// set engine_type 24
2019-11-18 20:45:35 -08:00
void setEngineBMW_M73_Manhattan(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
m73engine(PASS_CONFIG_PARAMETER_SIGNATURE);
2019-11-14 20:58:04 -08:00
2019-11-20 21:19:35 -08:00
/**
Nucleo boards - first step is to confirm that I can blink via each pin
going clockwise from top-right corner
GPIOA_10 USD ID
GPIOA_11 USD DM
GPIOA_12 USD DP
E_4: running
Good GPIO:
GPIOC_9 ETB#1
GPIOC_8 ETB#1
2019-11-28 22:35:45 -08:00
GPIOB_8 ETB#2
GPIOB_9 ETB#2
2019-11-20 21:19:35 -08:00
GPIOC_5
GPIOA_7
GPIOA_6
*/
CONFIG(fsioOutputPins)[7] = GPIO_UNASSIGNED;
engineConfiguration->fuelPumpPin = GPIO_UNASSIGNED;
engineConfiguration->idle.solenoidPin = GPIO_UNASSIGNED;
engineConfiguration->fanPin = GPIO_UNASSIGNED;
2019-11-20 21:19:35 -08:00
2019-11-27 21:40:25 -08:00
/**
* Yellow op-amp board
*
2019-11-29 13:51:51 -08:00
* AN5 tested pull-down 1M PA3 TPS1 orange wire
2019-11-28 22:35:45 -08:00
* AN6 tested pull-down 1M PA4 TPS2
2019-11-29 11:51:20 -08:00
* AN7 tested pull-down 1M PA6 PPS
2019-11-27 21:40:25 -08:00
* AN8 tested no pull-down / no pull-up
*/
2019-11-20 21:19:35 -08:00
// For example TLE7209 - two control wires:
// PWM on both wires - one to open, another to close
2019-11-27 21:40:25 -08:00
// ETB motor NEG pin # - white wire - OUT 1
2020-02-27 00:29:03 -08:00
// green input wire
2019-11-29 11:51:20 -08:00
engineConfiguration->throttlePedalPositionAdcChannel = EFI_ADC_6;
2019-11-28 22:35:45 -08:00
// set_analog_input_pin tps PA3
engineConfiguration->tps1_1AdcChannel = EFI_ADC_3; // PA3
2019-11-29 11:51:20 -08:00
// set_analog_input_pin tps2 PA4
2019-11-28 22:35:45 -08:00
engineConfiguration->tps2_1AdcChannel = EFI_ADC_4; // PA4
2019-11-20 21:19:35 -08:00
// PWM pin
engineConfiguration->etbIo[0].controlPin1 = GPIO_UNASSIGNED;
2019-11-20 21:19:35 -08:00
// DIR pin
2020-03-11 17:48:09 -07:00
engineConfiguration->etbIo[0].directionPin1 = GPIOC_8;
engineConfiguration->etbIo[0].directionPin2 = GPIOC_9;
2019-11-29 13:51:51 -08:00
CONFIG(etb_use_two_wires) = true;
2019-11-20 21:19:35 -08:00
2019-11-28 22:35:45 -08:00
// PWM pin
engineConfiguration->etbIo[1].controlPin1 = GPIO_UNASSIGNED;
2019-11-28 22:35:45 -08:00
// DIR pin
2020-03-11 17:48:09 -07:00
engineConfiguration->etbIo[1].directionPin1 = GPIOB_9;
engineConfiguration->etbIo[1].directionPin2 = GPIOB_8;
CONFIG(tps2Min) = CONFIG(tpsMin);
CONFIG(tps2Max) = CONFIG(tpsMax);
2019-11-20 21:49:38 -08:00
2019-11-20 21:19:35 -08:00
engineConfiguration->injectionPins[0] = GPIO_UNASSIGNED;
engineConfiguration->injectionPins[1] = GPIO_UNASSIGNED;
engineConfiguration->injectionPins[2] = GPIO_UNASSIGNED;
engineConfiguration->injectionPins[3] = GPIO_UNASSIGNED;
engineConfiguration->injectionPins[4] = GPIO_UNASSIGNED;
engineConfiguration->injectionPins[5] = GPIO_UNASSIGNED;
2019-11-20 21:19:35 -08:00
engineConfiguration->injectionPins[6] = GPIO_UNASSIGNED;
engineConfiguration->injectionPins[7] = GPIO_UNASSIGNED;
engineConfiguration->injectionPins[8] = GPIO_UNASSIGNED;
engineConfiguration->injectionPins[9] = GPIO_UNASSIGNED;
engineConfiguration->injectionPins[10] = GPIO_UNASSIGNED;
engineConfiguration->injectionPins[11] = GPIO_UNASSIGNED;
2019-11-20 21:19:35 -08:00
2019-11-01 19:56:58 -07:00
}
2019-11-18 20:45:35 -08:00
2020-02-19 19:34:51 -08:00
/**
* set engine_type 63
2020-02-23 06:16:11 -08:00
*
2020-03-06 21:45:45 -08:00
* https://github.com/mck1117/proteus/blob/master/readme_pinout.md
*
2020-02-23 06:16:11 -08:00
* black#3 : orange : injector #1
* black#4 : blue : injector #3
* black#5 : white : injector #5
* black#6 : green : injector #6
* black#7 : orange : injector #7
* black#8 : blue : injector #9
* black#9 : white : injector #11
* black#15: blue : injector #2
* black#16: white : injector #4
* black#19: green : injector #8
* black#20: : injector #10
* black#21: : injector #12
*
*
* small#5 : : VR1 pos
2020-02-23 21:20:36 -08:00
* small#8 : blue : ETB1-
2020-02-23 06:16:11 -08:00
* small#13: blue : VR1 neg
* small#15: orange : ETB1+
* small#18: red : ignition power / ECU power source
* small#19: black : GND
* small#21: blue : ETB2-
* small#22: orange : ETB2+
* small#23: red : ETB/high-side power from main relay
*
*
*
* white#9 : orange : +5v
2020-03-06 21:45:45 -08:00
* white#17: green : PPS
2020-03-29 22:13:02 -07:00
* white#18: red : TPS#2
2020-02-23 06:16:11 -08:00
* white#23: black : Sensor Ground
* white#24: red : TPS#1
*
2020-02-19 19:34:51 -08:00
*/
2020-02-01 14:55:58 -08:00
void setEngineBMW_M73_Proteus(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
m73engine(PASS_CONFIG_PARAMETER_SIGNATURE);
2020-02-19 19:34:51 -08:00
// 12 injectors defined in boards/proteus/board_configuration.cpp
2020-03-29 22:13:02 -07:00
// set_analog_input_pin pps pa4
2020-03-06 21:45:45 -08:00
engineConfiguration->throttlePedalPositionAdcChannel = EFI_ADC_4;
2020-02-19 19:34:51 -08:00
2020-05-08 14:31:03 -07:00
strcpy(CONFIG(vehicleName), "Using Proteus");
2020-08-19 19:03:27 -07:00
// GPIOE_7: "VR 1"
engineConfiguration->triggerInputPins[0] = GPIOE_7;
// GPIOE_11: "Digital 2"
engineConfiguration->camInputs[0] = GPIOE_11;
2020-02-27 00:29:03 -08:00
// set vbatt_divider 8.16
// engineConfiguration->vbattDividerCoeff = (49.0f / 10.0f) * 16.8f / 10.0f;
// todo: figure out exact values from TLE8888 breakout board used by Manhattan
engineConfiguration->vbattDividerCoeff = 7.6;
2020-02-23 06:16:11 -08:00
2020-08-18 21:35:09 -07:00
// GPIOE_0: "Lowside 14"
CONFIG(starterControlPin) = GPIOE_0;
// GPIOE_12: "Digital 3"
CONFIG(startStopButtonPin) = GPIOE_12;
// EFI_ADC_12: "Analog Volt 3"
engineConfiguration->tps1_2AdcChannel = EFI_ADC_12;
// EFI_ADC_13: "Analog Volt 4"
engineConfiguration->tps2_1AdcChannel = EFI_ADC_13;
// EFI_ADC_0: "Analog Volt 5"
engineConfiguration->tps2_2AdcChannel = EFI_ADC_0;
// EFI_ADC_1: "Analog Volt 6"
engineConfiguration->throttlePedalPositionAdcChannel = EFI_ADC_1;
2020-08-18 22:09:39 -07:00
// EFI_ADC_2: "Analog Volt 7"
engineConfiguration->throttlePedalPositionSecondAdcChannel = EFI_ADC_2;
2020-02-23 06:16:11 -08:00
2020-08-21 11:09:51 -07:00
setHitachiEtbBiasBins(PASS_CONFIG_PARAMETER_SIGNATURE);
engineConfiguration->etb.pFactor = 2.7999;
engineConfiguration->etb.iFactor = 25.5;
engineConfiguration->etb.dFactor = 0.053;
engineConfiguration->etb.offset = 0.0;
engineConfiguration->etb.periodMs = 5.0;
engineConfiguration->etb.minValue = -100.0;
engineConfiguration->etb.maxValue = 100.0;
2020-08-23 12:09:23 -07:00
CONFIG(useETBforIdleControl) = true;
// Nissan 60mm throttle
CONFIG(tpsMin) = CONFIG(tps2Min) = 113;
CONFIG(tpsMax) = CONFIG(tps2Max) = 846;
CONFIG(tps1SecondaryMin) = CONFIG(tps2SecondaryMin) = 897;
CONFIG(tps1SecondaryMax) = CONFIG(tps2SecondaryMax) = 161;
2020-02-01 14:55:58 -08:00
}