auto-sync
This commit is contained in:
parent
51268c966a
commit
53000a4972
|
@ -27,6 +27,7 @@ void setFordFiestaDefaultEngineConfiguration(DECLARE_ENGINE_PARAMETER_F) {
|
||||||
engineConfiguration->ignitionMode = IM_WASTED_SPARK;
|
engineConfiguration->ignitionMode = IM_WASTED_SPARK;
|
||||||
engineConfiguration->specs.firingOrder = FO_1_THEN_3_THEN_4_THEN2;
|
engineConfiguration->specs.firingOrder = FO_1_THEN_3_THEN_4_THEN2;
|
||||||
engineConfiguration->hasMafSensor = true;
|
engineConfiguration->hasMafSensor = true;
|
||||||
|
engineConfiguration->afr.hwChannel = EFI_ADC_NONE;
|
||||||
engineConfiguration->mafAdcChannel = EFI_ADC_14;
|
engineConfiguration->mafAdcChannel = EFI_ADC_14;
|
||||||
// engineConfiguration->mafAdcChannel = EFI_ADC_NONE; this would kill functional tests
|
// engineConfiguration->mafAdcChannel = EFI_ADC_NONE; this would kill functional tests
|
||||||
|
|
||||||
|
@ -35,6 +36,7 @@ void setFordFiestaDefaultEngineConfiguration(DECLARE_ENGINE_PARAMETER_F) {
|
||||||
// boardConfiguration->clutchUpPin
|
// boardConfiguration->clutchUpPin
|
||||||
boardConfiguration->etbControlPin1 = GPIOD_3;
|
boardConfiguration->etbControlPin1 = GPIOD_3;
|
||||||
engineConfiguration->pedalPositionChannel = EFI_ADC_1;
|
engineConfiguration->pedalPositionChannel = EFI_ADC_1;
|
||||||
|
boardConfiguration->etbDirectionPin2 = GPIOD_5;
|
||||||
|
|
||||||
engineConfiguration->tpsMin = 337;
|
engineConfiguration->tpsMin = 337;
|
||||||
engineConfiguration->tpsMax = 896;
|
engineConfiguration->tpsMax = 896;
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#if EFI_ELECTRONIC_THROTTLE_BODY || defined(__DOXYGEN__)
|
#if EFI_ELECTRONIC_THROTTLE_BODY || defined(__DOXYGEN__)
|
||||||
|
|
||||||
#define ETB_FREQ 400
|
#define ETB_FREQ 400
|
||||||
|
extern pin_output_mode_e DEFAULT_OUTPUT;
|
||||||
|
|
||||||
static LoggingWithStorage logger("ETB");
|
static LoggingWithStorage logger("ETB");
|
||||||
/**
|
/**
|
||||||
|
@ -45,10 +46,13 @@ static THD_WORKING_AREA(etbTreadStack, UTILITY_THREAD_STACK_SIZE);
|
||||||
/**
|
/**
|
||||||
* @brief Pulse-Width Modulation state
|
* @brief Pulse-Width Modulation state
|
||||||
*/
|
*/
|
||||||
static SimplePwm etbPwmUp;
|
static SimplePwm etbPwmUp CCM_OPTIONAL;
|
||||||
static OutputPin output1;
|
static OutputPin output1 CCM_OPTIONAL;
|
||||||
static SimplePwm etbPwmDown;
|
static SimplePwm etbPwmDown CCM_OPTIONAL;
|
||||||
static OutputPin output2;
|
static OutputPin output2 CCM_OPTIONAL;
|
||||||
|
|
||||||
|
static OutputPin outputDirectionOpen CCM_OPTIONAL;
|
||||||
|
static OutputPin outputDirectionClose CCM_OPTIONAL;
|
||||||
|
|
||||||
static Pid pid(1, 0, 0, 0, 100);
|
static Pid pid(1, 0, 0, 0, 100);
|
||||||
|
|
||||||
|
@ -58,16 +62,25 @@ static float currentEtbDuty;
|
||||||
|
|
||||||
EXTERN_ENGINE;
|
EXTERN_ENGINE;
|
||||||
|
|
||||||
|
static bool_t wasEtbBraking = false;
|
||||||
|
|
||||||
static msg_t etbThread(void *arg) {
|
static msg_t etbThread(void *arg) {
|
||||||
UNUSED(arg);
|
UNUSED(arg);
|
||||||
while (true) {
|
while (true) {
|
||||||
float pedal = getPedalPosition(PASS_ENGINE_PARAMETER_F);
|
percent_t pedal = getPedalPosition(PASS_ENGINE_PARAMETER_F);
|
||||||
float tps = getTPS();
|
percent_t tps = getTPS();
|
||||||
|
|
||||||
currentEtbDuty = pid.getValue(pedal, getTPS(), 1);
|
currentEtbDuty = pid.getValue(pedal, getTPS(), 1);
|
||||||
|
|
||||||
etbPwmUp.setSimplePwmDutyCycle(currentEtbDuty / 100);
|
etbPwmUp.setSimplePwmDutyCycle(currentEtbDuty / 100);
|
||||||
|
|
||||||
|
bool_t needEtbBraking = absF(pedal - tps) < 3;
|
||||||
|
if (needEtbBraking != wasEtbBraking) {
|
||||||
|
scheduleMsg(&logger, "need ETB braking: %d", needEtbBraking);
|
||||||
|
wasEtbBraking = needEtbBraking;
|
||||||
|
}
|
||||||
|
outputDirectionClose.setValue(needEtbBraking);
|
||||||
|
|
||||||
|
|
||||||
// if (tps != prevTps) {
|
// if (tps != prevTps) {
|
||||||
// prevTps = tps;
|
// prevTps = tps;
|
||||||
|
@ -96,10 +109,11 @@ static void showEthInfo(void) {
|
||||||
scheduleMsg(&logger, "pedal=%f %d/%d @", getPedalPosition(), engineConfiguration->pedalPositionMin, engineConfiguration->pedalPositionMax,
|
scheduleMsg(&logger, "pedal=%f %d/%d @", getPedalPosition(), engineConfiguration->pedalPositionMin, engineConfiguration->pedalPositionMax,
|
||||||
getPinNameByAdcChannel(engineConfiguration->pedalPositionChannel, pinNameBuffer));
|
getPinNameByAdcChannel(engineConfiguration->pedalPositionChannel, pinNameBuffer));
|
||||||
|
|
||||||
scheduleMsg(&logger, "tsp=%f", getTPS());
|
scheduleMsg(&logger, "TPS=%f", getTPS());
|
||||||
|
|
||||||
scheduleMsg(&logger, "etbControlPin1=%s duty=%f", hwPortname(boardConfiguration->etbControlPin1),
|
scheduleMsg(&logger, "etbControlPin1=%s duty=%f", hwPortname(boardConfiguration->etbControlPin1),
|
||||||
currentEtbDuty);
|
currentEtbDuty);
|
||||||
|
scheduleMsg(&logger, "close dir=%s", hwPortname(boardConfiguration->etbDirectionPin2));
|
||||||
scheduleMsg(&logger, "etb P=%f I=%f D=%f dT=%d", boardConfiguration->etbPFactor,
|
scheduleMsg(&logger, "etb P=%f I=%f D=%f dT=%d", boardConfiguration->etbPFactor,
|
||||||
boardConfiguration->etbIFactor,
|
boardConfiguration->etbIFactor,
|
||||||
0.0,
|
0.0,
|
||||||
|
@ -152,6 +166,9 @@ void initElectronicThrottle(void) {
|
||||||
0.80,
|
0.80,
|
||||||
applyPinState);
|
applyPinState);
|
||||||
|
|
||||||
|
outputPinRegisterExt2("etb dir open", &outputDirectionOpen, boardConfiguration->etbDirectionPin1, &DEFAULT_OUTPUT);
|
||||||
|
outputPinRegisterExt2("etb dir close", &outputDirectionClose, boardConfiguration->etbDirectionPin2, &DEFAULT_OUTPUT);
|
||||||
|
|
||||||
addConsoleActionI("e", setThrottleConsole);
|
addConsoleActionI("e", setThrottleConsole);
|
||||||
|
|
||||||
addConsoleAction("ethinfo", showEthInfo);
|
addConsoleAction("ethinfo", showEthInfo);
|
||||||
|
|
Loading…
Reference in New Issue