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

191 lines
11 KiB
C++
Raw Normal View History

2016-01-04 02:02:45 -08:00
/*
* @file ford_festiva.cpp
*
* @date Jan 3, 2016
* @author Andrey Belomutskiy, (c) 2012-2016
*/
#include "ford_festiva.h"
#include "thermistors.h"
#include "engine_math.h"
#include "maf.h"
#include "ego.h"
#include "fsio_impl.h"
#include "mazda_miata.h"
// this is about LCD method, TODO FIX IT FINALLY
#include "honda_accord.h"
static const fuel_table_t racingFestivaVeTable = {
/* Generated by TS2C on Sun Jan 03 13:19:39 EST 2016*/
{/* 0 10.000 *//* 0 800.0*/80.000, /* 1 1213.0*/81.095, /* 2 1626.0*/80.804, /* 3 2040.0*/80.281, /* 4 2453.0*/84.913, /* 5 2866.0*/87.951, /* 6 3280.0*/86.559, /* 7 3693.0*/92.322, /* 8 4106.0*/101.472, /* 9 4520.0*/108.560, /* 10 4933.0*/97.070, /* 11 5346.0*/85.638, /* 12 5760.0*/80.000, /* 13 6173.0*/80.000, /* 14 6586.0*/80.000, /* 15 7000.0*/80.000, },
{/* 1 20.000 *//* 0 800.0*/83.041, /* 1 1213.0*/85.975, /* 2 1626.0*/83.660, /* 3 2040.0*/85.078, /* 4 2453.0*/80.952, /* 5 2866.0*/85.848, /* 6 3280.0*/93.882, /* 7 3693.0*/102.314, /* 8 4106.0*/105.739, /* 9 4520.0*/106.285, /* 10 4933.0*/97.692, /* 11 5346.0*/84.264, /* 12 5760.0*/79.396, /* 13 6173.0*/79.415, /* 14 6586.0*/80.000, /* 15 7000.0*/80.000, },
{/* 2 30.000 *//* 0 800.0*/91.545, /* 1 1213.0*/90.546, /* 2 1626.0*/92.650, /* 3 2040.0*/95.962, /* 4 2453.0*/87.726, /* 5 2866.0*/87.472, /* 6 3280.0*/108.217, /* 7 3693.0*/114.407, /* 8 4106.0*/122.453, /* 9 4520.0*/117.908, /* 10 4933.0*/108.049, /* 11 5346.0*/96.007, /* 12 5760.0*/80.689, /* 13 6173.0*/79.261, /* 14 6586.0*/80.000, /* 15 7000.0*/80.000, },
{/* 3 40.000 *//* 0 800.0*/97.846, /* 1 1213.0*/101.259, /* 2 1626.0*/101.530, /* 3 2040.0*/106.327, /* 4 2453.0*/100.647, /* 5 2866.0*/100.725, /* 6 3280.0*/110.761, /* 7 3693.0*/111.219, /* 8 4106.0*/116.909, /* 9 4520.0*/114.285, /* 10 4933.0*/109.984, /* 11 5346.0*/96.081, /* 12 5760.0*/84.977, /* 13 6173.0*/85.682, /* 14 6586.0*/85.000, /* 15 7000.0*/85.000, },
{/* 4 50.000 *//* 0 800.0*/96.750, /* 1 1213.0*/97.932, /* 2 1626.0*/97.034, /* 3 2040.0*/104.922, /* 4 2453.0*/108.613, /* 5 2866.0*/98.351, /* 6 3280.0*/102.503, /* 7 3693.0*/104.539, /* 8 4106.0*/105.938, /* 9 4520.0*/102.396, /* 10 4933.0*/101.258, /* 11 5346.0*/87.967, /* 12 5760.0*/85.000, /* 13 6173.0*/85.000, /* 14 6586.0*/85.000, /* 15 7000.0*/85.000, },
{/* 5 60.000 *//* 0 800.0*/98.313, /* 1 1213.0*/89.631, /* 2 1626.0*/85.921, /* 3 2040.0*/104.913, /* 4 2453.0*/101.274, /* 5 2866.0*/98.829, /* 6 3280.0*/92.713, /* 7 3693.0*/91.545, /* 8 4106.0*/93.931, /* 9 4520.0*/85.000, /* 10 4933.0*/85.000, /* 11 5346.0*/85.000, /* 12 5760.0*/85.000, /* 13 6173.0*/85.000, /* 14 6586.0*/85.000, /* 15 7000.0*/85.000, },
{/* 6 70.000 *//* 0 800.0*/85.174, /* 1 1213.0*/84.487, /* 2 1626.0*/94.611, /* 3 2040.0*/92.700, /* 4 2453.0*/91.909, /* 5 2866.0*/90.979, /* 6 3280.0*/100.000, /* 7 3693.0*/100.000, /* 8 4106.0*/100.000, /* 9 4520.0*/100.000, /* 10 4933.0*/100.000, /* 11 5346.0*/100.000, /* 12 5760.0*/100.000, /* 13 6173.0*/100.000, /* 14 6586.0*/100.000, /* 15 7000.0*/100.000, },
{/* 7 80.000 *//* 0 800.0*/85.000, /* 1 1213.0*/86.351, /* 2 1626.0*/93.247, /* 3 2040.0*/90.879, /* 4 2453.0*/91.966, /* 5 2866.0*/90.883, /* 6 3280.0*/100.000, /* 7 3693.0*/100.000, /* 8 4106.0*/100.000, /* 9 4520.0*/100.000, /* 10 4933.0*/100.000, /* 11 5346.0*/100.000, /* 12 5760.0*/99.372, /* 13 6173.0*/100.000, /* 14 6586.0*/100.000, /* 15 7000.0*/100.000, },
{/* 8 90.000 *//* 0 800.0*/84.271, /* 1 1213.0*/83.948, /* 2 1626.0*/100.953, /* 3 2040.0*/102.934, /* 4 2453.0*/90.954, /* 5 2866.0*/90.000, /* 6 3280.0*/100.000, /* 7 3693.0*/110.000, /* 8 4106.0*/110.000, /* 9 4520.0*/110.000, /* 10 4933.0*/110.011, /* 11 5346.0*/108.715, /* 12 5760.0*/108.985, /* 13 6173.0*/108.938, /* 14 6586.0*/110.000, /* 15 7000.0*/100.000, },
{/* 9 100.000 *//* 0 800.0*/79.247, /* 1 1213.0*/82.754, /* 2 1626.0*/98.476, /* 3 2040.0*/108.385, /* 4 2453.0*/90.000, /* 5 2866.0*/90.000, /* 6 3280.0*/100.000, /* 7 3693.0*/111.758, /* 8 4106.0*/120.989, /* 9 4520.0*/119.830, /* 10 4933.0*/109.678, /* 11 5346.0*/106.050, /* 12 5760.0*/105.821, /* 13 6173.0*/105.758, /* 14 6586.0*/109.127, /* 15 7000.0*/100.000, },
{/* 10 110.000 *//* 0 800.0*/83.748, /* 1 1213.0*/85.000, /* 2 1626.0*/90.867, /* 3 2040.0*/92.900, /* 4 2453.0*/90.000, /* 5 2866.0*/90.000, /* 6 3280.0*/100.000, /* 7 3693.0*/111.904, /* 8 4106.0*/118.317, /* 9 4520.0*/110.000, /* 10 4933.0*/110.000, /* 11 5346.0*/110.000, /* 12 5760.0*/110.000, /* 13 6173.0*/110.000, /* 14 6586.0*/110.000, /* 15 7000.0*/100.000, },
{/* 11 120.000 *//* 0 800.0*/85.000, /* 1 1213.0*/85.000, /* 2 1626.0*/90.000, /* 3 2040.0*/90.000, /* 4 2453.0*/90.000, /* 5 2866.0*/90.000, /* 6 3280.0*/100.000, /* 7 3693.0*/110.000, /* 8 4106.0*/110.000, /* 9 4520.0*/110.000, /* 10 4933.0*/110.000, /* 11 5346.0*/110.000, /* 12 5760.0*/110.000, /* 13 6173.0*/110.000, /* 14 6586.0*/110.000, /* 15 7000.0*/100.000, },
{/* 12 130.000 *//* 0 800.0*/85.000, /* 1 1213.0*/85.000, /* 2 1626.0*/90.000, /* 3 2040.0*/90.000, /* 4 2453.0*/90.000, /* 5 2866.0*/90.000, /* 6 3280.0*/100.000, /* 7 3693.0*/100.000, /* 8 4106.0*/100.000, /* 9 4520.0*/100.000, /* 10 4933.0*/100.000, /* 11 5346.0*/100.000, /* 12 5760.0*/100.000, /* 13 6173.0*/100.000, /* 14 6586.0*/100.000, /* 15 7000.0*/100.000, },
{/* 13 140.000 *//* 0 800.0*/85.000, /* 1 1213.0*/85.000, /* 2 1626.0*/90.000, /* 3 2040.0*/90.000, /* 4 2453.0*/90.000, /* 5 2866.0*/90.000, /* 6 3280.0*/100.000, /* 7 3693.0*/100.000, /* 8 4106.0*/100.000, /* 9 4520.0*/100.000, /* 10 4933.0*/100.000, /* 11 5346.0*/100.000, /* 12 5760.0*/100.000, /* 13 6173.0*/100.000, /* 14 6586.0*/100.000, /* 15 7000.0*/100.000, },
{/* 14 150.000 *//* 0 800.0*/85.000, /* 1 1213.0*/85.000, /* 2 1626.0*/90.000, /* 3 2040.0*/90.000, /* 4 2453.0*/90.000, /* 5 2866.0*/90.000, /* 6 3280.0*/100.000, /* 7 3693.0*/100.000, /* 8 4106.0*/100.000, /* 9 4520.0*/100.000, /* 10 4933.0*/100.000, /* 11 5346.0*/100.000, /* 12 5760.0*/100.000, /* 13 6173.0*/100.000, /* 14 6586.0*/100.000, /* 15 7000.0*/100.000, },
{/* 15 160.000 *//* 0 800.0*/85.000, /* 1 1213.0*/85.000, /* 2 1626.0*/90.000, /* 3 2040.0*/90.000, /* 4 2453.0*/90.000, /* 5 2866.0*/90.000, /* 6 3280.0*/100.000, /* 7 3693.0*/100.000, /* 8 4106.0*/100.000, /* 9 4520.0*/100.000, /* 10 4933.0*/100.000, /* 11 5346.0*/100.000, /* 12 5760.0*/100.000, /* 13 6173.0*/100.000, /* 14 6586.0*/100.000, /* 15 7000.0*/100.000, },
};
EXTERN_ENGINE;
/**
* pin 1I/W9 - extra +5v
* set_engine_type 14
*/
void setFordEscortGt(DECLARE_ENGINE_PARAMETER_F) {
engineConfiguration->trigger.type = TT_MAZDA_DOHC_1_4;
common079721_2351(engineConfiguration, boardConfiguration);
setFrankenso_01_LCD(boardConfiguration);
setFrankenso0_1_joystick(engineConfiguration);
setDensoTODO(config);
engineConfiguration->globalFuelCorrection = 0.75;
engineConfiguration->specs.displacement = 1.839;
// engineConfiguration->algorithm = LM_PLAIN_MAF;
2016-01-08 12:01:38 -08:00
setAlgorithm(LM_SPEED_DENSITY PASS_ENGINE_PARAMETER);
2016-01-04 02:02:45 -08:00
// engineConfiguration->algorithm = LM_REAL_MAF;
boardConfiguration->tunerStudioSerialSpeed = 14400;
setFuelLoadBin(1.2, 4.4 PASS_ENGINE_PARAMETER);
setFuelRpmBin(800, 7000 PASS_ENGINE_PARAMETER);
copyFuelTable(racingFestivaVeTable, config->veTable);
// boardConfiguration->triggerInputPins[0] = GPIOC_6; // 2G YEL/BLU
// boardConfiguration->triggerInputPins[1] = GPIOA_5; // 2E White CKP
// in case of SOHC distributor we only have one signal
// boardConfiguration->triggerInputPins[0] = GPIOA_5; // 2E White CKP
// boardConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED;
// in case of DOHC distributor we have two signals
boardConfiguration->triggerInputPins[0] = GPIOC_6;
boardConfiguration->triggerInputPins[1] = GPIOA_5; // 2E White CKP
// Denso 195500-2180
engineConfiguration->injector.flow = 265;
engineConfiguration->hasBaroSensor = false;
engineConfiguration->hasMapSensor = true;
boardConfiguration->isFastAdcEnabled = true;
engineConfiguration->map.sensor.type = MT_DENSO183;
engineConfiguration->map.sensor.hwChannel = EFI_ADC_4;
setEgoSensor(ES_Innovate_MTX_L PASS_ENGINE_PARAMETER);
engineConfiguration->afr.hwChannel = EFI_ADC_2; // Frankenso analog #5
// set_idle_position 35
boardConfiguration->manIdlePosition = 35;
// set_global_trigger_offset_angle -40
engineConfiguration->globalTriggerAngleOffset = -40;
// set_ignition_offset 0
engineConfiguration->ignitionOffset = 0;
// set_injection_offset 0
engineConfiguration->injectionOffset = 0;
// todo: change to 15?
// set_cranking_timing_angle 3
engineConfiguration->crankingTimingAngle = 3;
engineConfiguration->crankingChargeAngle = 70;
// set_cranking_fuel 9
engineConfiguration->cranking.baseFuel = 9;
setTableBin2(config->ignitionLoadBins, IGN_LOAD_COUNT, 20, 105, 5);
setWholeTimingTable(10 PASS_ENGINE_PARAMETER);
// set_whole_fuel_map 5
setWholeFuelMap(5 PASS_ENGINE_PARAMETER);
2016-01-13 19:01:30 -08:00
setMap(config->afrTable, 13.5);
2016-01-04 02:02:45 -08:00
setSingleCoilDwell(engineConfiguration);
engineConfiguration->ignitionMode = IM_ONE_COIL;
boardConfiguration->triggerSimulatorPinModes[0] = OM_OPENDRAIN;
boardConfiguration->triggerSimulatorPinModes[1] = OM_OPENDRAIN;
boardConfiguration->ignitionPins[0] = GPIOE_14; // Frankenso high side - pin 1G
boardConfiguration->ignitionPins[1] = GPIO_UNASSIGNED;
boardConfiguration->ignitionPins[2] = GPIO_UNASSIGNED;
boardConfiguration->ignitionPins[3] = GPIO_UNASSIGNED;
boardConfiguration->ignitionPinMode = OM_DEFAULT;
/**
* Outputs
*/
// Frankenso low out #1: PE6
// Frankenso low out #2: PE5 MIL
// Frankenso low out #3:
// Frankenso low out #4:
// Frankenso low out #5: PE3 VICS solenoid
// Frankenso low out #6: PE4
// Frankenso low out #7: PE0<>PD5
// Frankenso low out #8: PE2 INJ
// Frankenso low out #9: PB9 IDLE
// Frankenso low out #10: PE1<>PD3 INJ 1&3
// Frankenso low out #11: PB8
// Frankenso low out #12: PB7
boardConfiguration->injectionPins[0] = GPIOD_3;
boardConfiguration->injectionPins[1] = GPIOE_2;
//setDefaultCrankingFuel(engineConfiguration);
engineConfiguration->cranking.baseFuel = 5;
// 40% idle is good default
boardConfiguration->idle.solenoidFrequency = 300;
boardConfiguration->idle.solenoidPin = GPIOB_9;
boardConfiguration->malfunctionIndicatorPin = GPIOE_5;
boardConfiguration->malfunctionIndicatorPinMode = OM_DEFAULT;
boardConfiguration->tunerStudioSerialSpeed = 9600;
commonFrankensoAnalogInputs(engineConfiguration);
setCommonNTCSensor(&engineConfiguration->clt);
engineConfiguration->clt.config.bias_resistor = 2700;
setCommonNTCSensor(&engineConfiguration->iat);
engineConfiguration->iat.config.bias_resistor = 2700;
// we have a 1999 Auto Miata TB mounted on this car
engineConfiguration->hasTpsSensor = true;
engineConfiguration->tpsMin = 115; // convert 12to10 bit (ADC/4)
engineConfiguration->tpsMax = 630; // convert 12to10 bit (ADC/4)
engineConfiguration->tpsAdcChannel = EFI_ADC_3;
// engineConfiguration->map.sensor.hwChannel = EFI_ADC_4;
engineConfiguration->mafAdcChannel = EFI_ADC_0;
engineConfiguration->clt.adcChannel = EFI_ADC_12;
engineConfiguration->iat.adcChannel = EFI_ADC_11;
// todo: 8.2 or 10k?
engineConfiguration->vbattDividerCoeff = ((float) (10 + 33)) / 10 * 2;
// VICS solenoid
/**
* to test
2016-01-12 19:01:53 -08:00
* set_fsio_setting 0 5000
2016-01-04 02:02:45 -08:00
*/
engineConfiguration->bc.fsio_setting[0] = 5000;
2016-01-12 19:01:53 -08:00
// set_fsio_expression 1 "rpm 0 fsio_setting >"
2016-01-04 02:02:45 -08:00
setFsioExt(0, GPIOE_3, "rpm 0 fsio_setting >", 150 PASS_ENGINE_PARAMETER);
// end of Ford Escort GT config
}