diff --git a/firmware/config/engines/mazda_miata_vvt.cpp b/firmware/config/engines/mazda_miata_vvt.cpp index 33d77f33fc..ea9acf9d2b 100644 --- a/firmware/config/engines/mazda_miata_vvt.cpp +++ b/firmware/config/engines/mazda_miata_vvt.cpp @@ -4,6 +4,17 @@ * MAZDA_MIATA_2003 * set engine_type 47 * + * coil1/4 (p1 +5 VP) GPIOE_14 + * coil2/2 (p1 +5 VP) GPIOC_9 + * tachometer +5 VP (p3 +12 VP) GPIOE_8 + * alternator +5 VP (p3 +12 VP) GPIOE_10 + * ETB PWM GPIOE_6 inverted low-side with pull-up + * ETB dir1 GPIOE_12 + * ETB dir2 GPIOC_7 + * + * COP ion #1 GPIOD_8 + * COP ion #3 GPIOD_9 + * * @date Oct 4, 2016 * @author Andrey Belomutskiy, (c) 2012-2019 * http://rusefi.com/forum/viewtopic.php?f=3&t=1095 @@ -20,14 +31,15 @@ * Cam vvt input PC6 (3G in Miata board) blue * Wideband input PA3 (3J in Miata board) * - * coil1/4 (p1 +5 VP) PE14 - * coil2/2 (p1 +5 VP) PC7 + * coil1/4 (p1 +5 VP) GPIOE_14 + * coil2/2 (p1 +5 VP) GPIOC_7 * - * tachometer +5 VP (p3 +12 VP) PE8 - * alternator +5 VP (p3 +12 VP) PE10 + * tachometer +5 VP (p3 +12 VP) GPIOE_8 + * alternator +5 VP (p3 +12 VP) GPIOE_10 + * + * VVT solenoid on aux PID#1 GPIOE_3 + * warning light GPIOE_6 * - * VVT solenoid on aux PID#1 PE3 - * warning light PE6 * * idle solenoid PC13 on middle harness plug. diodes seem to be in the harness */ @@ -331,7 +343,7 @@ void setMazdaMiata2003EngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { - boardConfiguration->malfunctionIndicatorPin = GPIOE_6; // just for a test + boardConfiguration->malfunctionIndicatorPin = GPIOE_0; // boardConfiguration->malfunctionIndicatorPin = GPIOD_9; @@ -376,6 +388,37 @@ void setMazdaMiata2003EngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // set idle_rpm 1700 // see setDefaultIdleParameters + // VNH2SP30 three-wire ETB control + // PWM + boardConfiguration->etb1.controlPin1 = GPIOE_6; + boardConfiguration->etb1.controlPinMode = OM_INVERTED; + // + boardConfiguration->etb1.directionPin1 = GPIOE_12; + // + boardConfiguration->etb1.directionPin2 = GPIOC_7; + + // set_analog_input_pin tps PC3 + engineConfiguration->tps1_1AdcChannel = EFI_ADC_13; // PC3 + + engineConfiguration->idleMode = IM_AUTO; + CONFIGB(useETBforIdleControl) = true; + // set_analog_input_pin pps PA2 + engineConfiguration->throttlePedalPositionAdcChannel = EFI_ADC_2; + + engineConfiguration->idleRpmPid.offset = 0; + engineConfiguration->idleRpmPid.pFactor = 0.2; + engineConfiguration->idleRpmPid.iFactor = 0.0001; + engineConfiguration->idleRpmPid.dFactor = 5; + engineConfiguration->idleRpmPid.periodMs = 10; + + engineConfiguration->bc.isFasterEngineSpinUpEnabled = true; + + //set etb_p 12 + engineConfiguration->etb.pFactor = 12; // a bit lower p-factor seems to work better on TLE9201? MRE? + engineConfiguration->etb.iFactor = 0; + engineConfiguration->etb.dFactor = 0; + engineConfiguration->etb.offset = 0; + } /** diff --git a/firmware/controllers/actuators/electronic_throttle.cpp b/firmware/controllers/actuators/electronic_throttle.cpp index d472272a8c..9b243fd19c 100644 --- a/firmware/controllers/actuators/electronic_throttle.cpp +++ b/firmware/controllers/actuators/electronic_throttle.cpp @@ -123,12 +123,13 @@ public: void start(bool useTwoWires, brain_pin_e pinEnable, - pin_output_mode_e pinEnableMode, + // since we have pointer magic here we cannot simply have value parameter + pin_output_mode_e *pinEnableMode, brain_pin_e pinDir1, brain_pin_e pinDir2) { dcMotor.SetType(useTwoWires ? TwoPinDcMotor::ControlType::PwmDirectionPins : TwoPinDcMotor::ControlType::PwmEnablePin); - m_pinEnable.initPin("ETB Enable", pinEnable, &pinEnableMode); + m_pinEnable.initPin("ETB Enable", pinEnable, pinEnableMode); m_pinDir1.initPin("ETB Dir 1", pinDir1); m_pinDir2.initPin("ETB Dir 2", pinDir2); @@ -483,7 +484,7 @@ void startETBPins(void) { etb1.start( CONFIG(etb1_use_two_wires), CONFIGB(etb1.controlPin1), - CONFIGB(etb1.controlPinMode), + &CONFIGB(etb1.controlPinMode), CONFIGB(etb1.directionPin1), CONFIGB(etb1.directionPin2) ); diff --git a/firmware/controllers/actuators/idle_thread.cpp b/firmware/controllers/actuators/idle_thread.cpp index 765d738018..143c188194 100644 --- a/firmware/controllers/actuators/idle_thread.cpp +++ b/firmware/controllers/actuators/idle_thread.cpp @@ -139,7 +139,7 @@ static void applyIACposition(percent_t position) { if (CONFIGB(useETBforIdleControl)) { engine->engineState.etbIdleAddition = position / 100 * CONFIG(etbIdleThrottleRange); #if ! EFI_UNIT_TEST - } if (CONFIGB(useStepperIdle)) { + } if (CONFIGB(useStepperIdle)) { iacMotor.setTargetPosition(position / 100 * engineConfiguration->idleStepperTotalSteps); #endif /* EFI_UNIT_TEST */ } else { diff --git a/firmware/controllers/system/efi_gpio.h b/firmware/controllers/system/efi_gpio.h index 3762e4a22d..091fdbfb98 100644 --- a/firmware/controllers/system/efi_gpio.h +++ b/firmware/controllers/system/efi_gpio.h @@ -31,6 +31,7 @@ public: OutputPin(); /** * initializes pin & registers it in pin repository + * todo: add a comment explaining why outputMode POINTER not VALUE? */ void initPin(const char *msg, brain_pin_e brainPin, const pin_output_mode_e *outputMode); /**