rusefi-1/firmware/config/engines/bmw_m73.cpp

286 lines
8.6 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)
2021-01-06 09:48:32 -08:00
* ECU pin 36: IN Knock Sensor #2
* ECU pin 37: GND Knock Sensor GND
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)
2021-01-06 09:48:32 -08:00
* ECU pin 49: IN Knock Sensor #1
* ECU pin 50: GND Knock Sensor GND
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
*/
2021-11-22 14:52:03 -08:00
#include "pch.h"
2020-03-11 17:48:09 -07:00
#include "bmw_m73.h"
2019-11-01 19:56:58 -07:00
#include "custom_engine.h"
2021-01-06 16:42:07 -08:00
#include "hip9011_logic.h"
2020-12-25 21:57:23 -08:00
#if EFI_ELECTRONIC_THROTTLE_BODY
#include "electronic_throttle.h"
2021-01-06 16:42:07 -08:00
#endif // EFI_ELECTRONIC_THROTTLE_BODY
2019-11-01 19:56:58 -07:00
#if HW_PROTEUS
#include "proteus_meta.h"
#endif
void m73engine() {
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;
strcpy(engineConfiguration->engineMake, ENGINE_MAKE_BMW);
strcpy(engineConfiguration->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;
engineConfiguration->fuelAlgorithm = LM_ALPHA_N;
2021-12-19 12:57:19 -08:00
engineConfiguration->canNbcType = CAN_BUS_NBC_NONE;
2019-11-03 18:27:37 -08:00
2021-02-08 18:50:31 -08:00
engineConfiguration->vvtMode[0] = VVT_FIRST_HALF;
2019-11-14 20:58:04 -08:00
2019-11-17 19:32:27 -08:00
engineConfiguration->globalTriggerAngleOffset = 90;
setCrankOperationMode();
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?
2021-12-19 12:57:19 -08:00
engineConfiguration->cranking.rpm = 350;
2019-12-01 20:45:45 -08:00
2019-11-18 20:45:35 -08:00
engineConfiguration->ignitionMode = IM_TWO_COILS;
2019-12-01 19:37:26 -08:00
2021-12-19 12:57:19 -08:00
// set cranking_fuel x
2021-12-22 13:54:17 -08:00
engineConfiguration->cranking.baseFuel = 27;
2021-12-19 12:57:19 -08:00
engineConfiguration->crankingTimingAngle = 15;
setTable(config->veTable, 45);
2021-01-06 16:42:07 -08:00
engineConfiguration->cylinderBore = 85.0;
2019-11-18 20:45:35 -08:00
}
// BMW_M73_F
void setBMW_M73_TwoCoilUnitTest() {
2021-11-06 18:19:56 -07:00
// twoCoil configuration without unit tests ETB setup drama
m73engine();
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
void setEngineBMW_M73_Manhattan() {
m73engine();
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
*/
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
2021-06-05 13:19:01 -07:00
engineConfiguration->etbIo[0].controlPin = 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;
engineConfiguration->etb_use_two_wires = true;
2019-11-20 21:19:35 -08:00
2019-11-28 22:35:45 -08:00
// PWM pin
2021-06-05 13:19:01 -07:00
engineConfiguration->etbIo[1].controlPin = 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;
engineConfiguration->tps2Min = engineConfiguration->tpsMin;
engineConfiguration->tps2Max = engineConfiguration->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
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
*/
#if HW_PROTEUS
void setEngineBMW_M73_Proteus() {
m73engine();
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
engineConfiguration->throttlePedalPositionAdcChannel = PROTEUS_IN_ANALOG_VOLT_9;
2020-02-19 19:34:51 -08:00
strcpy(engineConfiguration->vehicleName, "Using Proteus");
2020-05-08 14:31:03 -07:00
2020-12-20 08:17:38 -08:00
// set_trigger_input_pin 0 PE7
2022-04-25 14:42:30 -07:00
engineConfiguration->triggerInputPins[0] = PROTEUS_VR_1;
2020-08-19 19:03:27 -07:00
// GPIOE_11: "Digital 2"
2022-04-25 14:42:30 -07:00
engineConfiguration->camInputs[0] = PROTEUS_DIGITAL_2;
2020-08-19 19:03:27 -07:00
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
2020-11-06 11:18:54 -08:00
// engineConfiguration->vbattDividerCoeff = 7.6; // is that Proteus 0.2 value?
2020-02-27 00:29:03 -08:00
2020-11-27 13:41:11 -08:00
// no idea why https://github.com/rusefi/rusefi/wiki/HOWTO-M73-v12-on-Proteus uses non default CLT pin
engineConfiguration->clt.adcChannel = PROTEUS_IN_ANALOG_TEMP_4;
2020-11-27 13:41:11 -08:00
2020-02-23 06:16:11 -08:00
2020-08-18 21:35:09 -07:00
// GPIOE_0: "Lowside 14"
engineConfiguration->starterControlPin = GPIOE_0;
2020-08-18 21:35:09 -07:00
// GPIOE_12: "Digital 3"
engineConfiguration->startStopButtonPin = GPIOE_12;
engineConfiguration->startStopButtonMode = PI_PULLUP;
2020-08-18 21:35:09 -07:00
setProteusHitachiEtbDefaults();
2020-08-21 11:09:51 -07:00
engineConfiguration->useETBforIdleControl = true;
2020-02-01 14:55:58 -08:00
}
#endif // HW_PROTEUS