front to rear axle speed slip rate gauge #5842
This commit is contained in:
parent
002ef5af04
commit
6f9f6f8702
|
@ -375,5 +375,7 @@ float mapFast
|
||||||
uint16_t autoscale afrGasolineScale;@@GAUGE_NAME_AFR_GAS_SCALE@@;"AFR",{1/@@PACK_MULT_AFR@@}, 0, 0, 0, 2
|
uint16_t autoscale afrGasolineScale;@@GAUGE_NAME_AFR_GAS_SCALE@@;"AFR",{1/@@PACK_MULT_AFR@@}, 0, 0, 0, 2
|
||||||
uint16_t autoscale afr2GasolineScale;@@GAUGE_NAME_AFR2_GAS_SCALE@@;"AFR",{1/@@PACK_MULT_AFR@@}, 0, 0, 0, 2
|
uint16_t autoscale afr2GasolineScale;@@GAUGE_NAME_AFR2_GAS_SCALE@@;"AFR",{1/@@PACK_MULT_AFR@@}, 0, 0, 0, 2
|
||||||
|
|
||||||
uint8_t[120 iterate] unusedAtTheEnd;;"",1, 0, 0, 0, 0
|
float wheelSlipRatio
|
||||||
|
|
||||||
|
uint8_t[116 iterate] unusedAtTheEnd;;"",1, 0, 0, 0, 0
|
||||||
end_struct
|
end_struct
|
||||||
|
|
|
@ -450,6 +450,7 @@ static void updateVvtSensors() {
|
||||||
static void updateVehicleSpeed() {
|
static void updateVehicleSpeed() {
|
||||||
#if EFI_VEHICLE_SPEED
|
#if EFI_VEHICLE_SPEED
|
||||||
engine->outputChannels.vehicleSpeedKph = Sensor::getOrZero(SensorType::VehicleSpeed);
|
engine->outputChannels.vehicleSpeedKph = Sensor::getOrZero(SensorType::VehicleSpeed);
|
||||||
|
engine->outputChannels.wheelSlipRatio = Sensor::getOrZero(SensorType::WheelSlipRatio);
|
||||||
engine->outputChannels.speedToRpmRatio = engine->module<GearDetector>()->getGearboxRatio();
|
engine->outputChannels.speedToRpmRatio = engine->module<GearDetector>()->getGearboxRatio();
|
||||||
engine->outputChannels.detectedGear = Sensor::getOrZero(SensorType::DetectedGear);
|
engine->outputChannels.detectedGear = Sensor::getOrZero(SensorType::DetectedGear);
|
||||||
#endif /* EFI_VEHICLE_SPEED */
|
#endif /* EFI_VEHICLE_SPEED */
|
||||||
|
@ -733,10 +734,10 @@ void updateTunerStudioState() {
|
||||||
tle8888PostState();
|
tle8888PostState();
|
||||||
#endif /* BOARD_TLE8888_COUNT */
|
#endif /* BOARD_TLE8888_COUNT */
|
||||||
break;
|
break;
|
||||||
case DBG_LOGIC_ANALYZER:
|
case DBG_LOGIC_ANALYZER:
|
||||||
#if EFI_LOGIC_ANALYZER
|
#if EFI_LOGIC_ANALYZER
|
||||||
reportLogicAnalyzerToTS();
|
reportLogicAnalyzerToTS();
|
||||||
#endif /* EFI_LOGIC_ANALYZER */
|
#endif /* EFI_LOGIC_ANALYZER */
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
;
|
;
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
static bool isInit = false;
|
static bool isInit = false;
|
||||||
static uint16_t filterVssCanID = 0;
|
static uint16_t filterVssCanID = 0;
|
||||||
|
static uint16_t filterSecondVssCanID = 0;
|
||||||
static uint16_t filterRpmCanID = 0;
|
static uint16_t filterRpmCanID = 0;
|
||||||
|
|
||||||
static expected<uint16_t> look_up_rpm_can_id(can_vss_nbc_e type) {
|
static expected<uint16_t> look_up_rpm_can_id(can_vss_nbc_e type) {
|
||||||
|
@ -38,9 +39,11 @@ static expected<uint16_t> look_up_vss_can_id(can_vss_nbc_e type) {
|
||||||
case BMW_e90:
|
case BMW_e90:
|
||||||
return 0x1A0; // BMW E90 ABS speed frame (not wheel speeds, vehicle speed)
|
return 0x1A0; // BMW E90 ABS speed frame (not wheel speeds, vehicle speed)
|
||||||
case NISSAN_350:
|
case NISSAN_350:
|
||||||
return 0x280;
|
// decimal 640 0x280 has cluster speed but we use wheel speeds
|
||||||
|
return /*0x284*/644;
|
||||||
case HYUNDAI_PB:
|
case HYUNDAI_PB:
|
||||||
return 1264; // decimal 1264
|
// decimal 1264 0x4F0 CLU1 has cluster speed but we use wheel speeds
|
||||||
|
return /*0x1F1*/497;
|
||||||
case HONDA_CIVIC9:
|
case HONDA_CIVIC9:
|
||||||
return 0x309;
|
return 0x309;
|
||||||
case W202:
|
case W202:
|
||||||
|
@ -51,12 +54,29 @@ static expected<uint16_t> look_up_vss_can_id(can_vss_nbc_e type) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint16_t look_up_second_vss_can_id(can_vss_nbc_e type) {
|
||||||
|
switch (type) {
|
||||||
|
case NISSAN_350:
|
||||||
|
// decimal 640 0x280 has cluster speed but we use wheel speeds
|
||||||
|
return /*0x285*/645;
|
||||||
|
default:
|
||||||
|
// it's OK not to require second packet
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int getTwoBytesLsb(const CANRxFrame& frame, int index) {
|
static int getTwoBytesLsb(const CANRxFrame& frame, int index) {
|
||||||
uint8_t low = frame.data8[index];
|
uint8_t low = frame.data8[index];
|
||||||
uint8_t high = frame.data8[index + 1] & 0xFF;
|
uint8_t high = frame.data8[index + 1] & 0xFF;
|
||||||
return low | (high << 8);
|
return low | (high << 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int getTwoBytesMsb(const CANRxFrame& frame, int index) {
|
||||||
|
uint8_t low = frame.data8[index + 1];
|
||||||
|
uint8_t high = frame.data8[index] & 0x0FF;
|
||||||
|
return low | (high << 8);
|
||||||
|
}
|
||||||
|
|
||||||
/* Module specific processing functions */
|
/* Module specific processing functions */
|
||||||
/* source: http://z4evconversion.blogspot.com/2016/07/completely-forgot-but-it-does-live-on.html */
|
/* source: http://z4evconversion.blogspot.com/2016/07/completely-forgot-but-it-does-live-on.html */
|
||||||
float processBMW_e46(const CANRxFrame& frame) {
|
float processBMW_e46(const CANRxFrame& frame) {
|
||||||
|
@ -67,6 +87,19 @@ float processBMW_e46(const CANRxFrame& frame) {
|
||||||
return (left + right) / (16 * 2);
|
return (left + right) / (16 * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// open question if that's front axle or rear axle?
|
||||||
|
static int nissanFrontAxle = 0;
|
||||||
|
|
||||||
|
float processNissan(const CANRxFrame& frame) {
|
||||||
|
// todo: open question which one is left which one is right
|
||||||
|
int left = getTwoBytesMsb(frame, 0);
|
||||||
|
int right = getTwoBytesMsb(frame, 2);
|
||||||
|
|
||||||
|
nissanFrontAxle = left + right;
|
||||||
|
|
||||||
|
return nissanFrontAxle / (100 * 2);
|
||||||
|
}
|
||||||
|
|
||||||
float processBMW_e90(const CANRxFrame& frame) {
|
float processBMW_e90(const CANRxFrame& frame) {
|
||||||
return 0.1f * getTwoBytesLsb(frame, 0);
|
return 0.1f * getTwoBytesLsb(frame, 0);
|
||||||
}
|
}
|
||||||
|
@ -87,7 +120,8 @@ expected<float> processCanRxVssImpl(const CANRxFrame& frame) {
|
||||||
return processBMW_e90(frame);
|
return processBMW_e90(frame);
|
||||||
case W202:
|
case W202:
|
||||||
return processW202(frame);
|
return processW202(frame);
|
||||||
// case NISSAN_350:
|
case NISSAN_350:
|
||||||
|
return processNissan(frame);
|
||||||
default:
|
default:
|
||||||
efiPrintf("vss unsupported can option selected %x", engineConfiguration->canVssNbcType );
|
efiPrintf("vss unsupported can option selected %x", engineConfiguration->canVssNbcType );
|
||||||
}
|
}
|
||||||
|
@ -96,6 +130,27 @@ expected<float> processCanRxVssImpl(const CANRxFrame& frame) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static StoredValueSensor canSpeed(SensorType::VehicleSpeed, MS2NT(500));
|
static StoredValueSensor canSpeed(SensorType::VehicleSpeed, MS2NT(500));
|
||||||
|
static StoredValueSensor wheelSlipRatio(SensorType::WheelSlipRatio, MS2NT(1000));
|
||||||
|
|
||||||
|
static void processNissanSecondVss(const CANRxFrame& frame, efitick_t nowNt) {
|
||||||
|
// todo: open question which one is left which one is right
|
||||||
|
int left = getTwoBytesMsb(frame, 0);
|
||||||
|
int right = getTwoBytesMsb(frame, 2);
|
||||||
|
|
||||||
|
int rearAxle = left + right;
|
||||||
|
|
||||||
|
wheelSlipRatio.setValidValue(1.0 * nissanFrontAxle / rearAxle, nowNt);
|
||||||
|
}
|
||||||
|
|
||||||
|
void processCanRxSecondVss(const CANRxFrame& frame, efitick_t nowNt) {
|
||||||
|
switch (engineConfiguration->canVssNbcType) {
|
||||||
|
case NISSAN_350:
|
||||||
|
processNissanSecondVss(frame, nowNt);
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
criticalError("Unexpected processCanRxSecondVss %d", (int)engineConfiguration->canVssNbcType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void processCanRxVss(const CANRxFrame& frame, efitick_t nowNt) {
|
void processCanRxVss(const CANRxFrame& frame, efitick_t nowNt) {
|
||||||
if ((!engineConfiguration->enableCanVss) || (!isInit)) {
|
if ((!engineConfiguration->enableCanVss) || (!isInit)) {
|
||||||
|
@ -113,6 +168,11 @@ void processCanRxVss(const CANRxFrame& frame, efitick_t nowNt) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (CAN_SID(frame) == filterSecondVssCanID) {
|
||||||
|
processCanRxSecondVss(frame, nowNt);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (CAN_SID(frame) == filterRpmCanID) {
|
if (CAN_SID(frame) == filterRpmCanID) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +182,9 @@ void initCanVssSupport() {
|
||||||
if (engineConfiguration->enableCanVss) {
|
if (engineConfiguration->enableCanVss) {
|
||||||
if (auto canId = look_up_vss_can_id(engineConfiguration->canVssNbcType)) {
|
if (auto canId = look_up_vss_can_id(engineConfiguration->canVssNbcType)) {
|
||||||
filterVssCanID = canId.Value;
|
filterVssCanID = canId.Value;
|
||||||
|
filterSecondVssCanID = look_up_second_vss_can_id(engineConfiguration->canVssNbcType);
|
||||||
canSpeed.Register();
|
canSpeed.Register();
|
||||||
|
wheelSlipRatio.Register();
|
||||||
isInit = true;
|
isInit = true;
|
||||||
} else {
|
} else {
|
||||||
isInit = false;
|
isInit = false;
|
||||||
|
|
|
@ -1437,6 +1437,7 @@ gaugeCategory = Sensors - Basic
|
||||||
;Name Var Title Units Lo Hi LoD LoW HiW HiD vd ld
|
;Name Var Title Units Lo Hi LoD LoW HiW HiD vd ld
|
||||||
gaugeCategory = Sensors - Extra 1
|
gaugeCategory = Sensors - Extra 1
|
||||||
VSSGauge = vehicleSpeedKph, @@GAUGE_NAME_VVS@@, "kmh", 0, 200, 0, 1, 3, 4, 1, 1
|
VSSGauge = vehicleSpeedKph, @@GAUGE_NAME_VVS@@, "kmh", 0, 200, 0, 1, 3, 4, 1, 1
|
||||||
|
wheelSlipRatioGauge = wheelSlipRatio, "Wheel Slip Ratio", "", 0, 200, 0, 1, 3, 4, 3, 3
|
||||||
turboSpeedGauge = turboSpeed, @@GAUGE_NAME_TURBO_SPEED@@, "hz", 0, 200, 0, 1, 3, 4, 1, 1
|
turboSpeedGauge = turboSpeed, @@GAUGE_NAME_TURBO_SPEED@@, "hz", 0, 200, 0, 1, 3, 4, 1, 1
|
||||||
baroPressureGauge = baroPressure, @@GAUGE_NAME_BARO_PRESSURE@@, "kPa", 0, 1024, 0, 0, 0, 0, 0, 0
|
baroPressureGauge = baroPressure, @@GAUGE_NAME_BARO_PRESSURE@@, "kPa", 0, 1024, 0, 0, 0, 0, 0, 0
|
||||||
internalMcuTemperatureGauge = internalMcuTemperature, @@GAUGE_NAME_ECU_TEMPERATURE@@, "C", 0, 100, 0, 0, 75, 100, 0, 0
|
internalMcuTemperatureGauge = internalMcuTemperature, @@GAUGE_NAME_ECU_TEMPERATURE@@, "C", 0, 100, 0, 0, 75, 100, 0, 0
|
||||||
|
|
Loading…
Reference in New Issue