auto-sync

This commit is contained in:
rusEfi 2015-07-10 20:01:36 -04:00
parent 51268c966a
commit 53000a4972
2 changed files with 26 additions and 7 deletions

View File

@ -27,6 +27,7 @@ void setFordFiestaDefaultEngineConfiguration(DECLARE_ENGINE_PARAMETER_F) {
engineConfiguration->ignitionMode = IM_WASTED_SPARK;
engineConfiguration->specs.firingOrder = FO_1_THEN_3_THEN_4_THEN2;
engineConfiguration->hasMafSensor = true;
engineConfiguration->afr.hwChannel = EFI_ADC_NONE;
engineConfiguration->mafAdcChannel = EFI_ADC_14;
// engineConfiguration->mafAdcChannel = EFI_ADC_NONE; this would kill functional tests
@ -35,6 +36,7 @@ void setFordFiestaDefaultEngineConfiguration(DECLARE_ENGINE_PARAMETER_F) {
// boardConfiguration->clutchUpPin
boardConfiguration->etbControlPin1 = GPIOD_3;
engineConfiguration->pedalPositionChannel = EFI_ADC_1;
boardConfiguration->etbDirectionPin2 = GPIOD_5;
engineConfiguration->tpsMin = 337;
engineConfiguration->tpsMax = 896;

View File

@ -36,6 +36,7 @@
#if EFI_ELECTRONIC_THROTTLE_BODY || defined(__DOXYGEN__)
#define ETB_FREQ 400
extern pin_output_mode_e DEFAULT_OUTPUT;
static LoggingWithStorage logger("ETB");
/**
@ -45,10 +46,13 @@ static THD_WORKING_AREA(etbTreadStack, UTILITY_THREAD_STACK_SIZE);
/**
* @brief Pulse-Width Modulation state
*/
static SimplePwm etbPwmUp;
static OutputPin output1;
static SimplePwm etbPwmDown;
static OutputPin output2;
static SimplePwm etbPwmUp CCM_OPTIONAL;
static OutputPin output1 CCM_OPTIONAL;
static SimplePwm etbPwmDown CCM_OPTIONAL;
static OutputPin output2 CCM_OPTIONAL;
static OutputPin outputDirectionOpen CCM_OPTIONAL;
static OutputPin outputDirectionClose CCM_OPTIONAL;
static Pid pid(1, 0, 0, 0, 100);
@ -58,16 +62,25 @@ static float currentEtbDuty;
EXTERN_ENGINE;
static bool_t wasEtbBraking = false;
static msg_t etbThread(void *arg) {
UNUSED(arg);
while (true) {
float pedal = getPedalPosition(PASS_ENGINE_PARAMETER_F);
float tps = getTPS();
percent_t pedal = getPedalPosition(PASS_ENGINE_PARAMETER_F);
percent_t tps = getTPS();
currentEtbDuty = pid.getValue(pedal, getTPS(), 1);
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) {
// prevTps = tps;
@ -96,10 +109,11 @@ static void showEthInfo(void) {
scheduleMsg(&logger, "pedal=%f %d/%d @", getPedalPosition(), engineConfiguration->pedalPositionMin, engineConfiguration->pedalPositionMax,
getPinNameByAdcChannel(engineConfiguration->pedalPositionChannel, pinNameBuffer));
scheduleMsg(&logger, "tsp=%f", getTPS());
scheduleMsg(&logger, "TPS=%f", getTPS());
scheduleMsg(&logger, "etbControlPin1=%s duty=%f", hwPortname(boardConfiguration->etbControlPin1),
currentEtbDuty);
scheduleMsg(&logger, "close dir=%s", hwPortname(boardConfiguration->etbDirectionPin2));
scheduleMsg(&logger, "etb P=%f I=%f D=%f dT=%d", boardConfiguration->etbPFactor,
boardConfiguration->etbIFactor,
0.0,
@ -152,6 +166,9 @@ void initElectronicThrottle(void) {
0.80,
applyPinState);
outputPinRegisterExt2("etb dir open", &outputDirectionOpen, boardConfiguration->etbDirectionPin1, &DEFAULT_OUTPUT);
outputPinRegisterExt2("etb dir close", &outputDirectionClose, boardConfiguration->etbDirectionPin2, &DEFAULT_OUTPUT);
addConsoleActionI("e", setThrottleConsole);
addConsoleAction("ethinfo", showEthInfo);