Uaefi sent (#7099)
* SENT: typo * SENT: separate menu for input configuration * SENT: pass SENT input number to decoder function * SENT: is optional * SENT: move gauges to "Sensors - SENT" category * SENT: gauges show first channels statsistic only * SENT: channels abstraction First we define gpios used for SENT channels Then we glue sensors to SENT channels * SENT: fix gauges * SENT: guards
This commit is contained in:
parent
5387516bc6
commit
1987f497e2
|
@ -204,7 +204,11 @@ const ignition_state_s* getLiveData(size_t) {
|
|||
|
||||
template<>
|
||||
const sent_state_s* getLiveData(size_t) {
|
||||
#if EFI_SENT_SUPPORT
|
||||
return &engine->sent_state;
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
template<>
|
||||
|
|
|
@ -318,7 +318,9 @@ public:
|
|||
EngineState engineState;
|
||||
|
||||
dc_motors_s dc_motors;
|
||||
#if EFI_SENT_SUPPORT
|
||||
sent_state_s sent_state;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* idle blip is a development tool: alternator PID research for instance have benefited from a repetitive change of RPM
|
||||
|
|
|
@ -198,6 +198,17 @@ enum class SentEtbType : uint8_t {
|
|||
CUSTOM = 3,
|
||||
};
|
||||
|
||||
enum class SentInput : uint8_t {
|
||||
NONE = 0,
|
||||
INPUT1 = 1,
|
||||
INPUT2 = 2,
|
||||
INPUT3 = 3,
|
||||
INPUT4 = 4,
|
||||
INPUT5 = 5,
|
||||
INPUT6 = 6,
|
||||
INPUT7 = 7
|
||||
};
|
||||
|
||||
enum class CanGpioType : uint8_t {
|
||||
NONE = 0,
|
||||
DRT = 1,
|
||||
|
|
|
@ -749,7 +749,7 @@ void configureRusefiLuaHooks(lua_State* lState) {
|
|||
lua_register(lState, "getSentValue",
|
||||
[](lua_State* l) {
|
||||
auto humanIndex = luaL_checkinteger(l, 1);
|
||||
auto value = getSentValue(humanIndex - 1);
|
||||
auto value = getSentValue(static_cast<SentInput>(humanIndex));
|
||||
lua_pushnumber(l, value);
|
||||
return 1;
|
||||
});
|
||||
|
@ -759,7 +759,7 @@ void configureRusefiLuaHooks(lua_State* lState) {
|
|||
uint16_t sig0;
|
||||
uint16_t sig1;
|
||||
auto humanIndex = luaL_checkinteger(l, 1);
|
||||
/*auto ret = */getSentValues(humanIndex - 1, &sig0, &sig1);
|
||||
/*auto ret = */getSentValues(static_cast<SentInput>(humanIndex), &sig0, &sig1);
|
||||
lua_pushnumber(l, sig0);
|
||||
lua_pushnumber(l, sig1);
|
||||
return 2;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
struct sent_state_s
|
||||
uint16_t value0;"ETB: SENT value0";"value", 1,0, 0,3, 0,@@GAUGE_CATEGORY_ETB@@
|
||||
uint16_t value1;"ETB: SENT value1";"value", 1,0, 0,3, 0,@@GAUGE_CATEGORY_ETB@@
|
||||
float errorRate;"ETB: SENT error rate";"ratio", 1,0, 0,3, 2,@@GAUGE_CATEGORY_ETB@@
|
||||
uint16_t value0;"SENT ch0 value0";"RAW", 1,0, 0,4095, 0,@@GAUGE_CATEGORY_SENT@@
|
||||
uint16_t value1;"SENT ch0 value1";"RAW", 1,0, 0,4095, 0,@@GAUGE_CATEGORY_SENT@@
|
||||
float errorRate;"SENT ch0 error rate";"% (don't belive me)", 1,0, 0,100, 2,@@GAUGE_CATEGORY_SENT@@
|
||||
end_struct
|
|
@ -56,6 +56,8 @@ bool isPedalError() {
|
|||
return !Sensor::get(SensorType::AcceleratorPedal).Valid && Sensor::hasSensor(SensorType::AcceleratorPedalPrimary);
|
||||
}
|
||||
|
||||
#if EFI_SENT_SUPPORT
|
||||
|
||||
extern SentTps sentTps;
|
||||
|
||||
float decodeTpsSentValue(float sentValue) {
|
||||
|
@ -69,15 +71,19 @@ float decodeTpsSentValue(float sentValue) {
|
|||
}
|
||||
}
|
||||
|
||||
void sentTpsDecode() {
|
||||
#if EFI_SENT_SUPPORT
|
||||
if (!isDigitalTps1()) {
|
||||
void sentTpsDecode(SentInput sentCh) {
|
||||
if ((!isDigitalTps1()) || (engineConfiguration->EtbSentInput != sentCh)) {
|
||||
return;
|
||||
}
|
||||
// todo: move away from weird float API
|
||||
float sentValue = getSentValue(0);
|
||||
float sentValue = getSentValue(sentCh);
|
||||
float tpsValue = decodeTpsSentValue(sentValue);
|
||||
|
||||
sentTps.setValidValue(tpsValue, getTimeNowNt());
|
||||
#endif // EFI_SENT_SUPPORT
|
||||
}
|
||||
|
||||
bool isDigitalTps1() {
|
||||
return (engineConfiguration->sentEtbType != SentEtbType::NONE);
|
||||
}
|
||||
|
||||
#endif /* EFI_SENT_SUPPORT */
|
||||
|
|
|
@ -22,6 +22,17 @@ constexpr inline int convertVoltageTo10bitADC(float voltage) {
|
|||
return (int) (voltage * TPS_TS_CONVERSION);
|
||||
}
|
||||
|
||||
void grabTPSIsClosed();
|
||||
void grabTPSIsWideOpen();
|
||||
void grabPedalIsUp();
|
||||
void grabPedalIsWideOpen();
|
||||
|
||||
bool isTps1Error();
|
||||
bool isTps2Error();
|
||||
bool isPedalError();
|
||||
|
||||
#if EFI_SENT_SUPPORT
|
||||
|
||||
struct SentTps : public StoredValueSensor {
|
||||
SentTps() : StoredValueSensor(SensorType::Tps1, MS2NT(200)) {
|
||||
}
|
||||
|
@ -31,15 +42,8 @@ struct SentTps : public StoredValueSensor {
|
|||
}
|
||||
};
|
||||
|
||||
void grabTPSIsClosed();
|
||||
void grabTPSIsWideOpen();
|
||||
void grabPedalIsUp();
|
||||
void grabPedalIsWideOpen();
|
||||
|
||||
void sentTpsDecode();
|
||||
void sentTpsDecode(SentInput sentCh);
|
||||
float decodeTpsSentValue(float sentValue);
|
||||
bool isDigitalTps1();
|
||||
|
||||
bool isTps1Error();
|
||||
bool isTps2Error();
|
||||
bool isPedalError();
|
||||
#endif
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
|
||||
#include "pch.h"
|
||||
|
||||
#if EFI_SENT_SUPPORT
|
||||
|
||||
#include "sent.h"
|
||||
#include "sent_logic.h"
|
||||
#include "sent_constants.h"
|
||||
|
@ -497,9 +499,11 @@ uint8_t sent_channel::crc6(uint32_t data)
|
|||
return crc;
|
||||
}
|
||||
|
||||
#endif /* EFI_SENT_SUPPORT */
|
||||
#endif // EFI_PROD_CODE || EFI_UNIT_TEST
|
||||
|
||||
#if EFI_PROD_CODE
|
||||
#if EFI_SENT_SUPPORT
|
||||
|
||||
static sent_channel channels[SENT_CHANNELS_NUM];
|
||||
|
||||
|
@ -569,19 +573,21 @@ static void SentDecoderThread(void*) {
|
|||
sent_channel &channel = channels[n];
|
||||
|
||||
if (channel.Decoder(tick) > 0) {
|
||||
/* report only for first channel */
|
||||
if (n == 0) {
|
||||
uint16_t sig0, sig1;
|
||||
channel.GetSignals(NULL, &sig0, &sig1);
|
||||
engine->sent_state.value0 = sig0;
|
||||
engine->sent_state.value1 = sig1;
|
||||
|
||||
uint16_t sig0, sig1;
|
||||
channel.GetSignals(NULL, &sig0, &sig1);
|
||||
engine->sent_state.value0 = sig0;
|
||||
engine->sent_state.value1 = sig1;
|
||||
|
||||
#if SENT_STATISTIC_COUNTERS
|
||||
engine->sent_state.errorRate = channel.statistic.getErrorRate();
|
||||
#endif // SENT_STATISTIC_COUNTERS
|
||||
|
||||
#if SENT_STATISTIC_COUNTERS
|
||||
engine->sent_state.errorRate = 100.0 * channel.statistic.getErrorRate();
|
||||
#endif // SENT_STATISTIC_COUNTERS
|
||||
}
|
||||
|
||||
SentInput input = static_cast<SentInput>((size_t)SentInput::INPUT1 + n);
|
||||
/* Call high level decoder from here */
|
||||
sentTpsDecode();
|
||||
sentTpsDecode(input);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -589,21 +595,21 @@ static void SentDecoderThread(void*) {
|
|||
}
|
||||
|
||||
static void printSentInfo() {
|
||||
#if EFI_SENT_SUPPORT
|
||||
for (int i = 0; i < SENT_CHANNELS_NUM; i++) {
|
||||
sent_channel &channel = channels[i];
|
||||
|
||||
const char * pinName = getBoardSpecificPinName(engineConfiguration->sentInputPins[i]);
|
||||
efiPrintf("---- SENT ch %d ---- on %s", i, pinName);
|
||||
efiPrintf("---- SENT input %d ---- on %s", i + 1, pinName);
|
||||
channel.Info();
|
||||
efiPrintf("--------------------");
|
||||
}
|
||||
#endif // EFI_SENT_SUPPORT
|
||||
}
|
||||
|
||||
/* Don't be confused: this actually returns throttle body position */
|
||||
/* TODO: remove, replace with getSentValues() */
|
||||
float getSentValue(size_t index) {
|
||||
float getSentValue(SentInput input) {
|
||||
size_t index = static_cast<size_t>(input) - static_cast<size_t>(SentInput::INPUT1);
|
||||
|
||||
if (index < SENT_CHANNELS_NUM) {
|
||||
uint16_t sig0, sig1;
|
||||
sent_channel &channel = channels[index];
|
||||
|
@ -619,7 +625,9 @@ float getSentValue(size_t index) {
|
|||
return NAN;
|
||||
}
|
||||
|
||||
int getSentValues(size_t index, uint16_t *sig0, uint16_t *sig1) {
|
||||
int getSentValues(SentInput input, uint16_t *sig0, uint16_t *sig1) {
|
||||
size_t index = static_cast<size_t>(input) - static_cast<size_t>(SentInput::INPUT1);
|
||||
|
||||
if (index < SENT_CHANNELS_NUM) {
|
||||
sent_channel &channel = channels[index];
|
||||
|
||||
|
@ -643,4 +651,5 @@ void initSent(void) {
|
|||
addConsoleAction("sentinfo", &printSentInfo);
|
||||
}
|
||||
|
||||
#endif /* EFI_SENT_SUPPORT */
|
||||
#endif /* EFI_PROD_CODE */
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#if EFI_SENT_SUPPORT
|
||||
|
||||
/* SENT decoder init */
|
||||
void initSent();
|
||||
|
||||
|
@ -19,5 +21,7 @@ void SENT_ISR_Handler(uint8_t ch, uint16_t val_res);
|
|||
void startSent();
|
||||
void stopSent();
|
||||
|
||||
float getSentValue(size_t index);
|
||||
int getSentValues(size_t index, uint16_t *sig0, uint16_t *sig1);
|
||||
float getSentValue(SentInput input);
|
||||
int getSentValues(SentInput input, uint16_t *sig0, uint16_t *sig1);
|
||||
|
||||
#endif /* EFI_SENT_SUPPORT */
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
#include "pch.h"
|
||||
|
||||
#if EFI_SENT_SUPPORT
|
||||
|
||||
#include "sent.h"
|
||||
#include "sent_hw_icu.h"
|
||||
|
||||
|
@ -60,7 +62,7 @@ void startSent() {
|
|||
uint32_t baseClock;
|
||||
|
||||
if (getIcuParams(sentPin, &pinAF, &icu, &cfg->channel, &baseClock) != true) {
|
||||
/* this pin has no ICU functionality, of ICU driver is not enabled for TIM on this pin */
|
||||
/* this pin has no ICU functionality or ICU driver is not enabled for TIM on this pin */
|
||||
criticalError("No ICU on selected SENT pin");
|
||||
continue;
|
||||
}
|
||||
|
@ -84,7 +86,7 @@ void stopSent() {
|
|||
ICUDriver *icu;
|
||||
|
||||
if (getIcuParams(sentPin, NULL, &icu, NULL, NULL) != true) {
|
||||
/* this pin has no ICU functionality, of ICU driver is not enabled for TIM on this pin */
|
||||
/* this pin has no ICU functionality or ICU driver is not enabled for TIM on this pin */
|
||||
/* throw error? */
|
||||
continue;
|
||||
}
|
||||
|
@ -97,6 +99,8 @@ void stopSent() {
|
|||
}
|
||||
}
|
||||
|
||||
#endif /* EFI_SENT_SUPPORT */
|
||||
|
||||
#endif /* HAL_USE_ICU */
|
||||
|
||||
#endif /* EFI_PROD_CODE */
|
||||
|
|
|
@ -46,7 +46,7 @@ uint32_t getTotalError() {
|
|||
}
|
||||
|
||||
float getErrorRate() {
|
||||
return getTotalError() * 1.0 / FrameCnt;
|
||||
return 1.0 * getTotalError() / (FrameCnt + getTotalError());
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -176,7 +176,9 @@ static FuncSensPair tps2s(TPS_TS_CONVERSION, SensorType::Tps2Secondary);
|
|||
static RedundantPair analogTps1(tps1p, tps1s, SensorType::Tps1);
|
||||
static RedundantPair tps2(tps2p, tps2s, SensorType::Tps2);
|
||||
|
||||
#if EFI_SENT_SUPPORT
|
||||
SentTps sentTps;
|
||||
#endif
|
||||
|
||||
// Used only in case of weird Ford-style ETB TPS
|
||||
static RedundantFordTps fordTps1(SensorType::Tps1, SensorType::Tps1Primary, SensorType::Tps1Secondary);
|
||||
|
@ -199,10 +201,6 @@ static ProxySensor driverIntent(SensorType::DriverThrottleIntent);
|
|||
static FuncSensPair wastegate(PACK_MULT_VOLTAGE, SensorType::WastegatePosition);
|
||||
static FuncSensPair idlePos(PACK_MULT_VOLTAGE, SensorType::IdlePosition);
|
||||
|
||||
bool isDigitalTps1() {
|
||||
return isBrainPinValid(engineConfiguration->sentInputPins[0]) && engineConfiguration->sentEtbType != SentEtbType::NONE;
|
||||
}
|
||||
|
||||
void initTps() {
|
||||
criticalAssertVoid(engineConfiguration != nullptr, "null engineConfiguration");
|
||||
percent_t minTpsPps = engineConfiguration->tpsErrorDetectionTooLow;
|
||||
|
@ -219,9 +217,12 @@ void initTps() {
|
|||
}
|
||||
|
||||
|
||||
#if EFI_SENT_SUPPORT
|
||||
if (isDigitalTps1()) {
|
||||
sentTps.Register();
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
analogTps1.init(isFordTps, &fordTps1, tpsSecondaryMaximum,
|
||||
{ engineConfiguration->tps1_1AdcChannel, (float)engineConfiguration->tpsMin, (float)engineConfiguration->tpsMax, minTpsPps, maxTpsPps },
|
||||
{ engineConfiguration->tps1_2AdcChannel, (float)engineConfiguration->tps1SecondaryMin, (float)engineConfiguration->tps1SecondaryMax, minTpsPps, maxTpsPps }
|
||||
|
@ -269,7 +270,9 @@ void deinitTps() {
|
|||
tps2.deinit(isFordTps, &fordTps2);
|
||||
pedal.deinit(isFordPps, &fordPps);
|
||||
|
||||
#if EFI_SENT_SUPPORT
|
||||
sentTps.unregister();
|
||||
#endif
|
||||
|
||||
wastegate.deinit();
|
||||
idlePos.deinit();
|
||||
|
|
|
@ -298,6 +298,9 @@ custom ego_sensor_e 1 bits, S08, @OFFSET@, [0:2], @@ego_sensor_e_enum@@
|
|||
#define SentEtbType_enum "None", "GM type 1", "Ford type 1", "Custom"
|
||||
custom SentEtbType 1 bits, S08, @OFFSET@, [0:1], @@SentEtbType_enum@@
|
||||
|
||||
#define SentInput_enum "None", "SENT input 1", "SENT input 2", "SENT input 3", "SENT input 4", "SENT input 5", "SENT input 6", "SENT input 7"
|
||||
custom SentInput 1 bits, U08, @OFFSET@, [0:2], @@SentInput_enum@@
|
||||
|
||||
#define CanGpioType_enum "None", "DRT protocol", "MS protocol"
|
||||
custom CanGpioType 1 bits, S08, @OFFSET@, [0:1], @@CanGpioType_enum@@
|
||||
|
||||
|
@ -1401,7 +1404,7 @@ custom stepper_num_micro_steps_e 1 bits, U08, @OFFSET@, [0:3], @@stepper_num_mic
|
|||
|
||||
float auxFrequencyFilter;;"hz", 1, 0, 0, 100, 1
|
||||
|
||||
sent_input_pin_e[SENT_INPUT_COUNT iterate] sentInputPins;
|
||||
sent_input_pin_e[SENT_INPUT_COUNT iterate] sentInputPins;
|
||||
|
||||
|
||||
int16_t coastingFuelCutRpmHigh;This sets the RPM above which fuel cut is active.;"rpm", 1, 0, 0, 5000, 0
|
||||
|
@ -1589,7 +1592,7 @@ int16_t ALSMaxDuration;;"sec", 1, 0, 0, 10, 0
|
|||
uint8_t alsMinTimeBetween;;"", 1, 0, 0, 20000, 0
|
||||
uint8_t alsEtbPosition;;"", 1, 0, 0, 20000, 0
|
||||
uint8_t acRelayAlternatorDutyAdder;;"%", 1, 0, 0, 100, 0
|
||||
SentEtbType sentEtbType
|
||||
SentEtbType sentEtbType;If you have SENT TPS sensor please select type. For analog TPS lease None
|
||||
uint16_t customSentTpsMin
|
||||
int ALSIdleAdd;;"%", 1, 0, 0, 100, 2
|
||||
int ALSEtbAdd;;"%", 1, 0, 0, 100, 2
|
||||
|
@ -1721,7 +1724,9 @@ uint8_t autoscale knockFuelTrim;Fuel trim when knock, max 30%;"%", 1, 0, 0, 30,
|
|||
injector_compensation_mode_e secondaryInjectorCompensationMode;None = I have a MAP-referenced fuel pressure regulator\nFixed rail pressure = I have an atmosphere-referenced fuel pressure regulator (returnless, typically)\nSensed rail pressure = I have a fuel pressure sensor;
|
||||
float secondaryInjectorFuelReferencePressure;This is the pressure at which your injector flow is known.\nFor example if your injectors flow 400cc/min at 3.5 bar, enter 350kpa here.;"kPa", 1, 0, 50, 700000, 0
|
||||
|
||||
#define END_OF_CALIBRATION_PADDING 111
|
||||
SentInput EtbSentInput;SENT input connected to ETB
|
||||
|
||||
#define END_OF_CALIBRATION_PADDING 110
|
||||
uint8_t[END_OF_CALIBRATION_PADDING] unusedOftenChangesDuringFirmwareUpdate;;"units", 1, 0, 0, 1, 0
|
||||
|
||||
! end of engine_configuration_s
|
||||
|
@ -2147,6 +2152,7 @@ end_struct
|
|||
#define GAUGE_CATEGORY_FUEL_MATH "Fuel: math"
|
||||
#define GAUGE_CATEGORY_BOOST_CONTROL "Boost Control"
|
||||
#define GAUGE_CATEGORY_ETB "ETB more"
|
||||
#define GAUGE_CATEGORY_SENT "Sensors - SENT"
|
||||
|
||||
#define GAUGE_NAME_VVT_B1I "VVT: bank 1 intake"
|
||||
#define GAUGE_NAME_VVT_B1E "VVT: bank 1 exhaust"
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
#define GAUGE_CATEGORY_FUEL_MATH "Fuel: math"
|
||||
#define GAUGE_CATEGORY_BOOST_CONTROL "Boost Control"
|
||||
#define GAUGE_CATEGORY_ETB "ETB more"
|
||||
#define GAUGE_CATEGORY_SENT "Sensors - SENT"
|
||||
|
||||
#define GAUGE_NAME_VVT_B1I "VVT: bank 1 intake"
|
||||
#define GAUGE_NAME_VVT_B1E "VVT: bank 1 exhaust"
|
||||
|
|
|
@ -2188,6 +2188,10 @@ menuDialog = main
|
|||
subMenu = widebandConfig, "rusEFI Wideband Controller", 0, { canReadEnabled && canWriteEnabled }@@if_ts_show_can_wbo
|
||||
subMenu = std_separator
|
||||
|
||||
# SENT interface
|
||||
subMenu = sentInputs "SENT inputs"
|
||||
subMenu = std_separator
|
||||
|
||||
# Misc sensors
|
||||
groupMenu = "Oil sensors"
|
||||
groupChildMenu = oilPressureSensor, "Oil pressure"@@if_ts_show_oil_pressure_sensor
|
||||
|
@ -2965,8 +2969,8 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@@@ts_command_e_TS_
|
|||
field = "Resistance @ HT", auxTempSensor2_resistance_3, {auxTempSensor2_adcChannel != @@ADC_CHANNEL_NONE@@}
|
||||
|
||||
dialog = tpsSent1, "SENT TPS"
|
||||
field = "Input #1", sentInputPins1
|
||||
field = "ETB type", sentEtbType, {sentInputPins1 != 0}
|
||||
field = "ETB SENT type", sentEtbType
|
||||
field = "ETB SENT input" EtbSentInput, {sentEtbType != 0 }
|
||||
field = "Closed value", customSentTpsMin, {sentEtbType == @@SentEtbType_CUSTOM@@ }
|
||||
field = "Open value", customSentTpsMax, {sentEtbType == @@SentEtbType_CUSTOM@@ }
|
||||
|
||||
|
@ -3506,8 +3510,11 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@@@ts_command_e_TS_
|
|||
panel = auxLinearSensor2
|
||||
field = "Aux Speed Input 1", auxSpeedSensorInputPin1
|
||||
field = "Aux Speed Input 2", auxSpeedSensorInputPin2
|
||||
field = "Use Aux Speed Sensors for slip ratio", useAuxSpeedForSlipRatio
|
||||
field = "Use VSS As Second Wheel Speed", useVssAsSecondWheelSpeed
|
||||
field = "Use Aux Speed Sensors for slip ratio", useAuxSpeedForSlipRatio
|
||||
field = "Use VSS As Second Wheel Speed", useVssAsSecondWheelSpeed
|
||||
|
||||
dialog = sentInputs, "SENT protocol inputs"
|
||||
field = "SENT Input #1", sentInputPins1
|
||||
|
||||
; Sensors->MAP sensor
|
||||
dialog = mapSensorAnalog, "MAP sensor", yAxis
|
||||
|
|
Loading…
Reference in New Issue