finish off vbatt -> sensor model (#2433)
* more vbatt * s * goodbye voltage * makefile * apparently that part was in use * include * mocking
This commit is contained in:
parent
fe2cb514f8
commit
3d17e62d65
|
@ -368,7 +368,7 @@ class CommunicationBlinkingTask : public PeriodicTimerController {
|
|||
void PeriodicTask() override {
|
||||
counter++;
|
||||
|
||||
bool lowVBatt = getVBatt(PASS_ENGINE_PARAMETER_SIGNATURE) < LOW_VBATT;
|
||||
bool lowVBatt = Sensor::get(SensorType::BatteryVoltage).value_or(0) < LOW_VBATT;
|
||||
|
||||
if (counter == 1) {
|
||||
// first invocation of BlinkingTask
|
||||
|
@ -543,9 +543,8 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
|
|||
tsOutputChannels->veTableYAxis = ENGINE(engineState.currentVeLoad);
|
||||
tsOutputChannels->afrTableYAxis = ENGINE(engineState.currentAfrLoad);
|
||||
|
||||
// KLUDGE? we always show VBatt because Proteus board has VBatt input sensor hardcoded
|
||||
// offset 28
|
||||
tsOutputChannels->vBatt = getVBatt(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
tsOutputChannels->vBatt = Sensor::get(SensorType::BatteryVoltage).value_or(0);
|
||||
|
||||
// offset 36
|
||||
tsOutputChannels->baroPressure = Sensor::get(SensorType::BarometricPressure).value_or(0);
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#include "engine.h"
|
||||
#include "rpm_calculator.h"
|
||||
#include "alternator_controller.h"
|
||||
#include "voltage.h"
|
||||
#include "pid.h"
|
||||
#include "local_version_holder.h"
|
||||
#include "periodic_task.h"
|
||||
|
@ -81,12 +80,17 @@ class AlternatorController : public PeriodicTimerController {
|
|||
return;
|
||||
}
|
||||
|
||||
float vBatt = getVBatt(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
auto vBatt = Sensor::get(SensorType::BatteryVoltage);
|
||||
float targetVoltage = engineConfiguration->targetVBatt;
|
||||
|
||||
if (CONFIG(onOffAlternatorLogic)) {
|
||||
if (!vBatt) {
|
||||
// Somehow battery voltage isn't valid, disable alternator control
|
||||
enginePins.alternatorPin.setValue(false);
|
||||
}
|
||||
|
||||
float h = 0.1;
|
||||
bool newState = (vBatt < targetVoltage - h) || (currentPlainOnOffState && vBatt < targetVoltage);
|
||||
bool newState = (vBatt.Value < targetVoltage - h) || (currentPlainOnOffState && vBatt.Value < targetVoltage);
|
||||
enginePins.alternatorPin.setValue(newState);
|
||||
currentPlainOnOffState = newState;
|
||||
if (engineConfiguration->debugMode == DBG_ALTERNATOR_PID) {
|
||||
|
@ -98,15 +102,19 @@ class AlternatorController : public PeriodicTimerController {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!vBatt) {
|
||||
// Somehow battery voltage isn't valid, disable alternator control
|
||||
alternatorPid.reset();
|
||||
alternatorControl.setSimplePwmDutyCycle(0);
|
||||
} else {
|
||||
currentAltDuty = alternatorPid.getOutput(targetVoltage, vBatt.Value);
|
||||
if (CONFIG(isVerboseAlternator)) {
|
||||
scheduleMsg(logger, "alt duty: %.2f/vbatt=%.2f/p=%.2f/i=%.2f/d=%.2f int=%.2f", currentAltDuty, vBatt.Value,
|
||||
alternatorPid.getP(), alternatorPid.getI(), alternatorPid.getD(), alternatorPid.getIntegration());
|
||||
}
|
||||
|
||||
currentAltDuty = alternatorPid.getOutput(targetVoltage, vBatt);
|
||||
if (CONFIG(isVerboseAlternator)) {
|
||||
scheduleMsg(logger, "alt duty: %.2f/vbatt=%.2f/p=%.2f/i=%.2f/d=%.2f int=%.2f", currentAltDuty, vBatt,
|
||||
alternatorPid.getP(), alternatorPid.getI(), alternatorPid.getD(), alternatorPid.getIntegration());
|
||||
alternatorControl.setSimplePwmDutyCycle(PERCENT_TO_DUTY(currentAltDuty));
|
||||
}
|
||||
|
||||
|
||||
alternatorControl.setSimplePwmDutyCycle(PERCENT_TO_DUTY(currentAltDuty));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -118,7 +126,7 @@ void showAltInfo(void) {
|
|||
engineConfiguration->alternatorControl.periodMs);
|
||||
scheduleMsg(logger, "p=%.2f/i=%.2f/d=%.2f offset=%.2f", engineConfiguration->alternatorControl.pFactor,
|
||||
0, 0, engineConfiguration->alternatorControl.offset); // todo: i & d
|
||||
scheduleMsg(logger, "vbatt=%.2f/duty=%.2f/target=%.2f", getVBatt(PASS_ENGINE_PARAMETER_SIGNATURE), currentAltDuty,
|
||||
scheduleMsg(logger, "vbatt=%.2f/duty=%.2f/target=%.2f", Sensor::get(SensorType::BatteryVoltage).value_or(0), currentAltDuty,
|
||||
engineConfiguration->targetVBatt);
|
||||
}
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ static void populateFrame(Sensors2& msg) {
|
|||
msg.afr = Sensor::get(SensorType::Lambda1).value_or(0) * 14.7f;
|
||||
msg.oilPressure = Sensor::get(SensorType::OilPressure).value_or(-1);
|
||||
msg.vvtPos = engine->triggerCentral.getVVTPosition();
|
||||
msg.vbatt = getVBatt();
|
||||
msg.vbatt = Sensor::get(SensorType::BatteryVoltage).value_or(0);
|
||||
}
|
||||
|
||||
struct Fueling {
|
||||
|
|
|
@ -161,7 +161,7 @@ FsioResult getEngineValue(le_action_e action DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
|||
case LE_METHOD_IN_MR_BENCH:
|
||||
return engine->isInMainRelayBench();
|
||||
case LE_METHOD_VBATT:
|
||||
return getVBatt(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
return Sensor::get(SensorType::BatteryVoltage).value_or(0);
|
||||
case LE_METHOD_TPS:
|
||||
return Sensor::get(SensorType::DriverThrottleIntent).value_or(0);
|
||||
// cfg_xxx references are code generated
|
||||
|
@ -771,7 +771,7 @@ void runHardcodedFsio(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
|
||||
// see MAIN_RELAY_LOGIC
|
||||
if (isBrainPinValid(CONFIG(mainRelayPin))) {
|
||||
enginePins.mainRelay.setValue((getTimeNowSeconds() < 2) || (getVBatt(PASS_ENGINE_PARAMETER_SIGNATURE) > LOW_VBATT) || engine->isInShutdownMode());
|
||||
enginePins.mainRelay.setValue((getTimeNowSeconds() < 2) || (Sensor::get(SensorType::BatteryVoltage).value_or(0) > LOW_VBATT) || engine->isInShutdownMode());
|
||||
}
|
||||
// see STARTER_RELAY_LOGIC
|
||||
if (isBrainPinValid(CONFIG(starterRelayDisablePin))) {
|
||||
|
|
|
@ -24,7 +24,6 @@ void slowStartStopButtonCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
|||
void setMockVoltage(int hwChannel, float voltage DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||
#endif
|
||||
|
||||
void setMockVBattVoltage(float voltage DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||
void setMockMapVoltage(float voltage DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||
void setMockAfrVoltage(float voltage DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||
void setMockMafVoltage(float voltage DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||
|
|
|
@ -66,10 +66,6 @@ void setMockAfrVoltage(float voltage DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
|||
void setMockMapVoltage(float voltage DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||
setMockVoltage(engineConfiguration->map.sensor.hwChannel, voltage PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
}
|
||||
|
||||
void setMockVBattVoltage(float voltage DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||
setMockVoltage(engineConfiguration->vbattAdcChannel, voltage PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
}
|
||||
#endif /* EFI_ENABLE_MOCK_ADC */
|
||||
|
||||
#if EFI_PROD_CODE
|
||||
|
|
|
@ -203,7 +203,7 @@ static void showLine(lcd_line_e line, int /*screenY*/) {
|
|||
lcdPrintf("ING LAG %.2f", engine->engineState.running.injectorLag);
|
||||
return;
|
||||
case LL_VBATT:
|
||||
lcdPrintf("Battery %.2fv", getVBatt(PASS_ENGINE_PARAMETER_SIGNATURE));
|
||||
lcdPrintf("Battery %.2fv", Sensor::get(SensorType::BatteryVoltage).value_or(0));
|
||||
return;
|
||||
case LL_KNOCK:
|
||||
getPinNameByAdcChannel("hip", engineConfiguration->hipOutputChannel, buffer);
|
||||
|
|
|
@ -16,10 +16,11 @@
|
|||
#include "map.h"
|
||||
#include "maf.h"
|
||||
#include "ego.h"
|
||||
#include "voltage.h"
|
||||
#include "thermistors.h"
|
||||
#include "adc_inputs.h"
|
||||
|
||||
#define LOW_VBATT 7
|
||||
|
||||
void initSensors(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||
|
||||
bool hasAcToggle(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
|
|
@ -4,7 +4,6 @@ CONTROLLERS_SENSORS_SRC =
|
|||
CONTROLLERS_SENSORS_SRC_CPP = $(PROJECT_DIR)/controllers/sensors/thermistors.cpp \
|
||||
$(PROJECT_DIR)/controllers/sensors/allsensors.cpp \
|
||||
$(PROJECT_DIR)/controllers/sensors/map.cpp \
|
||||
$(PROJECT_DIR)/controllers/sensors/voltage.cpp \
|
||||
$(PROJECT_DIR)/controllers/sensors/maf.cpp \
|
||||
$(PROJECT_DIR)/controllers/sensors/tps.cpp \
|
||||
$(PROJECT_DIR)/controllers/sensors/ego.cpp \
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
/**
|
||||
* @file voltage.cpp
|
||||
* @brief
|
||||
*
|
||||
*
|
||||
* @date Nov 15, 2013
|
||||
* @author Andrey Belomutskiy, (c) 2012-2020
|
||||
*/
|
||||
|
||||
#include "global.h"
|
||||
#include "engine.h"
|
||||
#include "adc_inputs.h"
|
||||
#include "voltage.h"
|
||||
|
||||
EXTERN_ENGINE;
|
||||
|
||||
float getVBatt(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
#ifdef USE_ADC3_VBATT_HACK
|
||||
extern adcsample_t vbattSampleProteus;
|
||||
return adcToVolts(vbattSampleProteus) * engineConfiguration->vbattDividerCoeff;
|
||||
#else
|
||||
return getVoltage("vbatt", engineConfiguration->vbattAdcChannel PASS_ENGINE_PARAMETER_SUFFIX) * engineConfiguration->vbattDividerCoeff;
|
||||
#endif
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
/**
|
||||
* @file voltage.h
|
||||
* @brief
|
||||
*
|
||||
*
|
||||
* @date Nov 15, 2013
|
||||
* @author Andrey Belomutskiy, (c) 2012-2020
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "global.h"
|
||||
#define LOW_VBATT 7
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "engine_configuration.h"
|
||||
|
||||
float getVBatt(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
||||
#endif /* __cplusplus */
|
|
@ -1104,7 +1104,6 @@ const command_f_s commandsF[] = {
|
|||
{MOCK_MAF_COMMAND, setMockMafVoltage},
|
||||
{MOCK_AFR_COMMAND, setMockAfrVoltage},
|
||||
{MOCK_MAP_COMMAND, setMockMapVoltage},
|
||||
{"mock_vbatt_voltage", setMockVBattVoltage},
|
||||
{MOCK_CLT_COMMAND, setMockCltVoltage},
|
||||
#endif // EFI_ENABLE_MOCK_ADC
|
||||
{"ignition_offset", setIgnitionOffset},
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
#include "gpio/gpio_ext.h"
|
||||
#include "pin_repository.h"
|
||||
#include "os_util.h"
|
||||
#include "voltage.h"
|
||||
#include "thread_priority.h"
|
||||
|
||||
EXTERN_ENGINE_CONFIGURATION;
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "hardware.h"
|
||||
#include "mc33816_data.h"
|
||||
#include "mpu_util.h"
|
||||
#include "voltage.h"
|
||||
#include "allsensors.h"
|
||||
|
||||
EXTERN_ENGINE;
|
||||
|
||||
|
|
|
@ -209,7 +209,7 @@ public class CommonFunctionalTest extends RusefiTestBase {
|
|||
ecu.sendCommand("set wwaeTau 0");
|
||||
ecu.sendCommand("set wwaeBeta 0");
|
||||
ecu.sendCommand("set mock_map_voltage 1");
|
||||
ecu.sendCommand("set mock_vbatt_voltage 1.20");
|
||||
ecu.sendCommand("set_sensor_mock 27 12");
|
||||
ecu.sendCommand("disable cylinder_cleanup");
|
||||
EngineChart chart;
|
||||
String msg = "2003 Neon cranking ";
|
||||
|
@ -274,7 +274,7 @@ public class CommonFunctionalTest extends RusefiTestBase {
|
|||
public void testMazdaProtege() {
|
||||
ecu.setEngineType(ET_FORD_ESCORT_GT);
|
||||
EngineChart chart;
|
||||
ecu.sendCommand("set mock_vbatt_voltage 1.395");
|
||||
ecu.sendCommand("set_sensor_mock 27 12");
|
||||
|
||||
// Alpha-N mode so that we actually inject some fuel (without mocking tons of sensors)
|
||||
ecu.sendCommand("set algorithm 5");
|
||||
|
@ -354,7 +354,7 @@ public class CommonFunctionalTest extends RusefiTestBase {
|
|||
ecu.setEngineType(ET_FORD_ASPIRE);
|
||||
ecu.sendCommand("disable cylinder_cleanup");
|
||||
ecu.sendCommand("set mock_map_voltage 1");
|
||||
ecu.sendCommand("set mock_vbatt_voltage 2.2");
|
||||
ecu.sendCommand("set_sensor_mock 27 12");
|
||||
String msg;
|
||||
EngineChart chart;
|
||||
// todo: interesting changeRpm(100);
|
||||
|
|
Loading…
Reference in New Issue