Esempio n. 1
0
static void configureInputs(void) {
	memset(adcHwChannelEnabled, 0, sizeof(adcHwChannelEnabled));
	memset(adcHwChannelUsage, 0, sizeof(adcHwChannelUsage));

	addChannel("MAP", engineConfiguration->map.sensor.hwChannel, ADC_FAST);
	if (hasMafSensor()) {
		addChannel("MAF", engineConfiguration->mafAdcChannel, ADC_FAST);
	}
	addChannel("hip", engineConfiguration->hipOutputChannel, ADC_FAST);

	addChannel("TPS", engineConfiguration->tpsAdcChannel, ADC_SLOW);
	addChannel("fuel", engineConfiguration->fuelLevelSensor, ADC_SLOW);
	addChannel("pPS", engineConfiguration->pedalPositionAdcChannel, ADC_SLOW);
	addChannel("VBatt", engineConfiguration->vbattAdcChannel, ADC_SLOW);
	// not currently used	addChannel("Vref", engineConfiguration->vRefAdcChannel, ADC_SLOW);
	addChannel("CLT", engineConfiguration->clt.adcChannel, ADC_SLOW);
	addChannel("IAT", engineConfiguration->iat.adcChannel, ADC_SLOW);
	addChannel("AFR", engineConfiguration->afr.hwChannel, ADC_SLOW);
	addChannel("OilP", engineConfiguration->oilPressure.hwChannel, ADC_SLOW);
	addChannel("AC", engineConfiguration->acSwitchAdc, ADC_SLOW);

	if (CONFIGB(isCJ125Enabled)) {
		addChannel("cj125ur", engineConfiguration->cj125ur, ADC_SLOW);
		addChannel("cj125ua", engineConfiguration->cj125ua, ADC_SLOW);
	}

	for (int i = 0; i < FSIO_ANALOG_INPUT_COUNT ; i++) {
		addChannel("FSIOadc", engineConfiguration->fsioAdc[i], ADC_SLOW);
	}
}
Esempio n. 2
0
static void printAnalogInfo(void) {
	scheduleMsg(&logger, "analogInputDividerCoefficient: %f", engineConfiguration->analogInputDividerCoefficient);

	printAnalogChannelInfo("hip9011", engineConfiguration->hipOutputChannel);
	printAnalogChannelInfo("fuel gauge", engineConfiguration->fuelLevelSensor);
	printAnalogChannelInfo("TPS", engineConfiguration->tpsAdcChannel);
	printAnalogChannelInfo("pPS", engineConfiguration->pedalPositionChannel);
	if (engineConfiguration->clt.adcChannel != EFI_ADC_NONE) {
		printAnalogChannelInfo("CLT", engineConfiguration->clt.adcChannel);
	}
	if (engineConfiguration->iat.adcChannel != EFI_ADC_NONE) {
		printAnalogChannelInfo("IAT", engineConfiguration->iat.adcChannel);
	}
	if (hasMafSensor()) {
		printAnalogChannelInfo("MAF", engineConfiguration->mafAdcChannel);
	}
	for (int i = 0; i < FSIO_ADC_COUNT ; i++) {
		adc_channel_e ch = engineConfiguration->fsioAdc[i];
		if (ch != EFI_ADC_NONE) {
			printAnalogChannelInfo("fsio", ch);
		}
	}

	printAnalogChannelInfo("AFR", engineConfiguration->afr.hwChannel);
	if (hasMapSensor(PASS_ENGINE_PARAMETER_F)) {
		printAnalogChannelInfo("MAP", engineConfiguration->map.sensor.hwChannel);
	}
	if (hasBaroSensor(PASS_ENGINE_PARAMETER_F)) {
		printAnalogChannelInfo("BARO", engineConfiguration->baroSensor.hwChannel);
	}
	if (engineConfiguration->externalKnockSenseAdc != EFI_ADC_NONE) {
		printAnalogChannelInfo("extKno", engineConfiguration->externalKnockSenseAdc);
	}

	printAnalogChannelInfo("A/C sw", engineConfiguration->acSwitchAdc);
	printAnalogChannelInfo("HIP9011", engineConfiguration->hipOutputChannel);
	printAnalogChannelInfoExt("Vbatt", engineConfiguration->vbattAdcChannel, getVoltage("vbatt", engineConfiguration->vbattAdcChannel),
			engineConfiguration->vbattDividerCoeff);
}
Esempio n. 3
0
/**
 * @brief Returns engine load according to selected engine_load_mode
 *
 */
float getEngineLoadT(DECLARE_ENGINE_PARAMETER_F) {
	efiAssert(engine!=NULL, "engine 2NULL", NAN);
	efiAssert(engineConfiguration!=NULL, "engineConfiguration 2NULL", NAN);
	switch (engineConfiguration->algorithm) {
	case LM_PLAIN_MAF:
		if (!hasMafSensor(PASS_ENGINE_PARAMETER_F)) {
			warning(OBD_PCM_Processor_Fault, "MAF sensor needed for current fuel algorithm");
			return NAN;
		}
		return getMafT(engineConfiguration);
	case LM_SPEED_DENSITY:
		// SD engine load is used for timing lookup but not for fuel calculation
	case LM_MAP:
		return getMap();
	case LM_ALPHA_N:
		return getTPS(PASS_ENGINE_PARAMETER_F);
	case LM_REAL_MAF: {
		return getRealMaf(PASS_ENGINE_PARAMETER_F);
	}
	default:
		warning(OBD_PCM_Processor_Fault, "Unexpected engine load parameter: %d", engineConfiguration->algorithm);
		return -1;
	}
}
Esempio n. 4
0
static void printSensors(Logging *log, bool fileFormat) {
	// current time, in milliseconds
	int nowMs = currentTimeMillis();
	float sec = ((float) nowMs) / 1000;
	reportSensorF(log, fileFormat, "time", "", sec, 3);

	int rpm = 0;
#if EFI_SHAFT_POSITION_INPUT || defined(__DOXYGEN__)
	rpm = getRpmE(engine);
	reportSensorI(log, fileFormat, "rpm", "RPM", rpm);

//	reportSensorF(log, fileFormat, "TRG_0_DUTY", "%", getTriggerDutyCycle(0), 2);
//	reportSensorF(log, fileFormat, "TRG_1_DUTY", "%", getTriggerDutyCycle(1), 2);
#endif

	if (hasMafSensor()) {
		reportSensorF(log, fileFormat, "maf", "V", getMaf(), 2);
		reportSensorF(log, fileFormat, "mafr", "kg/hr", getRealMaf(), 2);
	}

	reportSensorF(log, fileFormat, "ENGINE_LOAD", "x", getEngineLoadT(), 2);


#if EFI_ANALOG_SENSORS || defined(__DOXYGEN__)
	if (engineConfiguration->hasMapSensor) {
		reportSensorF(log, fileFormat, "MAP", "kPa", getMap(), 2);
//		reportSensorF(log, fileFormat, "map_r", "V", getRawMap(), 2);
	}
	if (hasBaroSensor()) {
		reportSensorF(log, fileFormat, "baro", "kPa", getBaroPressure(), 2);
	}
	if (engineConfiguration->hasAfrSensor) {
		reportSensorF(log, fileFormat, "afr", "AFR", getAfr(), 2);
	}
#endif

#if EFI_VEHICLE_SPEED || defined(__DOXYGEN__)
	if (engineConfiguration->hasVehicleSpeedSensor) {
		reportSensorF(log, fileFormat, "vss", "kph", getVehicleSpeed(), 2);
	}
#endif /* EFI_PROD_CODE */

	reportSensorF(log, fileFormat, "ks", "count", engine->knockCount, 0);
	reportSensorF(log, fileFormat, "kv", "v", engine->knockVolts, 2);


//	reportSensorF(log, fileFormat, "vref", "V", getVRef(engineConfiguration), 2);
	if (hasVBatt(PASS_ENGINE_PARAMETER_F)) {
		reportSensorF(log, fileFormat, "vbatt", "V", getVBatt(PASS_ENGINE_PARAMETER_F), 2);
	}

	reportSensorF(log, fileFormat, "TP", "%", getTPS(PASS_ENGINE_PARAMETER_F), 2);

	if (fileFormat) {
		reportSensorF(log, fileFormat, "tpsacc", "ms", engine->tpsAccelEnrichment.getTpsEnrichment(PASS_ENGINE_PARAMETER_F), 2);
		reportSensorF(log, fileFormat, "advance", "deg", engine->tpsAccelEnrichment.getTpsEnrichment(PASS_ENGINE_PARAMETER_F), 2);
	}

	if (engineConfiguration->hasCltSensor) {
		reportSensorF(log, fileFormat, "CLT", "C", getCoolantTemperature(PASS_ENGINE_PARAMETER_F), 2);
	}

	reportSensorF(log, fileFormat, "MAT", "C", getIntakeAirTemperature(PASS_ENGINE_PARAMETER_F), 2);

//	debugFloat(&logger, "tch", getTCharge1(tps), 2);

}
Esempio n. 5
0
	float tps = getTPS(PASS_ENGINE_PARAMETER_F);
	float coolant = getCoolantTemperature(PASS_ENGINE_PARAMETER_F);
	float intake = getIntakeAirTemperature(PASS_ENGINE_PARAMETER_F);

	float engineLoad = getEngineLoadT(PASS_ENGINE_PARAMETER_F);
	float baseFuelMs = getBaseFuel(rpm PASS_ENGINE_PARAMETER);

	// header
	tsOutputChannels->tsConfigVersion = TS_FILE_VERSION;

	// engine state
	tsOutputChannels->rpm = rpm;
	tsOutputChannels->coolant_temperature = coolant;
	tsOutputChannels->intakeAirTemperature = intake;
	tsOutputChannels->throttlePositon = tps;
	tsOutputChannels->massAirFlowVoltage = hasMafSensor() ? getMaf() : 0;
    tsOutputChannels->massAirFlowValue = hasMafSensor() ? getRealMaf() : 0;
          
	tsOutputChannels->veValue = veMap.getValue(getMap(), rpm);
	tsOutputChannels->airFuelRatio = getAfr();
	if (hasVBatt(PASS_ENGINE_PARAMETER_F)) {
		tsOutputChannels->vBatt = getVBatt(PASS_ENGINE_PARAMETER_F);
	}
	tsOutputChannels->tpsADC = getTPS10bitAdc(PASS_ENGINE_PARAMETER_F);
#if EFI_ANALOG_SENSORS || defined(__DOXYGEN__)
	tsOutputChannels->baroPressure = hasBaroSensor() ? getBaroPressure() : 0;
#endif /* EFI_ANALOG_SENSORS */
	tsOutputChannels->manifold_air_pressure = getMap();
	tsOutputChannels->engineLoad = engineLoad;
	tsOutputChannels->rpmAcceleration = engine->rpmCalculator.getRpmAcceleration();
	tsOutputChannels->currentMapAccelDelta = engine->mapAccelEnrichment.getMapEnrichment(PASS_ENGINE_PARAMETER_F) * 100 / getMap();
Esempio n. 6
0
static void showLine(lcd_line_e line, int screenY) {
	static char buffer[10];

	switch (line) {
	case LL_VERSION:
		lcdPrintf("version %s", VCS_VERSION);
		return;
	case LL_CONFIG:
		lcdPrintf("config %s", getConfigurationName(engineConfiguration->engineType));
		return;
	case LL_RPM:
		lcdPrintf("RPM %d", getRpmE(engine));
		{
			char sdState;
			if (boardConfiguration->isSdCardEnabled) {
				sdState = isSdCardAlive() ? 'L' : 'n';
			} else {
				sdState = 'D';
			}
			int seconds = getTimeNowSeconds();
			if (seconds < 10000) {
				lcdPrintf("  %d%c", seconds, sdState);
			}
		}
		return;
	case LL_CLT_TEMPERATURE:
		lcdPrintf("Coolant %f", getCoolantTemperature(PASS_ENGINE_PARAMETER_F));
		return;
	case LL_IAT_TEMPERATURE:
		lcdPrintf("Intake Air %f", getIntakeAirTemperature(PASS_ENGINE_PARAMETER_F));
		return;
	case LL_ALGORITHM:
		lcdPrintf(getEngine_load_mode_e(engineConfiguration->algorithm));
		return;
	case LL_INJECTION:
		lcdPrintf(getInjection_mode_e(engineConfiguration->injectionMode));
		return;
	case LL_ING_FLOW:
		lcdPrintf("Inj %fcc", engineConfiguration->injector.flow);
		return;
	case LL_IGNITION:
		lcdPrintf(getIgnition_mode_e(engineConfiguration->ignitionMode));
		return;
	case LL_TPS:
		getPinNameByAdcChannel(engineConfiguration->tpsAdcChannel, buffer);

		lcdPrintf("Throttle %s %f%%", buffer, getTPS());
		return;
	case LL_VBATT:
		lcdPrintf("Battery %fv", getVBatt(PASS_ENGINE_PARAMETER_F));
		return;
	case LL_KNOCK:
		getPinNameByAdcChannel(engineConfiguration->hipOutputChannel, buffer);
		lcdPrintf("Knock %s %fv", buffer, engine->knockVolts);
		return;

#if	EFI_ANALOG_SENSORS || defined(__DOXYGEN__)
	case LL_BARO:
		if (hasBaroSensor()) {
			lcdPrintf("Baro: %f", getBaroPressure());
		} else {
			lcdPrintf("Baro: none");
		}
		return;
#endif
	case LL_AFR:
		if (engineConfiguration->hasAfrSensor) {
			lcdPrintf("AFR: %f", getAfr());
		} else {
			lcdPrintf("AFR: none");
		}
		return;
	case LL_MAP:
		if (engineConfiguration->hasMapSensor) {
			lcdPrintf("MAP %f", getMap());
		} else {
			lcdPrintf("MAP: none");
		}
		return;
	case LL_MAF_V:
		if (hasMafSensor()) {
			lcdPrintf("MAF: %fv", getMaf());
		} else {
			lcdPrintf("MAF: none");
		}
		return;
	case LL_MAF_KG_HR:
		if (hasMafSensor()) {
			lcdPrintf("MAF: %f kg/hr", getRealMaf());
		} else {
			lcdPrintf("MAF: none");
		}
		return;
	case LL_TRIGGER_ERRORS:
		lcdPrintf("Errors");
		return;
	case LL_TRIGGER_DUTY:
		lcdPrintf("Duty");
		return;
	default:
		lcdPrintf("()");
	}
}
Esempio n. 7
0
static void printSensors(Logging *log, bool fileFormat) {
	// current time, in milliseconds
	int nowMs = currentTimeMillis();
	float sec = ((float) nowMs) / 1000;
	reportSensorF(log, fileFormat, "time", "", sec, 3); // log column 1

	int rpm = 0;
#if EFI_SHAFT_POSITION_INPUT || defined(__DOXYGEN__)
	rpm = getRpmE(engine);
	reportSensorI(log, fileFormat, "rpm", "RPM", rpm); // log column 2

//	reportSensorF(log, fileFormat, "TRG_0_DUTY", "%", getTriggerDutyCycle(0), 2);
//	reportSensorF(log, fileFormat, "TRG_1_DUTY", "%", getTriggerDutyCycle(1), 2);
#endif

#if EFI_PROD_CODE || defined(__DOXYGEN__)
	reportSensorF(log, fileFormat, "int_temp", "C", getMCUInternalTemperature(), 2); // log column #3
#endif

	reportSensorI(log, fileFormat, "mode", "v", packEngineMode(PASS_ENGINE_PARAMETER_F)); // log column #3

	if (hasCltSensor()) {
		reportSensorF(log, fileFormat, "CLT", "C", getCoolantTemperature(PASS_ENGINE_PARAMETER_F), 2); // log column #4
	}
	if (hasTpsSensor()) {
		reportSensorF(log, fileFormat, "TPS", "%", getTPS(PASS_ENGINE_PARAMETER_F), 2); // log column #5
	}

	if (hasVBatt(PASS_ENGINE_PARAMETER_F)) {
		reportSensorF(log, fileFormat, "vbatt", "V", getVBatt(PASS_ENGINE_PARAMETER_F), 2); // log column #6
	}

	if (hasIatSensor()) {
		reportSensorF(log, fileFormat, "IAT", "C", getIntakeAirTemperature(PASS_ENGINE_PARAMETER_F), 2); // log column #7
	}

	if (hasMafSensor()) {
		reportSensorF(log, fileFormat, "maf", "V", getMaf(PASS_ENGINE_PARAMETER_F), 2);
		reportSensorF(log, fileFormat, "mafr", "kg/hr", getRealMaf(PASS_ENGINE_PARAMETER_F), 2);
	}
#if EFI_ANALOG_SENSORS || defined(__DOXYGEN__)
	if (engineConfiguration->map.sensor.hwChannel != EFI_ADC_NONE) {
		reportSensorF(log, fileFormat, "MAP", "kPa", getMap(), 2);
//		reportSensorF(log, fileFormat, "map_r", "V", getRawMap(), 2);
	}
#endif /* EFI_ANALOG_SENSORS */
#if EFI_ANALOG_SENSORS || defined(__DOXYGEN__)
	if (hasBaroSensor()) {
		reportSensorF(log, fileFormat, "baro", "kPa", getBaroPressure(), 2);
	}
#endif /* EFI_ANALOG_SENSORS */

	if (hasAfrSensor(PASS_ENGINE_PARAMETER_F)) {
		reportSensorF(log, fileFormat, "afr", "AFR", getAfr(PASS_ENGINE_PARAMETER_F), 2);
	}

#if EFI_IDLE_CONTROL || defined(__DOXYGEN__)
	if (fileFormat) {
		reportSensorF(log, fileFormat, "idle", "%", getIdlePosition(), 2);
	}
#endif /* EFI_IDLE_CONTROL */

#if EFI_ANALOG_SENSORS || defined(__DOXYGEN__)
	reportSensorF(log, fileFormat, "target", "AFR", engine->engineState.targetAFR, 2);
#endif /* EFI_ANALOG_SENSORS */

	if (fileFormat) {
		reportSensorF(log, fileFormat, "tCharge", "K", engine->engineState.tChargeK, 2); // log column #8
		reportSensorF(log, fileFormat, "curVE", "%", veMap.getValue(rpm, getMap()), 2);
	}

	float engineLoad = getEngineLoadT(PASS_ENGINE_PARAMETER_F);
	reportSensorF(log, fileFormat, "ENGINE_LOAD", "x", engineLoad, 2);


	reportSensorF(log, fileFormat, "dwell", "ms", ENGINE(engineState.sparkDwell), 2);
	if (fileFormat) {
		reportSensorF(log, fileFormat, "timing", "deg", engine->engineState.timingAdvance, 2);

	}

	if (fileFormat) {
		floatms_t fuelBase = getBaseFuel(rpm PASS_ENGINE_PARAMETER);
		reportSensorF(log, fileFormat, "f: base", "ms", fuelBase, 2);
		reportSensorF(log, fileFormat, "f: actual", "ms", ENGINE(actualLastInjection), 2);
		reportSensorF(log, fileFormat, "f: lag", "ms", engine->engineState.injectorLag, 2);
		reportSensorF(log, fileFormat, "f: running", "ms", ENGINE(engineState.runningFuel), 2);

		reportSensorF(log, fileFormat, "f: wall amt", "v", ENGINE(wallFuel).getWallFuel(0), 2);
		reportSensorF(log, fileFormat, "f: wall crr", "v", ENGINE(wallFuelCorrection), 2);

		reportSensorI(log, fileFormat, "version", "#", getRusEfiVersion());
	}


	if (engineConfiguration->hasVehicleSpeedSensor) {
#if EFI_VEHICLE_SPEED || defined(__DOXYGEN__)
		float vehicleSpeed = getVehicleSpeed();
#else
		float vehicleSpeed = 0;
#endif /* EFI_PROD_CODE */
		reportSensorF(log, fileFormat, "vss", "kph", vehicleSpeed, 2);
		float sp2rpm = rpm == 0 ? 0 : vehicleSpeed / rpm;
		reportSensorF(log, fileFormat, "sp2rpm", "x", sp2rpm, 2);
	}

	reportSensorF(log, fileFormat, "knck_c", "count", engine->knockCount, 0);
	reportSensorF(log, fileFormat, "knck_v", "v", engine->knockVolts, 2);

//	reportSensorF(log, fileFormat, "vref", "V", getVRef(engineConfiguration), 2);

	if (fileFormat) {
		reportSensorF(log, fileFormat, "f: tps delta", "v", engine->tpsAccelEnrichment.getMaxDelta(), 2);
		reportSensorF(log, fileFormat, "f: tps fuel", "ms", engine->engineState.tpsAccelEnrich, 2);

		reportSensorF(log, fileFormat, "f: el delta", "v", engine->engineLoadAccelEnrichment.getMaxDelta(), 2);
		reportSensorF(log, fileFormat, "f: el fuel", "v", engine->engineLoadAccelEnrichment.getEngineLoadEnrichment(PASS_ENGINE_PARAMETER_F) * 100 / getMap(), 2);

		reportSensorF(log, fileFormat, "f: duty", "%", getInjectorDutyCycle(rpm PASS_ENGINE_PARAMETER), 2);
	}


//	debugFloat(&logger, "tch", getTCharge1(tps), 2);

	for (int i = 0;i<FSIO_ADC_COUNT;i++) {
		if (engineConfiguration->fsioAdc[i] != EFI_ADC_NONE) {
			strcpy(buf, "adcX");
			buf[3] = '0' + i;
			reportSensorF(log, fileFormat, buf, "", getVoltage("fsio", engineConfiguration->fsioAdc[i]), 2);
		}
	}

	reportSensorI(log, fileFormat, "warn", "count", engine->engineState.warningCounter);
	reportSensorI(log, fileFormat, "error", "code", engine->engineState.lastErrorCode);

}
Esempio n. 8
0
	float tps = getTPS(PASS_ENGINE_PARAMETER_F);
	float coolant = getCoolantTemperature(PASS_ENGINE_PARAMETER_F);
	float intake = getIntakeAirTemperature(PASS_ENGINE_PARAMETER_F);

	float engineLoad = getEngineLoadT(PASS_ENGINE_PARAMETER_F);

	// header
	tsOutputChannels->tsConfigVersion = TS_FILE_VERSION;

	// engine state
	tsOutputChannels->rpm = rpm;
	tsOutputChannels->coolantTemperature = coolant;
	tsOutputChannels->intakeAirTemperature = intake;
	tsOutputChannels->throttlePositon = tps;
	tsOutputChannels->massAirFlowVoltage = hasMafSensor() ? getMaf(PASS_ENGINE_PARAMETER_F) : 0;
    tsOutputChannels->massAirFlow = hasMafSensor() ? getRealMaf(PASS_ENGINE_PARAMETER_F) : 0;
          
	tsOutputChannels->veValue = veMap.getValue(rpm, getMap());
	tsOutputChannels->currentTargetAfr = afrMap.getValue(rpm, getMap());
	tsOutputChannels->airFuelRatio = getAfr(PASS_ENGINE_PARAMETER_F);
	if (hasVBatt(PASS_ENGINE_PARAMETER_F)) {
		tsOutputChannels->vBatt = getVBatt(PASS_ENGINE_PARAMETER_F);
	}
	tsOutputChannels->tpsADC = getTPS12bitAdc(PASS_ENGINE_PARAMETER_F) / TPS_TS_CONVERSION;
#if EFI_ANALOG_SENSORS || defined(__DOXYGEN__)
	tsOutputChannels->baroPressure = hasBaroSensor() ? getBaroPressure() : 0;
#endif /* EFI_ANALOG_SENSORS */
	tsOutputChannels->manifoldAirPressure = getMap();
	tsOutputChannels->engineLoad = engineLoad;
	tsOutputChannels->rpmAcceleration = engine->rpmCalculator.getRpmAcceleration();