microRusEFI used as Body Control Module BCM BCU
This commit is contained in:
parent
b04a4ec04c
commit
294ca5aae3
|
@ -14,6 +14,8 @@
|
|||
#define CAN_PEDAL_TPS_OFFSET 2
|
||||
#define CAN_SENSOR_1_OFFSET 3
|
||||
|
||||
#define CAN_TIMEOUT MS2NT(100)
|
||||
|
||||
class Logging;
|
||||
class CanSensorBase;
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ static void handleGetDataRequest(const CANRxFrame& rx) {
|
|||
obdSendValue(_1_MODE, pid, 2, (2<<8)|(0)); // 2 = "Closed loop, using oxygen sensor feedback to determine fuel mix"
|
||||
break;
|
||||
case PID_ENGINE_LOAD:
|
||||
obdSendValue(_1_MODE, pid, 1, getFuelingLoad(PASS_ENGINE_PARAMETER_SIGNATURE) * 2.55f);
|
||||
obdSendValue(_1_MODE, pid, 1, getFuelingLoad(PASS_ENGINE_PARAMETER_SIGNATURE) * ODB_TPS_BYTE_PERCENT);
|
||||
break;
|
||||
case PID_COOLANT_TEMP:
|
||||
obdSendValue(_1_MODE, pid, 1, Sensor::get(SensorType::Clt).value_or(0) + ODB_TEMP_EXTRA);
|
||||
|
@ -154,7 +154,7 @@ static void handleGetDataRequest(const CANRxFrame& rx) {
|
|||
obdSendValue(_1_MODE, pid, 2, getRealMaf(PASS_ENGINE_PARAMETER_SIGNATURE) * 100.0f); // grams/sec (A*256+B)/100
|
||||
break;
|
||||
case PID_THROTTLE:
|
||||
obdSendValue(_1_MODE, pid, 1, Sensor::get(SensorType::Tps1).value_or(0) * 2.55f); // (A*100/255)
|
||||
obdSendValue(_1_MODE, pid, 1, Sensor::get(SensorType::Tps1).value_or(0) * ODB_TPS_BYTE_PERCENT); // (A*100/255)
|
||||
break;
|
||||
case PID_FUEL_AIR_RATIO_1: {
|
||||
float lambda = Sensor::get(SensorType::Lambda).value_or(0);
|
||||
|
|
|
@ -45,3 +45,4 @@ void obdOnCanPacketRx(const CANRxFrame& rx);
|
|||
|
||||
#define ODB_RPM_MULT 4
|
||||
#define ODB_TEMP_EXTRA 40
|
||||
#define ODB_TPS_BYTE_PERCENT 2.55f
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "hal.h"
|
||||
#include "can_msg_tx.h"
|
||||
#include "obd2.h"
|
||||
#include "can.h"
|
||||
|
||||
/**
|
||||
* Sensor which reads it's value from CAN
|
||||
|
@ -79,12 +80,13 @@ private:
|
|||
const uint8_t m_offset;
|
||||
};
|
||||
|
||||
template <int Size, int TScale>
|
||||
template <int Size, int Offset>
|
||||
class ObdCanSensor: public CanSensorBase {
|
||||
public:
|
||||
ObdCanSensor(int PID, SensorType type, efitick_t timeout) :
|
||||
CanSensorBase(OBD_TEST_RESPONSE, type, timeout) {
|
||||
ObdCanSensor(int PID, float Scale, SensorType type) :
|
||||
CanSensorBase(OBD_TEST_RESPONSE, type, CAN_TIMEOUT) {
|
||||
this->PID = PID;
|
||||
this->Scale = Scale;
|
||||
}
|
||||
|
||||
void decodeFrame(const CANRxFrame& frame, efitick_t nowNt) override {
|
||||
|
@ -99,7 +101,7 @@ public:
|
|||
iValue = frame.data8[3];
|
||||
}
|
||||
|
||||
float fValue = 1.0 * iValue / TScale;
|
||||
float fValue = (1.0 * iValue / Scale) - Offset;
|
||||
setValidValue(fValue, nowNt);
|
||||
}
|
||||
|
||||
|
@ -114,5 +116,6 @@ public:
|
|||
}
|
||||
|
||||
int PID;
|
||||
float Scale;
|
||||
};
|
||||
|
||||
|
|
|
@ -14,30 +14,43 @@
|
|||
EXTERN_CONFIG
|
||||
;
|
||||
|
||||
|
||||
#define TIMEOUT MS2NT(100)
|
||||
|
||||
CanSensor<int16_t, PACK_MULT_PERCENT> canPedalSensor(
|
||||
CAN_DEFAULT_BASE + CAN_PEDAL_TPS_OFFSET, /*offset =*/ 0,
|
||||
SensorType::AcceleratorPedal, TIMEOUT
|
||||
SensorType::AcceleratorPedal, CAN_TIMEOUT
|
||||
);
|
||||
|
||||
ObdCanSensor<2, ODB_RPM_MULT> obdRpmSensor(
|
||||
PID_RPM,
|
||||
SensorType::Rpm, TIMEOUT
|
||||
ObdCanSensor<2, 0> obdRpmSensor(
|
||||
PID_RPM, ODB_RPM_MULT,
|
||||
SensorType::Rpm
|
||||
);
|
||||
|
||||
ObdCanSensor<1, 1> obdCltSensor(
|
||||
PID_COOLANT_TEMP,
|
||||
SensorType::Clt, TIMEOUT
|
||||
ObdCanSensor<1, ODB_TEMP_EXTRA> obdCltSensor(
|
||||
PID_COOLANT_TEMP, 1,
|
||||
SensorType::Clt
|
||||
);
|
||||
|
||||
ObdCanSensor<1, ODB_TEMP_EXTRA> obdIatSensor(
|
||||
PID_INTAKE_TEMP, 1,
|
||||
SensorType::Iat
|
||||
);
|
||||
|
||||
ObdCanSensor<1, 0> obdTpsSensor(
|
||||
PID_INTAKE_TEMP, ODB_TPS_BYTE_PERCENT,
|
||||
SensorType::Tps1
|
||||
);
|
||||
|
||||
//ObdCanSensor<1, ODB_TPS_BYTE_PERCENT> obdTpsSensor(
|
||||
// PID_ENGINE_LOAD,
|
||||
// SensorType::Tps, TIMEOUT
|
||||
//);
|
||||
|
||||
void initCanSensors() {
|
||||
if (CONFIG(consumeObdSensors)) {
|
||||
// registerCanSensor(canPedalSensor);
|
||||
registerCanSensor(obdRpmSensor);
|
||||
// registerCanSensor(obdCltSensor);
|
||||
// registerCanSensor(obdIatSensor);
|
||||
// registerCanSensor(obdTpsSensor);
|
||||
}
|
||||
}
|
||||
#endif // EFI_CAN_SUPPORT
|
||||
|
|
Loading…
Reference in New Issue