some cheap used junkyard Accelerometer #2225

MM5.10
This commit is contained in:
rusefillc 2021-10-05 16:21:41 -04:00
parent 5a53fb3d28
commit 77c4e83ebc
4 changed files with 37 additions and 4 deletions

View File

@ -221,8 +221,8 @@ struct TunerStudioOutputChannels {
scaled_channel<uint16_t> debugIntField5; // 210
// accelerometer
int16_t accelerationX; // 212
int16_t accelerationY; // 214
scaled_channel<int16_t, PACK_MULT_PERCENT> accelerationX; // 212
scaled_channel<int16_t, PACK_MULT_PERCENT> accelerationY; // 214
// EGT
egt_values_s egtValues; // 216

View File

@ -39,6 +39,11 @@ static constexpr LogField fields[] = {
{tsOutputChannels.lastErrorCode, GAUGE_NAME_WARNING_LAST, "", 0},
{tsOutputChannels.tuneCrc16, GAUGE_NAME_TUNE_CRC16, "", 0},
{tsOutputChannels.engineMakeCodeNameCrc16, GAUGE_NAME_ENGINE_CRC16, "", 0},
{tsOutputChannels.firmwareVersion, GAUGE_NAME_VERSION, "", 0},
{tsOutputChannels.accelerationX, GAUGE_NAME_ACCEL_X, "", 2},
{tsOutputChannels.accelerationY, GAUGE_NAME_ACCEL_Y, "", 2},
{tsOutputChannels.debugIntField1, GAUGE_NAME_DEBUG_I1, "", 0},
{tsOutputChannels.debugIntField2, GAUGE_NAME_DEBUG_I2, "", 0},
{tsOutputChannels.debugIntField3, GAUGE_NAME_DEBUG_I3, "", 0},

View File

@ -101,6 +101,10 @@ void registerCanSensor(CanSensorBase& sensor) {
#define VAG_YAW_RATE_G_LAT 0x130
#define VAG_YAW_ACCEL_G_LONG 0x131
#define MM5_10_YAW_Y 0x174
#define MM5_10_ROLL_X 0x178
#define MM5_10_Z 0x17C
static uint16_t getLSB_intel(const CANRxFrame& frame, int offset) {
return (frame.data8[offset + 1] << 8) + frame.data8[offset];
}
@ -110,6 +114,7 @@ static int16_t getShiftedLSB_intel(const CANRxFrame& frame, int offset) {
}
static void processCanRxImu(const CANRxFrame& frame, efitick_t nowNt) {
/*
if (CAN_SID(frame) == 0x130) {
float a = getShiftedLSB_intel(frame, 0);
float b = getShiftedLSB_intel(frame, 4);
@ -123,6 +128,29 @@ static void processCanRxImu(const CANRxFrame& frame, efitick_t nowNt) {
efiPrintf("CAN_rx VAG_YAW_ACCEL_G_LONG");
}
}
*/
if (CONFIG(imuType) == IMU_MM5_10) {
#define MM5_10_RATE_QUANT 0.005
#define MM5_10_ACC_QUANT 0.0001274
if (CAN_SID(frame) == MM5_10_YAW_Y) {
float yaw = getShiftedLSB_intel(frame, 0);
float accY = getShiftedLSB_intel(frame, 4);
efiPrintf("CAN_rx MM5_10_YAW_Y %f %f", yaw, accY);
engine->sensors.accelerometer.y = accY * MM5_10_ACC_QUANT;
} else if (CAN_SID(frame) == MM5_10_ROLL_X) {
float roll = getShiftedLSB_intel(frame, 0);
float accX = getShiftedLSB_intel(frame, 4);
efiPrintf("CAN_rx MM5_10_ROLL_X %f %f", roll, accX);
engine->sensors.accelerometer.x = accX * MM5_10_ACC_QUANT;
}
}
}
void processCanRxMessage(const CANRxFrame &frame, efitick_t nowNt) {

View File

@ -340,8 +340,8 @@ enable2ndByteCanID = false
debugIntField5 = scalar, S16, 210, "val", 1, 0.0
; Accel
accelerationX = scalar, S16, 212, "G", 0.01, 0
accelerationY = scalar, S16, 214, "G", 0.01, 0
accelerationX = scalar, S16, 212, "G", {1/@@PACK_MULT_PERCENT@@}, 0
accelerationY = scalar, S16, 214, "G", {1/@@PACK_MULT_PERCENT@@}, 0
; egt
egt1 = scalar, S16, 216, "deg C", 1, 0