2015-07-10 06:01:56 -07:00
|
|
|
/**
|
|
|
|
* @file custom_engine.cpp
|
|
|
|
*
|
2017-02-24 15:55:53 -08:00
|
|
|
*
|
2017-12-02 16:25:36 -08:00
|
|
|
* set engine_type 49
|
2017-12-03 14:26:15 -08:00
|
|
|
* FRANKENSO_QA_ENGINE
|
2017-12-02 16:25:36 -08:00
|
|
|
* See also DEFAULT_ENGINE_TYPE
|
|
|
|
* Frankenso QA 12 cylinder engine
|
2017-02-24 15:55:53 -08:00
|
|
|
*
|
2015-07-10 06:01:56 -07:00
|
|
|
* @date Jan 18, 2015
|
2020-01-07 21:02:40 -08:00
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2020
|
2015-07-10 06:01:56 -07:00
|
|
|
*/
|
2019-12-28 20:22:16 -08:00
|
|
|
|
2021-08-03 19:05:01 -07:00
|
|
|
#include "pch.h"
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
#include "custom_engine.h"
|
2019-04-11 20:21:16 -07:00
|
|
|
#include "fsio_impl.h"
|
2021-10-27 16:54:45 -07:00
|
|
|
#include "mre_meta.h"
|
2021-11-10 19:27:21 -08:00
|
|
|
#include "proteus_meta.h"
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2019-09-21 21:16:46 -07:00
|
|
|
#if EFI_ELECTRONIC_THROTTLE_BODY
|
|
|
|
#include "electronic_throttle.h"
|
|
|
|
#endif
|
|
|
|
|
2019-04-12 19:10:57 -07:00
|
|
|
#if EFI_PROD_CODE
|
2016-01-24 12:02:46 -08:00
|
|
|
#include "can_hw.h"
|
2018-01-28 11:03:58 -08:00
|
|
|
#include "scheduler.h"
|
2017-12-03 12:23:39 -08:00
|
|
|
#endif /* EFI_PROD_CODE */
|
2016-01-24 12:02:46 -08:00
|
|
|
|
2021-10-02 21:35:09 -07:00
|
|
|
#if HW_PROTEUS & EFI_PROD_CODE
|
|
|
|
#include "proteus_meta.h"
|
|
|
|
#endif
|
2018-01-28 11:03:58 -08:00
|
|
|
|
2019-04-12 19:10:57 -07:00
|
|
|
#if EFI_PROD_CODE
|
2018-01-28 11:03:58 -08:00
|
|
|
static int periodIndex = 0;
|
|
|
|
|
|
|
|
static OutputPin testPin;
|
2021-07-13 17:10:31 -07:00
|
|
|
static scheduling_s testScheduling;
|
2018-01-28 11:03:58 -08:00
|
|
|
|
2018-01-29 11:25:28 -08:00
|
|
|
static int test557[] = {5, 5, 10, 10, 20, 20, 50, 50, 100, 100, 200, 200, 500, 500, 500, 500};
|
|
|
|
#define TEST_LEN 16
|
2018-01-28 11:03:58 -08:00
|
|
|
|
|
|
|
efitimeus_t testTime;
|
|
|
|
|
2020-01-06 21:41:18 -08:00
|
|
|
static void toggleTestAndScheduleNext(void *) {
|
2018-01-28 11:03:58 -08:00
|
|
|
testPin.toggle();
|
|
|
|
periodIndex = (periodIndex + 1) % TEST_LEN;
|
|
|
|
testTime += test557[periodIndex];
|
2021-07-14 13:03:00 -07:00
|
|
|
engine->executor.scheduleByTimestamp("test", &testScheduling, testTime, &toggleTestAndScheduleNext);
|
2018-01-28 11:03:58 -08:00
|
|
|
}
|
|
|
|
|
2018-03-04 14:55:46 -08:00
|
|
|
/**
|
|
|
|
* https://github.com/rusefi/rusefi/issues/557 common rail / direct injection scheduling control test
|
|
|
|
*/
|
2019-01-10 21:03:42 -08:00
|
|
|
void runSchedulingPrecisionTestIfNeeded(void) {
|
2021-01-08 17:01:26 -08:00
|
|
|
if (!isBrainPinValid(engineConfiguration->test557pin)) {
|
2018-01-28 11:03:58 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
testPin.initPin("test", engineConfiguration->test557pin);
|
|
|
|
testPin.setValue(0);
|
|
|
|
testTime = getTimeNowUs();
|
2020-01-06 21:41:18 -08:00
|
|
|
toggleTestAndScheduleNext(/*unused*/ nullptr);
|
2018-01-28 11:03:58 -08:00
|
|
|
}
|
|
|
|
#endif /* EFI_PROD_CODE */
|
|
|
|
|
2019-12-11 14:48:55 -08:00
|
|
|
void setFrankenso_01_LCD(engine_configuration_s *engineConfiguration) {
|
|
|
|
engineConfiguration->HD44780_rs = GPIOE_7;
|
|
|
|
engineConfiguration->HD44780_e = GPIOE_9;
|
|
|
|
engineConfiguration->HD44780_db4 = GPIOE_11;
|
|
|
|
engineConfiguration->HD44780_db5 = GPIOE_13;
|
|
|
|
engineConfiguration->HD44780_db6 = GPIOE_15;
|
|
|
|
engineConfiguration->HD44780_db7 = GPIOB_10;
|
2016-04-03 16:01:59 -07:00
|
|
|
}
|
|
|
|
|
2019-12-11 14:48:55 -08:00
|
|
|
void disableLCD(engine_configuration_s *engineConfiguration) {
|
|
|
|
engineConfiguration->HD44780_rs = GPIO_UNASSIGNED;
|
|
|
|
engineConfiguration->HD44780_e = GPIO_UNASSIGNED;
|
|
|
|
engineConfiguration->HD44780_db4 = GPIO_UNASSIGNED;
|
|
|
|
engineConfiguration->HD44780_db5 = GPIO_UNASSIGNED;
|
|
|
|
engineConfiguration->HD44780_db6 = GPIO_UNASSIGNED;
|
|
|
|
engineConfiguration->HD44780_db7 = GPIO_UNASSIGNED;
|
2016-04-03 16:01:59 -07:00
|
|
|
}
|
|
|
|
|
2017-01-28 12:05:25 -08:00
|
|
|
// todo: should this be part of more default configurations?
|
2021-11-16 01:15:29 -08:00
|
|
|
void setFrankensoConfiguration() {
|
|
|
|
setDefaultFrankensoConfiguration();
|
2015-07-10 06:01:56 -07:00
|
|
|
engineConfiguration->trigger.type = TT_ONE_PLUS_ONE;
|
|
|
|
|
2019-12-11 14:48:55 -08:00
|
|
|
setFrankenso_01_LCD(engineConfiguration);
|
2019-08-12 21:03:31 -07:00
|
|
|
engineConfiguration->displayMode = DM_HD44780;
|
2019-01-09 21:56:08 -08:00
|
|
|
commonFrankensoAnalogInputs(engineConfiguration);
|
|
|
|
setFrankenso0_1_joystick(engineConfiguration);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Frankenso analog #1 PC2 ADC12 CLT
|
|
|
|
* Frankenso analog #2 PC1 ADC11 IAT
|
|
|
|
* Frankenso analog #3 PA0 ADC0 MAP
|
|
|
|
* Frankenso analog #4 PC3 ADC13 WBO / O2
|
|
|
|
* Frankenso analog #5 PA2 ADC2 TPS
|
|
|
|
* Frankenso analog #6 PA1 ADC1
|
|
|
|
* Frankenso analog #7 PA4 ADC4
|
|
|
|
* Frankenso analog #8 PA3 ADC3
|
|
|
|
* Frankenso analog #9 PA7 ADC7
|
|
|
|
* Frankenso analog #10 PA6 ADC6
|
|
|
|
* Frankenso analog #11 PC5 ADC15
|
|
|
|
* Frankenso analog #12 PC4 ADC14 VBatt
|
|
|
|
*/
|
2019-06-30 11:28:47 -07:00
|
|
|
engineConfiguration->tps1_1AdcChannel = EFI_ADC_2; // PA2
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
engineConfiguration->map.sensor.hwChannel = EFI_ADC_0;
|
|
|
|
|
|
|
|
engineConfiguration->clt.adcChannel = EFI_ADC_12;
|
|
|
|
engineConfiguration->iat.adcChannel = EFI_ADC_11;
|
|
|
|
engineConfiguration->afr.hwChannel = EFI_ADC_13;
|
|
|
|
|
2019-10-02 18:00:10 -07:00
|
|
|
setCommonNTCSensor(&engineConfiguration->clt, 2700);
|
|
|
|
setCommonNTCSensor(&engineConfiguration->iat, 2700);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* http://rusefi.com/wiki/index.php?title=Manual:Hardware_Frankenso_board
|
|
|
|
*/
|
|
|
|
// Frankenso low out #1: PE6
|
|
|
|
// Frankenso low out #2: PE5
|
|
|
|
// Frankenso low out #3: PD7 Main Relay
|
|
|
|
// Frankenso low out #4: PC13 Idle valve solenoid
|
|
|
|
// Frankenso low out #5: PE3
|
|
|
|
// Frankenso low out #6: PE4 fuel pump relay
|
|
|
|
// Frankenso low out #7: PE1 (do not use with discovery!)
|
|
|
|
// Frankenso low out #8: PE2 injector #2
|
|
|
|
// Frankenso low out #9: PB9 injector #1
|
|
|
|
// Frankenso low out #10: PE0 (do not use with discovery!)
|
|
|
|
// Frankenso low out #11: PB8 injector #3
|
|
|
|
// Frankenso low out #12: PB7 injector #4
|
|
|
|
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->fuelPumpPin = GPIOE_4;
|
|
|
|
engineConfiguration->mainRelayPin = GPIOD_7;
|
|
|
|
engineConfiguration->idle.solenoidPin = GPIOC_13;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->fanPin = GPIOE_5;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->injectionPins[0] = GPIOB_9; // #1
|
|
|
|
engineConfiguration->injectionPins[1] = GPIOE_2; // #2
|
|
|
|
engineConfiguration->injectionPins[2] = GPIOB_8; // #3
|
2019-02-06 15:53:43 -08:00
|
|
|
#ifndef EFI_INJECTOR_PIN3
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->injectionPins[3] = GPIOB_7; // #4
|
2019-02-06 15:53:43 -08:00
|
|
|
#else /* EFI_INJECTOR_PIN3 */
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->injectionPins[3] = EFI_INJECTOR_PIN3; // #4
|
2019-02-06 15:53:43 -08:00
|
|
|
#endif /* EFI_INJECTOR_PIN3 */
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
setAlgorithm(LM_SPEED_DENSITY);
|
2016-01-08 12:01:38 -08:00
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
#if EFI_PWM_TESTER
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->injectionPins[4] = GPIOC_8; // #5
|
|
|
|
engineConfiguration->injectionPins[5] = GPIOD_10; // #6
|
|
|
|
engineConfiguration->injectionPins[6] = GPIOD_9;
|
|
|
|
engineConfiguration->injectionPins[7] = GPIOD_11;
|
|
|
|
engineConfiguration->injectionPins[8] = GPIOD_0;
|
|
|
|
engineConfiguration->injectionPins[9] = GPIOB_11;
|
|
|
|
engineConfiguration->injectionPins[10] = GPIOC_7;
|
|
|
|
engineConfiguration->injectionPins[11] = GPIOE_4;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* We want to initialize all outputs for test
|
|
|
|
*/
|
|
|
|
engineConfiguration->specs.cylindersCount = 12;
|
|
|
|
|
|
|
|
engineConfiguration->displayMode = DM_NONE;
|
2017-12-03 12:37:52 -08:00
|
|
|
#else /* EFI_PWM_TESTER */
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->injectionPins[4] = GPIO_UNASSIGNED;
|
|
|
|
engineConfiguration->injectionPins[5] = GPIO_UNASSIGNED;
|
|
|
|
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;
|
|
|
|
|
|
|
|
engineConfiguration->ignitionPins[0] = GPIOE_14;
|
|
|
|
engineConfiguration->ignitionPins[1] = GPIOC_7;
|
|
|
|
engineConfiguration->ignitionPins[2] = GPIOC_9;
|
2017-03-21 19:45:15 -07:00
|
|
|
// set_ignition_pin 4 PE10
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->ignitionPins[3] = GPIOE_10;
|
2017-12-03 12:37:52 -08:00
|
|
|
#endif /* EFI_PWM_TESTER */
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
// todo: 8.2 or 10k?
|
|
|
|
engineConfiguration->vbattDividerCoeff = ((float) (10 + 33)) / 10 * 2;
|
|
|
|
|
2019-04-12 19:10:57 -07:00
|
|
|
#if EFI_CAN_SUPPORT
|
2016-01-24 12:02:46 -08:00
|
|
|
enableFrankensoCan();
|
2018-11-16 04:40:06 -08:00
|
|
|
#endif /* EFI_CAN_SUPPORT */
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2020-02-18 14:53:56 -08:00
|
|
|
/**
|
|
|
|
* set engine_type 49
|
|
|
|
*/
|
2021-11-16 01:15:29 -08:00
|
|
|
void setFrankensoBoardTestConfiguration() {
|
|
|
|
setFrankensoConfiguration();
|
2017-02-24 15:55:53 -08:00
|
|
|
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->triggerSimulatorFrequency = 300;
|
2017-12-03 15:29:52 -08:00
|
|
|
engineConfiguration->cranking.rpm = 100;
|
2017-12-02 16:47:18 -08:00
|
|
|
|
2017-02-24 15:55:53 -08:00
|
|
|
engineConfiguration->specs.cylindersCount = 12;
|
2017-03-23 18:59:47 -07:00
|
|
|
engineConfiguration->specs.firingOrder = FO_1_7_5_11_3_9_6_12_2_8_4_10;
|
2017-02-24 15:55:53 -08:00
|
|
|
|
2017-03-21 19:45:15 -07:00
|
|
|
// set ignition_mode 1
|
|
|
|
engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS;
|
|
|
|
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->injectionPins[0] = GPIOB_7; // injector in default pinout
|
|
|
|
engineConfiguration->injectionPins[1] = GPIOB_8; // injector in default pinout
|
|
|
|
engineConfiguration->injectionPins[2] = GPIOB_9; // injector in default pinout
|
|
|
|
engineConfiguration->injectionPins[3] = GPIOC_13;
|
|
|
|
|
|
|
|
engineConfiguration->injectionPins[4] = GPIOD_3;
|
|
|
|
engineConfiguration->injectionPins[5] = GPIOD_5;
|
|
|
|
engineConfiguration->injectionPins[6] = GPIOD_7;
|
|
|
|
engineConfiguration->injectionPins[7] = GPIOE_2; // injector in default pinout
|
|
|
|
engineConfiguration->injectionPins[8] = GPIOE_3;
|
|
|
|
engineConfiguration->injectionPins[9] = GPIOE_4;
|
|
|
|
engineConfiguration->injectionPins[10] = GPIOE_5;
|
|
|
|
engineConfiguration->injectionPins[11] = GPIOE_6;
|
|
|
|
|
|
|
|
engineConfiguration->fuelPumpPin = GPIO_UNASSIGNED;
|
|
|
|
engineConfiguration->mainRelayPin = GPIO_UNASSIGNED;
|
|
|
|
engineConfiguration->idle.solenoidPin = GPIO_UNASSIGNED;
|
|
|
|
engineConfiguration->fanPin = GPIO_UNASSIGNED;
|
|
|
|
|
|
|
|
|
|
|
|
engineConfiguration->ignitionPins[0] = GPIOC_9; // coil in default pinout
|
|
|
|
engineConfiguration->ignitionPins[1] = GPIOC_7; // coil in default pinout
|
|
|
|
engineConfiguration->ignitionPins[2] = GPIOE_10; // coil in default pinout
|
|
|
|
engineConfiguration->ignitionPins[3] = GPIOE_8; // Miata VVT tach
|
|
|
|
|
|
|
|
engineConfiguration->ignitionPins[4] = GPIOE_14; // coil in default pinout
|
|
|
|
engineConfiguration->ignitionPins[5] = GPIOE_12;
|
|
|
|
engineConfiguration->ignitionPins[6] = GPIOD_8;
|
|
|
|
engineConfiguration->ignitionPins[7] = GPIOD_9;
|
|
|
|
|
|
|
|
engineConfiguration->ignitionPins[8] = GPIOE_0; // brain board, not discovery
|
|
|
|
engineConfiguration->ignitionPins[9] = GPIOE_1; // brain board, not discovery
|
2017-02-24 15:55:53 -08:00
|
|
|
}
|
|
|
|
|
2019-05-04 06:57:57 -07:00
|
|
|
|
2019-03-02 11:00:32 -08:00
|
|
|
// ETB_BENCH_ENGINE
|
2019-04-21 11:11:39 -07:00
|
|
|
// set engine_type 58
|
2021-11-16 01:15:29 -08:00
|
|
|
void setEtbTestConfiguration() {
|
|
|
|
setDefaultFrankensoConfiguration();
|
2019-03-02 10:21:12 -08:00
|
|
|
// VAG test ETB
|
|
|
|
// set tps_min 54
|
|
|
|
engineConfiguration->tpsMin = 54;
|
|
|
|
// by the way this ETB has default position of ADC=74 which is about 4%
|
|
|
|
// set tps_max 540
|
|
|
|
engineConfiguration->tpsMax = 540;
|
|
|
|
|
2019-11-24 17:48:25 -08:00
|
|
|
// yes, 30K - that's a test configuration
|
|
|
|
engineConfiguration->rpmHardLimit = 30000;
|
|
|
|
|
|
|
|
setOperationMode(engineConfiguration, FOUR_STROKE_CRANK_SENSOR);
|
|
|
|
engineConfiguration->trigger.type = TT_TOOTHED_WHEEL_60_2;
|
|
|
|
|
|
|
|
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->ignitionPins[0] = GPIO_UNASSIGNED;
|
|
|
|
engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED;
|
|
|
|
engineConfiguration->ignitionPins[2] = GPIO_UNASSIGNED;
|
|
|
|
engineConfiguration->ignitionPins[3] = GPIO_UNASSIGNED;
|
2019-02-27 06:57:03 -08:00
|
|
|
/**
|
|
|
|
* remember that some H-bridges require 5v control lines, not just 3v logic outputs we have on stm32
|
|
|
|
*/
|
2021-11-17 00:54:21 -08:00
|
|
|
engineConfiguration->etbIo[0].directionPin1 = GPIOC_7; // Frankenso high-side in order to get 5v control
|
|
|
|
engineConfiguration->etbIo[0].directionPin2 = GPIOC_9;
|
|
|
|
engineConfiguration->etbIo[0].controlPin = GPIOE_14;
|
2019-02-27 14:54:25 -08:00
|
|
|
|
2019-04-12 19:10:57 -07:00
|
|
|
#if EFI_ELECTRONIC_THROTTLE_BODY
|
2021-11-16 01:15:29 -08:00
|
|
|
setBoschVNH2SP30Curve();
|
|
|
|
// setDefaultEtbParameters();
|
2019-03-29 07:29:01 -07:00
|
|
|
#endif /* EFI_ELECTRONIC_THROTTLE_BODY */
|
2019-02-27 06:57:03 -08:00
|
|
|
|
2019-06-30 11:28:47 -07:00
|
|
|
engineConfiguration->tps1_1AdcChannel = EFI_ADC_2; // PA2
|
2019-02-27 06:57:03 -08:00
|
|
|
engineConfiguration->throttlePedalPositionAdcChannel = EFI_ADC_9; // PB1
|
|
|
|
|
2019-02-27 14:54:25 -08:00
|
|
|
engineConfiguration->debugMode = DBG_ELECTRONIC_THROTTLE_PID;
|
|
|
|
|
2019-03-02 19:42:11 -08:00
|
|
|
// turning off other PWMs to simplify debugging
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->triggerSimulatorFrequency = 0;
|
2019-03-03 12:27:49 -08:00
|
|
|
engineConfiguration->stepperEnablePin = GPIO_UNASSIGNED;
|
2021-11-17 00:54:21 -08:00
|
|
|
engineConfiguration->idle.stepperStepPin = GPIO_UNASSIGNED;
|
|
|
|
engineConfiguration->idle.stepperDirectionPin = GPIO_UNASSIGNED;
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->useStepperIdle = true;
|
2019-03-02 19:42:11 -08:00
|
|
|
|
2019-05-04 08:01:05 -07:00
|
|
|
// no analog dividers - all sensors with 3v supply, naked discovery bench setup
|
|
|
|
engineConfiguration->analogInputDividerCoefficient = 1;
|
|
|
|
|
|
|
|
// EFI_ADC_15 = PC5
|
2019-03-10 21:31:06 -07:00
|
|
|
engineConfiguration->clt.adcChannel = EFI_ADC_15;
|
2019-10-02 18:00:10 -07:00
|
|
|
set10K_4050K(&engineConfiguration->clt, 10000);
|
2019-03-10 21:31:06 -07:00
|
|
|
|
2019-04-21 09:24:31 -07:00
|
|
|
// see also setDefaultEtbBiasCurve
|
2019-02-27 05:55:56 -08:00
|
|
|
}
|
2019-04-04 18:34:33 -07:00
|
|
|
|
2019-12-28 20:22:16 -08:00
|
|
|
#if EFI_UNIT_TEST
|
2021-11-16 01:15:29 -08:00
|
|
|
void setIssue898() {
|
2019-08-08 20:11:56 -07:00
|
|
|
engineConfiguration->trigger.type = TT_MAZDA_MIATA_NA;
|
|
|
|
}
|
2019-12-28 20:22:16 -08:00
|
|
|
#endif /* EFI_UNIT_TEST */
|
2019-08-08 20:11:56 -07:00
|
|
|
|
2019-04-04 18:34:33 -07:00
|
|
|
// TLE8888_BENCH_ENGINE
|
2019-12-28 20:22:16 -08:00
|
|
|
// todo: remove this? this was used to play with "secret" red boards prior to MRE reality
|
2019-04-04 18:34:33 -07:00
|
|
|
// set engine_type 59
|
2021-11-16 01:15:29 -08:00
|
|
|
void setTle8888TestConfiguration() {
|
2019-04-04 18:34:33 -07:00
|
|
|
engineConfiguration->specs.cylindersCount = 8;
|
|
|
|
engineConfiguration->specs.firingOrder = FO_1_8_7_2_6_5_4_3;
|
|
|
|
engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS;
|
|
|
|
engineConfiguration->crankingInjectionMode = IM_SEQUENTIAL;
|
|
|
|
|
2019-07-09 03:06:07 -07:00
|
|
|
#if defined(STM32_HAS_GPIOG) && STM32_HAS_GPIOG
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->ignitionPins[0] = GPIOG_3;
|
|
|
|
engineConfiguration->ignitionPins[1] = GPIOG_4;
|
|
|
|
engineConfiguration->ignitionPins[2] = GPIOG_5;
|
|
|
|
engineConfiguration->ignitionPins[3] = GPIOG_6;
|
|
|
|
engineConfiguration->ignitionPins[4] = GPIOG_7;
|
|
|
|
engineConfiguration->ignitionPins[5] = GPIOG_8;
|
2019-07-09 02:29:03 -07:00
|
|
|
#endif /* STM32_HAS_GPIOG */
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->ignitionPins[6] = GPIOC_6;
|
|
|
|
engineConfiguration->ignitionPins[7] = GPIOC_7;
|
2019-04-04 18:34:33 -07:00
|
|
|
|
2019-07-27 06:37:45 -07:00
|
|
|
#if (BOARD_TLE8888_COUNT > 0)
|
2019-04-04 18:34:33 -07:00
|
|
|
engineConfiguration->tle8888spiDevice = SPI_DEVICE_1;
|
2019-07-27 06:37:45 -07:00
|
|
|
engineConfiguration->tle8888_cs = GPIOD_5;
|
2019-04-04 18:34:33 -07:00
|
|
|
|
2019-04-06 04:38:02 -07:00
|
|
|
// PB3 is nicely both SWO and SPI1 SCK so logic analyzer could be used on SWO header
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->spi1mosiPin = GPIOB_5;
|
|
|
|
engineConfiguration->spi1misoPin = GPIOB_4;
|
|
|
|
engineConfiguration->spi1sckPin = GPIOB_3; // please note that this pin is also SWO/SWD - Single Wire debug Output
|
|
|
|
engineConfiguration->is_enabled_spi_1 = true;
|
2019-04-04 20:03:32 -07:00
|
|
|
engineConfiguration->debugMode = DBG_TLE8888;
|
2019-04-11 20:21:16 -07:00
|
|
|
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->fuelPumpPin = TLE8888_PIN_20;
|
2019-07-27 06:37:45 -07:00
|
|
|
#endif /* BOARD_TLE8888_COUNT */
|
|
|
|
|
2019-04-12 22:03:12 -07:00
|
|
|
engineConfiguration->throttlePedalPositionAdcChannel = EFI_ADC_9; // PB1 // just any non-empty value for now
|
2019-04-11 20:21:16 -07:00
|
|
|
// ETB #1 top one - closer to 121 connector
|
|
|
|
// DIS PF12
|
|
|
|
// EN PF13
|
|
|
|
// IN1 PF15
|
|
|
|
// IN2 PF14
|
|
|
|
// SF PF11
|
2019-07-09 03:06:07 -07:00
|
|
|
#if defined(STM32_HAS_GPIOF) && STM32_HAS_GPIOF
|
2019-04-15 05:40:12 -07:00
|
|
|
#if EFI_FSIO
|
2021-11-16 01:15:29 -08:00
|
|
|
// todo lua setFsio(14, GPIOF_13, "1");
|
2019-08-14 22:59:15 -07:00
|
|
|
#endif /* EFI_FSIO */
|
2021-11-17 00:54:21 -08:00
|
|
|
engineConfiguration->etbIo[0].directionPin1 = GPIOF_15;
|
|
|
|
engineConfiguration->etbIo[0].directionPin2 = GPIOF_14;
|
|
|
|
engineConfiguration->etbIo[0].disablePin = GPIOF_12;
|
2019-07-09 02:29:03 -07:00
|
|
|
#endif /* STM32_HAS_GPIOF */
|
2021-11-17 00:54:21 -08:00
|
|
|
engineConfiguration->etb_use_two_wires = true;
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->isHip9011Enabled = false;
|
2019-04-11 20:21:16 -07:00
|
|
|
|
|
|
|
// ETB #2
|
|
|
|
// DIS PE5
|
|
|
|
// EN PE6
|
|
|
|
// IN1 PE2
|
|
|
|
// IN2 PE4
|
|
|
|
// SF PE3
|
2019-04-15 05:40:12 -07:00
|
|
|
#if EFI_FSIO
|
2021-11-16 01:15:29 -08:00
|
|
|
// todo lua setFsio(15, GPIOE_6, "1");
|
2019-04-15 05:40:12 -07:00
|
|
|
#endif
|
2021-11-17 00:54:21 -08:00
|
|
|
engineConfiguration->etbIo[0].directionPin1 = GPIOE_2;
|
|
|
|
engineConfiguration->etbIo[0].directionPin2 = GPIOE_4;
|
|
|
|
engineConfiguration->etbIo[0].disablePin = GPIOE_5;
|
2019-04-11 20:21:16 -07:00
|
|
|
|
2019-04-21 11:00:19 -07:00
|
|
|
|
2019-06-30 11:28:47 -07:00
|
|
|
engineConfiguration->tps1_1AdcChannel = EFI_ADC_3; // PA3
|
2019-04-24 20:46:49 -07:00
|
|
|
engineConfiguration->throttlePedalPositionAdcChannel = EFI_ADC_7; // PA7
|
|
|
|
|
2019-05-05 09:48:04 -07:00
|
|
|
// engineConfiguration->etb.pFactor = 1.07;
|
|
|
|
// engineConfiguration->etb.iFactor = 0.18;
|
|
|
|
// engineConfiguration->etb.dFactor = 0.24;
|
|
|
|
// engineConfiguration->etb.offset = 80;
|
|
|
|
|
|
|
|
engineConfiguration->etb.pFactor = 22;
|
|
|
|
engineConfiguration->etb.iFactor = 0;
|
|
|
|
engineConfiguration->etb.dFactor = 0;
|
|
|
|
engineConfiguration->etb.offset = 0;
|
|
|
|
|
2019-04-24 20:46:49 -07:00
|
|
|
engineConfiguration->etb_iTermMin = -300;
|
|
|
|
engineConfiguration->etb_iTermMax = 300;
|
|
|
|
|
|
|
|
// VAG test ETB, no divider on red board - direct 3v TPS sensor
|
|
|
|
// set tps_min 332
|
|
|
|
engineConfiguration->tpsMin = 332;
|
|
|
|
// by the way this ETB has default position of ADC=74 which is about 4%
|
|
|
|
// set tps_max 540
|
|
|
|
engineConfiguration->tpsMax = 799;
|
2019-04-04 18:34:33 -07:00
|
|
|
}
|
|
|
|
|
2019-08-05 20:00:35 -07:00
|
|
|
/**
|
2019-12-28 20:22:16 -08:00
|
|
|
* This configuration is used for MRE board Quality Assurance validation
|
2021-10-24 08:47:20 -07:00
|
|
|
* todo: inline
|
2019-08-05 20:00:35 -07:00
|
|
|
*/
|
2021-11-16 01:15:29 -08:00
|
|
|
static void mreBoardOldTest() {
|
2019-10-31 13:06:34 -07:00
|
|
|
#if (BOARD_TLE8888_COUNT > 0)
|
2020-02-10 10:24:09 -08:00
|
|
|
engineConfiguration->debugMode = DBG_TLE8888;
|
|
|
|
|
2020-10-11 16:16:41 -07:00
|
|
|
engineConfiguration->triggerSimulatorFrequency = HW_CHECK_RPM;
|
2019-08-10 11:53:57 -07:00
|
|
|
// set cranking_rpm 500
|
2019-08-09 16:11:15 -07:00
|
|
|
engineConfiguration->cranking.rpm = 100;
|
2019-08-10 13:25:42 -07:00
|
|
|
// set cranking_dwell 200
|
|
|
|
engineConfiguration->ignitionDwellForCrankingMs = 200;
|
2019-08-10 11:53:57 -07:00
|
|
|
// set cranking_fuel 300
|
|
|
|
engineConfiguration->cranking.baseFuel = 190;
|
2019-08-09 16:11:15 -07:00
|
|
|
engineConfiguration->injectionMode = IM_SEQUENTIAL;
|
2019-08-10 11:53:57 -07:00
|
|
|
engineConfiguration->crankingInjectionMode = IM_SEQUENTIAL;
|
2019-08-05 20:00:35 -07:00
|
|
|
|
|
|
|
// EFI_ADC_1: "23 - AN temp 2"
|
|
|
|
// test harness: Red/Green, 2K PD. expected 2.0v
|
|
|
|
// iat in microrusefi/board_configuration.cpp
|
|
|
|
|
|
|
|
// EFI_ADC_2: "24 - AN temp 3"
|
|
|
|
// test harness: Blue/White, 2K PD. expected 2.0v
|
|
|
|
|
|
|
|
|
|
|
|
// EFI_ADC_10: "27 - AN volt 1"
|
|
|
|
// test harness: Blue/Red, 3.84K PD / 5.3 PU. expected 1.6v
|
|
|
|
engineConfiguration->mafAdcChannel = EFI_ADC_10;
|
|
|
|
|
|
|
|
// EFI_ADC_14: "32 - AN volt 6"
|
|
|
|
// test harness: Red/White 3.6K PD / 5.2 PU. expected 1.6v
|
|
|
|
engineConfiguration->throttlePedalPositionAdcChannel = EFI_ADC_14;
|
|
|
|
|
|
|
|
|
|
|
|
// EFI_ADC_4: "28 - AN volt 10"
|
|
|
|
// test harness: Red/Yellow
|
|
|
|
engineConfiguration->afr.hwChannel = EFI_ADC_4;
|
|
|
|
|
|
|
|
|
|
|
|
// EFI_ADC_7: "31 - AN volt 3"
|
|
|
|
// test harness: White/Red
|
|
|
|
engineConfiguration->map.sensor.hwChannel = EFI_ADC_7;
|
|
|
|
|
|
|
|
|
|
|
|
//engineConfiguration->baroSensor.hwChannel
|
|
|
|
//engineConfiguration->oilPressure.hwChannel
|
|
|
|
//engineConfiguration->fuelLevelSensor
|
|
|
|
|
|
|
|
// TPS tps1_1AdcChannel EFI_ADC_13
|
|
|
|
|
2019-08-09 16:11:15 -07:00
|
|
|
engineConfiguration->specs.cylindersCount = 10;
|
|
|
|
engineConfiguration->specs.firingOrder = FO_1_10_9_4_3_6_5_8_7_2;
|
2019-08-09 20:45:35 -07:00
|
|
|
|
2019-08-10 13:25:42 -07:00
|
|
|
// red LED #1
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->ignitionPins[1 - 1] = GPIOD_4;
|
|
|
|
engineConfiguration->ignitionPins[10 - 1] = GPIOD_3;
|
|
|
|
engineConfiguration->ignitionPins[9 - 1] = GPIOD_6;
|
|
|
|
engineConfiguration->ignitionPins[4 - 1] = GPIOD_7;
|
|
|
|
engineConfiguration->ignitionPins[3 - 1] = GPIOD_1;
|
|
|
|
engineConfiguration->ignitionPins[6 - 1] = GPIOD_2;
|
|
|
|
engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED;
|
|
|
|
engineConfiguration->ignitionPins[4] = GPIO_UNASSIGNED;
|
|
|
|
engineConfiguration->ignitionPins[6] = GPIO_UNASSIGNED;
|
|
|
|
engineConfiguration->ignitionPins[7] = GPIO_UNASSIGNED;
|
|
|
|
|
|
|
|
|
|
|
|
engineConfiguration->fuelPumpPin = GPIO_UNASSIGNED;
|
|
|
|
engineConfiguration->idle.solenoidPin = GPIO_UNASSIGNED;
|
|
|
|
engineConfiguration->fanPin = GPIO_UNASSIGNED;
|
2019-10-10 10:32:07 -07:00
|
|
|
|
2019-08-16 20:21:03 -07:00
|
|
|
// fuel pump is useful to test power on/off scenario
|
2019-12-11 14:48:55 -08:00
|
|
|
// engineConfiguration->fuelPumpPin = TLE8888_PIN_22;
|
2019-08-16 20:21:03 -07:00
|
|
|
|
|
|
|
|
2019-08-10 11:53:57 -07:00
|
|
|
// LED #1
|
2020-10-23 09:25:30 -07:00
|
|
|
// TLE8888_PIN_22: "34 - GP Out 2"
|
|
|
|
engineConfiguration->injectionPins[1 - 1] = TLE8888_PIN_22;
|
2019-08-10 11:53:57 -07:00
|
|
|
|
|
|
|
// LED #2
|
2019-08-10 12:23:41 -07:00
|
|
|
// TLE8888_PIN_23: "33 - GP Out 3"
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->injectionPins[10 - 1] = TLE8888_PIN_23;
|
2019-08-10 11:53:57 -07:00
|
|
|
|
2020-10-23 09:25:30 -07:00
|
|
|
// TLE8888_PIN_1: LED #3 - INJ#2
|
|
|
|
engineConfiguration->injectionPins[9 - 1] = TLE8888_PIN_1;
|
2019-08-10 11:53:57 -07:00
|
|
|
|
2020-10-23 09:25:30 -07:00
|
|
|
// TLE8888_PIN_2: LED #4 - INJ#1
|
|
|
|
engineConfiguration->injectionPins[4 - 1] = TLE8888_PIN_2;
|
2019-08-10 11:53:57 -07:00
|
|
|
|
2020-10-23 09:25:30 -07:00
|
|
|
// TLE8888_PIN_3: LED #5 - INJ#3
|
|
|
|
engineConfiguration->injectionPins[3 - 1] = TLE8888_PIN_3;
|
2019-08-10 11:53:57 -07:00
|
|
|
|
2020-10-23 09:25:30 -07:00
|
|
|
// TLE8888_PIN_4: LED #6 - INJ#4
|
|
|
|
engineConfiguration->injectionPins[6 - 1] = TLE8888_PIN_4;
|
2019-08-10 11:53:57 -07:00
|
|
|
|
|
|
|
// LED #7
|
|
|
|
// TLE8888_PIN_24: "43 - GP Out 4"
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->injectionPins[5 - 1] = TLE8888_PIN_24;
|
2019-08-10 11:53:57 -07:00
|
|
|
|
|
|
|
// LED #8
|
2019-08-09 20:45:35 -07:00
|
|
|
// TLE8888 half bridges (pushpull, lowside, or high-low) IN12
|
2020-10-23 09:25:30 -07:00
|
|
|
// TLE8888_PIN_21: "35 - GP Out 1"
|
|
|
|
engineConfiguration->injectionPins[8 - 1] = TLE8888_PIN_21;
|
2019-08-09 16:11:15 -07:00
|
|
|
|
2019-08-10 11:53:57 -07:00
|
|
|
// LED #9
|
|
|
|
// TLE8888 high current low side: IN10
|
2020-10-23 09:25:30 -07:00
|
|
|
// TLE8888_PIN_6: "7 - Lowside 1"
|
|
|
|
engineConfiguration->injectionPins[7 - 1] = TLE8888_PIN_6;
|
2019-08-05 20:00:35 -07:00
|
|
|
|
2019-08-10 11:53:57 -07:00
|
|
|
// LED #10
|
|
|
|
// TLE8888 high current low side: VVT2 IN9 / OUT5
|
2020-10-23 09:25:30 -07:00
|
|
|
// TLE8888_PIN_5: "3 - Lowside 2"
|
|
|
|
engineConfiguration->injectionPins[2 - 1] = TLE8888_PIN_5;
|
2019-10-31 13:06:34 -07:00
|
|
|
#endif /* BOARD_TLE8888_COUNT */
|
2019-08-05 20:00:35 -07:00
|
|
|
}
|
2020-02-25 18:35:21 -08:00
|
|
|
|
2020-12-25 21:57:23 -08:00
|
|
|
#if HW_PROTEUS
|
2020-12-26 07:41:33 -08:00
|
|
|
/**
|
|
|
|
* PROTEUS_QC_TEST_BOARD
|
|
|
|
* set engine_type 42
|
|
|
|
*/
|
2021-11-16 01:15:29 -08:00
|
|
|
void proteusBoardTest() {
|
2020-12-25 21:57:23 -08:00
|
|
|
engineConfiguration->specs.cylindersCount = 12;
|
|
|
|
engineConfiguration->specs.firingOrder = FO_1_2_3_4_5_6_7_8_9_10_11_12;
|
2020-12-26 15:59:30 -08:00
|
|
|
engineConfiguration->triggerSimulatorFrequency = 600;
|
2020-12-25 21:57:23 -08:00
|
|
|
|
2020-12-26 10:41:33 -08:00
|
|
|
engineConfiguration->cranking.rpm = 100;
|
|
|
|
engineConfiguration->injectionMode = IM_SEQUENTIAL;
|
|
|
|
engineConfiguration->crankingInjectionMode = IM_SEQUENTIAL;
|
|
|
|
|
|
|
|
engineConfiguration->mainRelayPin = GPIO_UNASSIGNED;
|
2021-11-17 00:54:21 -08:00
|
|
|
engineConfiguration->fanPin = GPIO_UNASSIGNED;
|
|
|
|
engineConfiguration->fuelPumpPin = GPIO_UNASSIGNED;
|
2020-12-26 10:41:33 -08:00
|
|
|
|
2021-10-02 21:27:55 -07:00
|
|
|
#if EFI_PROD_CODE
|
2021-10-02 20:56:43 -07:00
|
|
|
engineConfiguration->injectionPins[0] = PROTEUS_LS_1;
|
|
|
|
engineConfiguration->injectionPins[1] = PROTEUS_LS_2;
|
|
|
|
engineConfiguration->injectionPins[2] = PROTEUS_LS_3;
|
|
|
|
engineConfiguration->injectionPins[3] = PROTEUS_LS_4;
|
2020-12-26 07:41:33 -08:00
|
|
|
engineConfiguration->injectionPins[4] = GPIOG_12;// "Lowside 5"
|
|
|
|
engineConfiguration->injectionPins[5] = GPIOG_13;// "Lowside 6"
|
2020-12-26 10:41:33 -08:00
|
|
|
engineConfiguration->injectionPins[6] = GPIOB_5;// "Lowside 9"
|
2020-12-26 07:41:33 -08:00
|
|
|
engineConfiguration->injectionPins[7] = GPIOB_4;// "Lowside 8"
|
2020-12-26 10:41:33 -08:00
|
|
|
engineConfiguration->injectionPins[8] = GPIOB_7;// "Lowside 11"
|
2021-10-02 20:56:43 -07:00
|
|
|
engineConfiguration->injectionPins[9] = PROTEUS_LS_10;
|
2020-12-26 15:59:30 -08:00
|
|
|
engineConfiguration->injectionPins[10] = GPIOB_8;// "Lowside 12"
|
2020-12-26 10:41:33 -08:00
|
|
|
engineConfiguration->injectionPins[11] = GPIOB_9;// "Lowside 13" # pin 10/black35
|
|
|
|
|
|
|
|
|
2020-12-26 07:41:33 -08:00
|
|
|
|
|
|
|
|
2021-10-28 19:11:26 -07:00
|
|
|
engineConfiguration->ignitionPins[0] = PROTEUS_IGN_1;
|
|
|
|
engineConfiguration->ignitionPins[1] = PROTEUS_IGN_2;
|
|
|
|
engineConfiguration->ignitionPins[2] = PROTEUS_IGN_4;
|
|
|
|
engineConfiguration->ignitionPins[3] = PROTEUS_IGN_5;
|
|
|
|
engineConfiguration->ignitionPins[4] = PROTEUS_IGN_6;
|
|
|
|
engineConfiguration->ignitionPins[5] = PROTEUS_IGN_7;
|
2020-12-26 15:59:30 -08:00
|
|
|
|
|
|
|
engineConfiguration->ignitionPins[6] = GPIOD_15;// "Highside 3" # pin 13/black35
|
2021-10-28 19:11:26 -07:00
|
|
|
engineConfiguration->ignitionPins[7] = PROTEUS_IGN_3;
|
|
|
|
engineConfiguration->ignitionPins[8] = PROTEUS_IGN_9;
|
|
|
|
engineConfiguration->ignitionPins[9] = PROTEUS_IGN_8;
|
|
|
|
engineConfiguration->ignitionPins[10] = PROTEUS_IGN_1;
|
|
|
|
engineConfiguration->ignitionPins[11] = PROTEUS_IGN_12;
|
2020-12-26 07:41:33 -08:00
|
|
|
|
2020-12-26 10:41:33 -08:00
|
|
|
|
2021-10-02 21:27:55 -07:00
|
|
|
#endif // EFI_PROD_CODE
|
2020-12-26 07:41:33 -08:00
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
setProteusHitachiEtbDefaults();
|
2020-12-25 21:57:23 -08:00
|
|
|
}
|
|
|
|
#endif // HW_PROTEUS
|
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
void mreBCM() {
|
2021-07-06 17:14:08 -07:00
|
|
|
for (int i = 0; i < MAX_CYLINDER_COUNT;i++) {
|
2020-09-06 16:43:54 -07:00
|
|
|
engineConfiguration->ignitionPins[i] = GPIO_UNASSIGNED;
|
|
|
|
engineConfiguration->injectionPins[i] = GPIO_UNASSIGNED;
|
|
|
|
}
|
|
|
|
engineConfiguration->fanPin = GPIO_UNASSIGNED;
|
|
|
|
engineConfiguration->consumeObdSensors = true;
|
|
|
|
|
2020-08-29 11:29:34 -07:00
|
|
|
}
|
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
void mreSecondaryCan() {
|
2021-10-27 16:54:45 -07:00
|
|
|
engineConfiguration->tps1_1AdcChannel = EFI_ADC_NONE;
|
|
|
|
engineConfiguration->tps2_1AdcChannel = EFI_ADC_NONE;
|
|
|
|
engineConfiguration->clt.adcChannel = EFI_ADC_NONE;
|
|
|
|
engineConfiguration->iat.adcChannel = EFI_ADC_NONE;
|
|
|
|
engineConfiguration->map.sensor.hwChannel = EFI_ADC_NONE;
|
|
|
|
|
|
|
|
|
|
|
|
engineConfiguration->auxAnalogInputs[0] = MRE_IN_TPS;
|
|
|
|
engineConfiguration->auxAnalogInputs[1] = MRE_IN_MAP;
|
|
|
|
engineConfiguration->auxAnalogInputs[2] = MRE_IN_CLT;
|
|
|
|
engineConfiguration->auxAnalogInputs[3] = MRE_IN_IAT;
|
|
|
|
// engineConfiguration->auxAnalogInputs[0] =
|
|
|
|
|
|
|
|
|
|
|
|
// EFI_ADC_14: "32 - AN volt 6"
|
|
|
|
// engineConfiguration->afr.hwChannel = EFI_ADC_14;
|
|
|
|
|
|
|
|
|
2021-11-08 14:31:17 -08:00
|
|
|
strncpy(config->luaScript, R"(
|
|
|
|
txPayload = {}
|
|
|
|
function onTick()
|
|
|
|
auxV = getAuxAnalog(0)
|
|
|
|
print('Hello analog ' .. auxV )
|
|
|
|
-- first byte: integer part, would be autoboxed to int
|
|
|
|
txPayload[1] = auxV
|
|
|
|
-- second byte: fractional part, would be autoboxed to int, overflow would be ignored
|
|
|
|
txPayload[2] = auxV * 256;
|
|
|
|
auxV = getAuxAnalog(1)
|
|
|
|
print('Hello analog ' .. auxV )
|
|
|
|
txPayload[3] = auxV
|
|
|
|
txPayload[4] = auxV * 256;
|
|
|
|
auxV = getAuxAnalog(2)
|
|
|
|
print('Hello analog ' .. auxV )
|
|
|
|
txPayload[5] = auxV
|
|
|
|
txPayload[6] = auxV * 256;
|
|
|
|
txCan(1, 0x600, 1, txPayload)
|
|
|
|
end
|
|
|
|
)", efi::size(config->luaScript));
|
2021-10-27 16:54:45 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-05-21 18:45:01 -07:00
|
|
|
/**
|
|
|
|
* MRE_BOARD_NEW_TEST
|
|
|
|
* set engine_type 31
|
|
|
|
*/
|
2021-11-16 01:15:29 -08:00
|
|
|
void mreBoardNewTest() {
|
|
|
|
mreBoardOldTest();
|
2020-05-21 18:45:01 -07:00
|
|
|
|
|
|
|
engineConfiguration->specs.cylindersCount = 12;
|
|
|
|
engineConfiguration->specs.firingOrder = FO_1_2_3_4_5_6_7_8_9_10_11_12;
|
|
|
|
|
|
|
|
#if (BOARD_TLE8888_COUNT > 0)
|
2020-05-23 07:50:32 -07:00
|
|
|
engineConfiguration->ignitionPins[1 - 1] = GPIOD_6;
|
|
|
|
engineConfiguration->ignitionPins[2 - 1] = GPIOD_7;
|
|
|
|
engineConfiguration->ignitionPins[3 - 1] = GPIOD_1;
|
|
|
|
engineConfiguration->ignitionPins[4 - 1] = GPIOD_2;
|
|
|
|
engineConfiguration->ignitionPins[5 - 1] = GPIOD_3;
|
|
|
|
engineConfiguration->ignitionPins[6 - 1] = GPIOD_4;
|
|
|
|
|
|
|
|
engineConfiguration->ignitionPins[7 - 1] = TLE8888_PIN_11;
|
|
|
|
engineConfiguration->ignitionPins[8 - 1] = TLE8888_PIN_12;
|
|
|
|
|
2020-08-31 14:15:04 -07:00
|
|
|
// LED #8
|
|
|
|
// TLE8888 half bridges (pushpull, lowside, or high-low) IN12
|
2020-10-23 09:25:30 -07:00
|
|
|
// TLE8888_PIN_21: "35 - GP Out 1"
|
|
|
|
engineConfiguration->ignitionPins[9 - 1] = TLE8888_PIN_21;
|
2020-08-31 14:15:04 -07:00
|
|
|
|
|
|
|
// LED #1
|
2020-10-23 09:25:30 -07:00
|
|
|
// TLE8888_PIN_22: "34 - GP Out 2"
|
|
|
|
engineConfiguration->ignitionPins[10- 1] = TLE8888_PIN_22;
|
2020-08-31 14:15:04 -07:00
|
|
|
|
|
|
|
// LED #2
|
|
|
|
// TLE8888_PIN_23: "33 - GP Out 3"
|
|
|
|
engineConfiguration->ignitionPins[11 - 1] = TLE8888_PIN_23;
|
|
|
|
|
|
|
|
// LED #7
|
|
|
|
// TLE8888_PIN_24: "43 - GP Out 4"
|
|
|
|
engineConfiguration->ignitionPins[12 - 1] = TLE8888_PIN_24;
|
|
|
|
|
2020-10-11 16:05:56 -07:00
|
|
|
engineConfiguration->afr.hwChannel = EFI_ADC_6;
|
2020-08-31 11:26:34 -07:00
|
|
|
engineConfiguration->throttlePedalPositionAdcChannel = EFI_ADC_NONE;
|
2020-08-31 10:44:58 -07:00
|
|
|
|
2020-05-21 18:45:01 -07:00
|
|
|
// TLE8888 high current low side: IN10
|
2020-10-23 09:25:30 -07:00
|
|
|
// TLE8888_PIN_6: "7 - Lowside 1"
|
|
|
|
engineConfiguration->injectionPins[1 - 1] = TLE8888_PIN_6;
|
2020-05-21 18:45:01 -07:00
|
|
|
|
|
|
|
// TLE8888 high current low side: VVT2 IN9 / OUT5
|
2020-10-23 09:25:30 -07:00
|
|
|
// TLE8888_PIN_5: "3 - Lowside 2"
|
|
|
|
engineConfiguration->injectionPins[2 - 1] = TLE8888_PIN_5;
|
2020-05-21 18:45:01 -07:00
|
|
|
|
2020-10-23 09:25:30 -07:00
|
|
|
// TLE8888_PIN_4: INJ#4
|
|
|
|
engineConfiguration->injectionPins[3 - 1] = TLE8888_PIN_4;
|
|
|
|
// TLE8888_PIN_3: INJ#3
|
|
|
|
engineConfiguration->injectionPins[4 - 1] = TLE8888_PIN_3;
|
|
|
|
// TLE8888_PIN_2: INJ#2
|
|
|
|
engineConfiguration->injectionPins[5 - 1] = TLE8888_PIN_2;
|
|
|
|
// TLE8888_PIN_1: LED #3 - INJ#1
|
|
|
|
engineConfiguration->injectionPins[6 - 1] = TLE8888_PIN_1;
|
2020-05-21 18:45:01 -07:00
|
|
|
|
|
|
|
|
2020-08-31 14:15:04 -07:00
|
|
|
engineConfiguration->injectionPins[7 - 1] = GPIOA_4; // AV10
|
|
|
|
engineConfiguration->injectionPins[8 - 1] = GPIOB_1; // AV9
|
|
|
|
engineConfiguration->injectionPins[9 - 1] = GPIOB_0; // AV8
|
|
|
|
engineConfiguration->injectionPins[10 - 1] = GPIOC_4; // AV6
|
2020-05-23 07:50:32 -07:00
|
|
|
|
2020-08-31 14:15:04 -07:00
|
|
|
engineConfiguration->injectionPins[11- 1] = TLE8888_PIN_13;
|
2020-05-23 07:50:32 -07:00
|
|
|
|
2020-08-31 14:15:04 -07:00
|
|
|
engineConfiguration->injectionPins[12- 1] = TLE8888_PIN_10;
|
2020-05-21 18:45:01 -07:00
|
|
|
#endif /* BOARD_TLE8888_COUNT */
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
void setBoschHDEV_5_injectors() {
|
2020-10-12 21:35:04 -07:00
|
|
|
// This is the configuration for bosch HDEV 5 injectors
|
2020-11-21 22:14:34 -08:00
|
|
|
// all times in microseconds/us
|
2021-11-17 00:54:21 -08:00
|
|
|
engineConfiguration->mc33_hvolt = 65;
|
|
|
|
engineConfiguration->mc33_i_boost = 13000;
|
|
|
|
engineConfiguration->mc33_i_peak = 9400;
|
|
|
|
engineConfiguration->mc33_i_hold = 3700;
|
|
|
|
engineConfiguration->mc33_t_max_boost = 470;
|
|
|
|
engineConfiguration->mc33_t_peak_off = 10;
|
|
|
|
engineConfiguration->mc33_t_peak_tot = 700;
|
|
|
|
engineConfiguration->mc33_t_bypass = 15;
|
|
|
|
engineConfiguration->mc33_t_hold_off = 60;
|
|
|
|
engineConfiguration->mc33_t_hold_tot = 10000;
|
2020-10-12 21:35:04 -07:00
|
|
|
}
|
|
|
|
|
2021-09-25 23:21:21 -07:00
|
|
|
/**
|
|
|
|
* set engine_type 108
|
|
|
|
*/
|
2021-11-16 01:15:29 -08:00
|
|
|
void setVrThresholdTest() {
|
2021-09-26 00:01:25 -07:00
|
|
|
engineConfiguration->trigger.type = TT_HONDA_1_24;
|
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
setHellenDefaultVrThresholds();
|
2021-09-25 23:21:21 -07:00
|
|
|
engineConfiguration->vrThreshold[0].pin = GPIOB_4;
|
2021-10-02 12:18:45 -07:00
|
|
|
|
|
|
|
engineConfiguration->triggerInputPins[0] = GPIOA_5;
|
|
|
|
engineConfiguration->triggerInputPins[1] = GPIOC_6;
|
2021-09-25 23:21:21 -07:00
|
|
|
}
|
|
|
|
|
2021-07-21 16:55:14 -07:00
|
|
|
/**
|
|
|
|
* set engine_type 107
|
|
|
|
*/
|
2021-11-16 01:15:29 -08:00
|
|
|
void setRotary() {
|
2021-07-21 16:55:14 -07:00
|
|
|
engineConfiguration->specs.cylindersCount = 2;
|
|
|
|
engineConfiguration->specs.firingOrder = FO_1_2;
|
|
|
|
|
|
|
|
engineConfiguration->trigger.type = TT_36_2_2_2;
|
|
|
|
setOperationMode(engineConfiguration, TWO_STROKE);
|
|
|
|
|
2021-11-17 00:54:21 -08:00
|
|
|
strcpy(engineConfiguration->engineMake, ENGINE_MAKE_MAZDA);
|
|
|
|
strcpy(engineConfiguration->engineCode, "13B");
|
|
|
|
strcpy(engineConfiguration->vehicleName, "test");
|
2021-07-21 16:55:14 -07:00
|
|
|
|
|
|
|
engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS;
|
|
|
|
engineConfiguration->injectionPins[2] = GPIO_UNASSIGNED; // injector in default pinout
|
|
|
|
engineConfiguration->injectionPins[3] = GPIO_UNASSIGNED;
|
|
|
|
|
|
|
|
engineConfiguration->enableTrailingSparks = true;
|
|
|
|
engineConfiguration->trailingCoilPins[0] = GPIOC_9;
|
|
|
|
engineConfiguration->trailingCoilPins[1] = GPIOE_10;
|
|
|
|
}
|
2020-05-21 18:45:01 -07:00
|
|
|
|
2020-02-25 19:38:08 -08:00
|
|
|
/**
|
|
|
|
* set engine_type 103
|
|
|
|
*/
|
2021-11-16 01:15:29 -08:00
|
|
|
void setTest33816EngineConfiguration() {
|
2020-02-25 18:35:21 -08:00
|
|
|
|
2020-02-25 19:38:08 -08:00
|
|
|
// grey
|
|
|
|
// default spi3mosiPin PB5
|
|
|
|
// white
|
|
|
|
// default spi3misoPin PB4
|
|
|
|
// violet
|
|
|
|
// default spi3sckPin PB3
|
|
|
|
|
|
|
|
|
2021-11-17 00:54:21 -08:00
|
|
|
engineConfiguration->triggerSimulatorPins[0] = GPIO_UNASSIGNED;
|
|
|
|
engineConfiguration->triggerSimulatorPins[1] = GPIO_UNASSIGNED;
|
|
|
|
engineConfiguration->triggerSimulatorPins[2] = GPIO_UNASSIGNED;
|
2020-04-14 16:23:53 -07:00
|
|
|
|
2020-04-15 13:20:18 -07:00
|
|
|
engineConfiguration->injectionPins[0] = GPIOB_9; // #1
|
|
|
|
engineConfiguration->injectionPins[1] = GPIOE_2; // #2
|
|
|
|
engineConfiguration->injectionPins[2] = GPIOB_8; // #3
|
|
|
|
engineConfiguration->injectionPins[3] = GPIOB_7; // #4
|
|
|
|
|
|
|
|
|
2020-02-25 19:38:08 -08:00
|
|
|
// blue
|
2021-11-17 00:54:21 -08:00
|
|
|
engineConfiguration->mc33816_cs = GPIOD_7;
|
2020-02-25 19:38:08 -08:00
|
|
|
// green
|
2021-11-17 00:54:21 -08:00
|
|
|
engineConfiguration->mc33816_rstb = GPIOD_4;
|
2020-02-25 19:38:08 -08:00
|
|
|
// yellow
|
2021-11-17 00:54:21 -08:00
|
|
|
engineConfiguration->mc33816_driven = GPIOD_6;
|
2020-02-25 18:35:21 -08:00
|
|
|
|
2021-11-17 00:54:21 -08:00
|
|
|
engineConfiguration->mc33816_flag0 = GPIOD_3;
|
2020-04-13 16:01:22 -07:00
|
|
|
|
2020-02-25 19:38:08 -08:00
|
|
|
// enable_spi 3
|
2021-11-17 00:54:21 -08:00
|
|
|
engineConfiguration->is_enabled_spi_3 = true;
|
2020-02-25 19:38:08 -08:00
|
|
|
// Wire up spi3
|
|
|
|
engineConfiguration->spi3mosiPin = GPIOB_5;
|
|
|
|
engineConfiguration->spi3misoPin = GPIOB_4;
|
|
|
|
engineConfiguration->spi3sckPin = GPIOB_3;
|
|
|
|
|
2021-11-17 00:54:21 -08:00
|
|
|
engineConfiguration->isSdCardEnabled = false;
|
2020-02-25 18:35:21 -08:00
|
|
|
|
2021-11-17 00:54:21 -08:00
|
|
|
engineConfiguration->mc33816spiDevice = SPI_DEVICE_3;
|
2021-11-16 01:15:29 -08:00
|
|
|
setBoschHDEV_5_injectors();
|
2020-02-25 18:35:21 -08:00
|
|
|
}
|
2021-04-10 20:30:36 -07:00
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
void setHellen72etb() {
|
2021-11-17 00:54:21 -08:00
|
|
|
engineConfiguration->etbIo[0].directionPin1 = GPIOC_6;
|
|
|
|
engineConfiguration->etbIo[0].directionPin2 = GPIOC_7;
|
2021-04-10 20:30:36 -07:00
|
|
|
engineConfiguration->etb_use_two_wires = true;
|
|
|
|
}
|
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
void setHellenDefaultVrThresholds() {
|
2021-09-17 18:23:54 -07:00
|
|
|
for (int i = 0;i<VR_THRESHOLD_COUNT;i++) {
|
2021-09-18 19:12:22 -07:00
|
|
|
setLinearCurve(engineConfiguration->vrThreshold[i].rpmBins, 600 / RPM_1_BYTE_PACKING_MULT, 7000 / RPM_1_BYTE_PACKING_MULT, 100 / RPM_1_BYTE_PACKING_MULT);
|
2021-09-18 18:27:17 -07:00
|
|
|
setLinearCurve(engineConfiguration->vrThreshold[i].values, PACK_PERCENT_BYTE_MULT * 0.6, PACK_PERCENT_BYTE_MULT * 1.2, PACK_PERCENT_BYTE_MULT * 0.1);
|
2021-09-17 18:23:54 -07:00
|
|
|
}
|
|
|
|
}
|
2021-09-29 08:47:04 -07:00
|
|
|
|
2021-11-14 13:04:44 -08:00
|
|
|
/**
|
|
|
|
* set engine_type 6
|
|
|
|
*/
|
2021-11-16 01:15:29 -08:00
|
|
|
void proteusHarley() {
|
2021-11-14 09:51:41 -08:00
|
|
|
strcpy(engineConfiguration->scriptSettingName[0], "compReleaseRpm");
|
|
|
|
engineConfiguration->scriptSetting[0] = 300;
|
|
|
|
strcpy(engineConfiguration->scriptSettingName[1], "compReleaseDur");
|
|
|
|
engineConfiguration->scriptSetting[1] = 5000;
|
|
|
|
|
2021-11-24 19:25:23 -08:00
|
|
|
// for now we need non wired camInput to keep TS field enable/disable logic happy
|
|
|
|
engineConfiguration->camInputs[0] = PROTEUS_DIGITAL_6;
|
|
|
|
engineConfiguration->vvtMode[0] = VVT_MAP_V_TWIN;
|
2021-11-14 09:51:41 -08:00
|
|
|
|
2021-11-14 07:02:28 -08:00
|
|
|
engineConfiguration->luaOutputPins[0] = PROTEUS_LS_12;
|
2021-11-13 01:24:53 -08:00
|
|
|
#if HW_PROTEUS
|
|
|
|
strncpy(config->luaScript, R"(
|
2021-11-14 13:04:44 -08:00
|
|
|
outputIndex = 0
|
|
|
|
startPwm(outputIndex, 100, 0)
|
|
|
|
|
|
|
|
rpmLimitSetting = findSetting("compReleaseRpm", 300)
|
|
|
|
compReleaseDulationLimit = findSetting("compReleaseDur", 6000)
|
|
|
|
|
2021-11-22 10:00:16 -08:00
|
|
|
every200msTimer = Timer.new();
|
|
|
|
everySecondTimer = Timer.new();
|
2021-11-25 06:06:50 -08:00
|
|
|
every50msTimer = Timer.new();
|
|
|
|
offCounter = 0
|
2021-11-22 10:00:16 -08:00
|
|
|
-- cranking!
|
2021-11-25 06:06:50 -08:00
|
|
|
packet542 = {0x20, 0x82, 0x81, 0xd9, 0x00, 0x00, 0x00, 0x00}
|
2021-11-22 11:29:48 -08:00
|
|
|
packet543 = {0x13, 0x57, 0x13, 0x45, 0x00, 0xe8, 0x00, 0x00}
|
2021-11-25 06:06:50 -08:00
|
|
|
packet541 = {0x00, 0x00, 0x00, 0x00, 0x00, 0x45, 0x00, 0xFF}
|
2021-11-22 10:00:16 -08:00
|
|
|
|
|
|
|
-- every 200ms
|
|
|
|
packet540 = {0x00, 0x00, 0x5a, 0x4c, 0xff, 0x00, 0x00, 0x00}
|
|
|
|
|
|
|
|
-- every 1000ms
|
|
|
|
packet502 = {0x01}
|
|
|
|
packet546 = {0x35, 0x48, 0x44, 0x31, 0x46, 0x48}
|
|
|
|
packet547 = {0x50, 0x41, 0x31, 0x4b, 0x42, 0x36}
|
|
|
|
packet548 = {0x33, 0x34, 0x38, 0x32, 0x32, 0x00}
|
|
|
|
|
2021-11-22 11:29:48 -08:00
|
|
|
counter543 = 0;
|
2021-11-25 06:06:50 -08:00
|
|
|
setTickRate(66);
|
2021-11-22 11:29:48 -08:00
|
|
|
|
2021-11-25 06:06:50 -08:00
|
|
|
canRxAdd(0x570)
|
|
|
|
canRxAdd(0x500)
|
2021-11-22 10:00:16 -08:00
|
|
|
|
2021-11-25 06:06:50 -08:00
|
|
|
function onCanRx(bus, id, dlc, data)
|
|
|
|
--print('got CAN id=' .. id .. ' dlc=' .. dlc)
|
|
|
|
id11 = id % 2048
|
2021-11-22 14:33:28 -08:00
|
|
|
|
2021-11-25 06:06:50 -08:00
|
|
|
if id11 == 0x500 then --Check can state of BCM
|
|
|
|
canState = data[1]
|
|
|
|
if canState == 01 then
|
|
|
|
packet502[1] = 0x01
|
|
|
|
else
|
|
|
|
packet502[1] = 0x00
|
|
|
|
end
|
|
|
|
if id11 == 0x570 then
|
|
|
|
curState = data[1]
|
|
|
|
if curState == 06 then -- Cranking TODO: MUST ONLY DO THIS ON RPM TILL STARt
|
|
|
|
packet542[2] = 0x82
|
|
|
|
end
|
|
|
|
if curState == 04 then -- Kill off
|
|
|
|
packet542[2] = 0x82
|
|
|
|
end
|
|
|
|
if curState == 01 then -- Kill
|
|
|
|
packet542[2] = 0xA2
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-11-22 14:33:28 -08:00
|
|
|
|
2021-11-22 11:29:48 -08:00
|
|
|
|
2021-11-25 06:06:50 -08:00
|
|
|
function onTick()
|
|
|
|
|
|
|
|
if packet502[1] == 01 then
|
|
|
|
offCounter = 0
|
|
|
|
counter543 = (counter543 + 1) % 64
|
|
|
|
packet543[7] = 64 + counter543
|
|
|
|
packet543[8] = crc8_j1850(packet543, 7)
|
|
|
|
APP = getSensor("AcceleratorPedal")
|
|
|
|
if APP == nil then
|
|
|
|
packet543[5] = 0
|
|
|
|
else
|
|
|
|
packet543[5] = APP *2
|
|
|
|
end
|
|
|
|
|
|
|
|
txCan(1, 0x543, 0, packet543)
|
|
|
|
txCan(1, 0x541, 0, packet541)
|
|
|
|
|
|
|
|
if every200msTimer:getElapsedSeconds() > 0.2 then
|
2021-11-22 10:00:16 -08:00
|
|
|
every200msTimer:reset();
|
2021-11-25 06:06:50 -08:00
|
|
|
txCan(1, 0x540, 0, packet540)
|
2021-11-22 10:00:16 -08:00
|
|
|
end
|
|
|
|
|
2021-11-25 06:06:50 -08:00
|
|
|
if every50msTimer:getElapsedSeconds() > 0.05 then
|
|
|
|
every50msTimer:reset();
|
|
|
|
txCan(1, 0x542, 0, packet542)
|
|
|
|
end
|
|
|
|
|
2021-11-22 10:00:16 -08:00
|
|
|
if everySecondTimer:getElapsedSeconds() > 1 then
|
|
|
|
everySecondTimer:reset();
|
2021-11-25 06:06:50 -08:00
|
|
|
txCan(1, 0x502, 0, packet502)
|
|
|
|
txCan(1, 0x546, 0, packet546)
|
|
|
|
txCan(1, 0x547, 0, packet547)
|
|
|
|
txCan(1, 0x548, 0, packet548)
|
2021-11-22 10:00:16 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2021-11-13 01:24:53 -08:00
|
|
|
rpm = getSensor("RPM")
|
|
|
|
-- handle nil RPM, todo: change firmware to avoid nil RPM
|
|
|
|
rpm = (rpm == nil and 0 or rpm)
|
2021-11-25 06:06:50 -08:00
|
|
|
--print('Rpm ' .. rpm)
|
|
|
|
--print('getTimeSinceTriggerEventMs ' .. getTimeSinceTriggerEventMs())
|
2021-11-14 13:04:44 -08:00
|
|
|
enableCompressionReleaseSolenoid = getTimeSinceTriggerEventMs() < compReleaseDulationLimit and rpm < rpmLimitSetting
|
2021-11-26 11:41:35 -08:00
|
|
|
duty = enableCompressionReleaseSolenoid and 1 or 0
|
2021-11-14 13:04:44 -08:00
|
|
|
print("Compression release solenoid " .. duty)
|
|
|
|
setPwmDuty(outputIndex, duty)
|
2021-11-25 06:06:50 -08:00
|
|
|
else
|
|
|
|
if offCounter == 0 then --goodbye sweet love
|
|
|
|
txCan(1, 0x502, 0, packet502) --goodbye
|
|
|
|
offCounter = 1 --One shot
|
|
|
|
end
|
|
|
|
end
|
2021-11-13 01:24:53 -08:00
|
|
|
end
|
|
|
|
)", efi::size(config->luaScript));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
void proteusLuaDemo() {
|
2021-11-08 14:31:17 -08:00
|
|
|
#if HW_PROTEUS
|
|
|
|
engineConfiguration->tpsMin = 889;
|
|
|
|
engineConfiguration->tpsMax = 67;
|
|
|
|
|
|
|
|
engineConfiguration->tps1SecondaryMin = 105;
|
|
|
|
engineConfiguration->tps1SecondaryMax = 933;
|
|
|
|
|
2021-11-10 19:27:21 -08:00
|
|
|
strcpy(engineConfiguration->scriptCurveName[2 - 1], "rateofchange");
|
|
|
|
|
2021-11-08 14:31:17 -08:00
|
|
|
strcpy(engineConfiguration->scriptCurveName[3 - 1], "bias");
|
|
|
|
|
|
|
|
/**
|
|
|
|
* for this demo I use ETB just a sample object to control with PID. No reasonable person should consider actually using
|
|
|
|
* Lua for actual intake ETB control while driving around the racing track - hard-coded ETB control is way smarter!
|
|
|
|
*/
|
|
|
|
static const float defaultBiasBins[] = {
|
|
|
|
0, 1, 2, 4, 7, 98, 99, 100
|
|
|
|
};
|
|
|
|
static const float defaultBiasValues[] = {
|
|
|
|
-20, -18, -17, 0, 20, 21, 22, 25
|
|
|
|
};
|
|
|
|
|
|
|
|
engineConfiguration->luaOutputPins[0] = GPIOD_12;
|
2021-11-08 18:29:09 -08:00
|
|
|
engineConfiguration->luaOutputPins[1] = GPIOD_10;
|
|
|
|
engineConfiguration->luaOutputPins[2] = GPIOD_11;
|
2021-11-08 14:31:17 -08:00
|
|
|
|
2021-11-17 00:54:21 -08:00
|
|
|
setLinearCurve(engineConfiguration->scriptCurve2Bins, 0, 8000, 1);
|
|
|
|
setLinearCurve(engineConfiguration->scriptCurve2, 0, 100, 1);
|
2021-11-10 19:27:21 -08:00
|
|
|
|
2021-11-17 00:54:21 -08:00
|
|
|
copyArray(engineConfiguration->scriptCurve3Bins, defaultBiasBins);
|
|
|
|
copyArray(engineConfiguration->scriptCurve3, defaultBiasValues);
|
2021-11-08 14:31:17 -08:00
|
|
|
|
2021-11-10 19:27:21 -08:00
|
|
|
engineConfiguration->auxAnalogInputs[0] = PROTEUS_IN_ANALOG_VOLT_10;
|
|
|
|
engineConfiguration->afr.hwChannel = EFI_ADC_NONE;
|
2021-11-08 14:31:17 -08:00
|
|
|
|
2021-11-11 21:19:33 -08:00
|
|
|
|
2021-11-08 14:31:17 -08:00
|
|
|
// ETB direction #1 PD10
|
2021-11-11 21:19:33 -08:00
|
|
|
engineConfiguration->etbIo[0].directionPin1 = GPIO_UNASSIGNED;
|
2021-11-08 14:31:17 -08:00
|
|
|
// ETB control PD12
|
2021-11-11 21:19:33 -08:00
|
|
|
engineConfiguration->etbIo[0].controlPin = GPIO_UNASSIGNED;
|
2021-11-08 14:31:17 -08:00
|
|
|
// ETB disable PD11
|
2021-11-11 21:19:33 -08:00
|
|
|
engineConfiguration->etbIo[0].disablePin = GPIO_UNASSIGNED;
|
2021-11-08 14:31:17 -08:00
|
|
|
|
2021-11-12 10:45:07 -08:00
|
|
|
/**
|
2021-11-11 21:19:33 -08:00
|
|
|
controlIndex = 0
|
|
|
|
directionIndex = 1
|
|
|
|
|
2021-11-12 10:45:07 -08:00
|
|
|
print('pid output ' .. output)
|
|
|
|
print('')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local duty = (bias + output) / 100
|
|
|
|
|
|
|
|
-- isPositive = duty > 0;
|
|
|
|
-- pwmValue = isPositive and duty or -duty
|
|
|
|
-- setPwmDuty(controlIndex, pwmValue)
|
|
|
|
|
|
|
|
-- dirValue = isPositive and 1 or 0;
|
|
|
|
-- setPwmDuty(directionIndex, dirValue)
|
|
|
|
|
|
|
|
-- print('pwm ' .. pwmValue .. ' dir ' .. dirValue)
|
|
|
|
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
auto script = R"(
|
|
|
|
|
2021-11-11 16:16:04 -08:00
|
|
|
startPwm(0, 800, 0.1)
|
2021-11-08 18:29:09 -08:00
|
|
|
-- direction
|
|
|
|
startPwm(1, 80, 1.0)
|
|
|
|
-- disable
|
|
|
|
startPwm(2, 80, 0.0)
|
|
|
|
|
2021-11-13 00:18:16 -08:00
|
|
|
pid = Pid.new(2, 0, 0, -100, 100)
|
2021-11-11 16:16:04 -08:00
|
|
|
|
2021-11-11 21:19:33 -08:00
|
|
|
biasCurveIndex = findCurveIndex("bias")
|
|
|
|
|
2021-11-13 13:41:20 -08:00
|
|
|
voltageFromCan = nil
|
|
|
|
canRxAdd(0x600)
|
|
|
|
|
|
|
|
function onCanRx(bus, id, dlc, data)
|
|
|
|
print('got CAN id=' .. id .. ' dlc=' .. dlc)
|
|
|
|
voltageFromCan = data[2] / 256.0 + data[1]
|
2021-11-13 01:44:04 -08:00
|
|
|
end
|
|
|
|
|
2021-11-08 18:29:09 -08:00
|
|
|
function onTick()
|
2021-11-12 10:11:32 -08:00
|
|
|
local targetVoltage = getAuxAnalog(0)
|
2021-11-11 16:16:04 -08:00
|
|
|
|
2021-11-13 13:41:20 -08:00
|
|
|
-- local target = interpolate(1, 0, 3.5, 100, targetVoltage)
|
|
|
|
local target = interpolate(1, 0, 3.5, 100, voltageFromCan)
|
2021-11-11 16:16:04 -08:00
|
|
|
-- clamp 0 to 100
|
|
|
|
target = math.max(0, target)
|
|
|
|
target = math.min(100, target)
|
|
|
|
|
|
|
|
print('Decoded target: ' .. target)
|
|
|
|
|
2021-11-12 10:11:32 -08:00
|
|
|
local tps = getSensor("TPS1")
|
2021-11-11 16:16:04 -08:00
|
|
|
tps = (tps == nil and 'invalid TPS' or tps)
|
|
|
|
print('Tps ' .. tps)
|
|
|
|
|
2021-11-13 00:18:16 -08:00
|
|
|
local output = pid:get(target, tps)
|
2021-11-11 16:16:04 -08:00
|
|
|
|
2021-11-12 10:11:32 -08:00
|
|
|
local bias = curve(biasCurveIndex, target)
|
2021-11-11 21:19:33 -08:00
|
|
|
print('bias ' .. bias)
|
|
|
|
|
2021-11-13 07:02:45 -08:00
|
|
|
local duty = (bias + output) / 100
|
|
|
|
isPositive = duty > 0;
|
|
|
|
pwmValue = isPositive and duty or -duty
|
|
|
|
setPwmDuty(0, pwmValue)
|
|
|
|
|
|
|
|
dirValue = isPositive and 1 or 0;
|
|
|
|
setPwmDuty(1, dirValue)
|
|
|
|
|
|
|
|
print('pwm ' .. pwmValue .. ' dir ' .. dirValue)
|
2021-11-11 16:16:04 -08:00
|
|
|
print('')
|
2021-11-08 18:29:09 -08:00
|
|
|
end
|
2021-11-08 14:31:17 -08:00
|
|
|
)";
|
2021-11-11 16:16:04 -08:00
|
|
|
strncpy(config->luaScript, script, efi::size(config->luaScript));
|
2021-11-08 14:31:17 -08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-09-29 08:52:54 -07:00
|
|
|
#if HW_HELLEN
|
2021-11-16 01:15:29 -08:00
|
|
|
void setHellen144LedPins() {
|
2021-09-29 08:47:04 -07:00
|
|
|
#ifdef EFI_COMMUNICATION_PIN
|
|
|
|
engineConfiguration->communicationLedPin = EFI_COMMUNICATION_PIN;
|
|
|
|
#else
|
|
|
|
engineConfiguration->communicationLedPin = GPIOE_7;
|
|
|
|
#endif /* EFI_COMMUNICATION_PIN */
|
|
|
|
engineConfiguration->runningLedPin = GPIOG_1;
|
|
|
|
engineConfiguration->warningLedPin = GPIOE_8;
|
|
|
|
}
|
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
void setHellen176LedPins() {
|
2021-09-29 08:47:04 -07:00
|
|
|
#ifdef EFI_COMMUNICATION_PIN
|
|
|
|
engineConfiguration->communicationLedPin = EFI_COMMUNICATION_PIN;
|
|
|
|
#else
|
|
|
|
engineConfiguration->communicationLedPin = GPIOH_10;
|
|
|
|
#endif /* EFI_COMMUNICATION_PIN */
|
|
|
|
engineConfiguration->runningLedPin = GPIOH_9; // green
|
|
|
|
engineConfiguration->warningLedPin = GPIOH_11; // yellow
|
|
|
|
}
|
2021-09-29 08:52:54 -07:00
|
|
|
#endif //HW_HELLEN
|