Skip to content

Commit

Permalink
sanity in IMU data names/ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
mck1117 committed Nov 27, 2023
1 parent 28fbe86 commit c7cc2de
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 54 deletions.
10 changes: 4 additions & 6 deletions firmware/console/binary/output_channels.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,8 @@ int16_t rpmAcceleration;dRPM;"RPM acceleration",1, 0, 0, 5, 2

int16_t autoscale rawWastegatePosition;;"V",{1/@@PACK_MULT_VOLTAGE@@}, 0, 0, 5, 3

! todo: reimplement { LIS302DLCsPin != 0 || imuType != 0 }
int16_t autoscale accelerationX;@@GAUGE_NAME_ACCEL_X@@;"G",{1/@@PACK_MULT_PERCENT@@}, 0, 0, 0, 2
int16_t autoscale accelerationY;@@GAUGE_NAME_ACCEL_Y@@;"G",{1/@@PACK_MULT_PERCENT@@}, 0, 0, 0, 2
int16_t autoscale accelerationLat;@@GAUGE_NAME_ACCEL_LAT@@;"G",{1/1000}, 0, 0, 0, 0
int16_t autoscale accelerationLon;@@GAUGE_NAME_ACCEL_LON@@;"G",{1/1000}, 0, 0, 0, 0

uint8_t detectedGear;@@GAUGE_NAME_DETECTED_GEAR@@;"", 1, 0, 0, @@GEARS_COUNT@@, 0
uint8_t maxTriggerReentrant;;"", 1, 0, 0, 100, 0
Expand Down Expand Up @@ -203,9 +202,8 @@ int16_t rpmAcceleration;dRPM;"RPM acceleration",1, 0, 0, 5, 2

int16_t autoscale rawTps2Secondary;;"V",{1/@@PACK_MULT_VOLTAGE@@}, 0, 0, 5, 3

int16_t autoscale accelerationZ;@@GAUGE_NAME_ACCEL_Z@@;"G",{1/@@PACK_MULT_PERCENT@@}, 0, 0, 0, 0
int16_t autoscale accelerationRoll;@@GAUGE_NAME_ACCEL_ROLL@@;"G",{1/@@PACK_MULT_PERCENT@@}, 0, 0, 0, 0
int16_t autoscale accelerationYaw;@@GAUGE_NAME_ACCEL_YAW@@;"G",{1/@@PACK_MULT_PERCENT@@}, 0, 0, 0, 0
int16_t autoscale accelerationVert;@@GAUGE_NAME_ACCEL_VERT@@;"G",{1/1000}, 0, 0, 0, 0
int16_t autoscale gyroYaw;@@GAUGE_NAME_GYRO_YAW@@;"deg/sec",{1/1000}, 0, 0, 0, 0

int8_t[4 iterate] vvtTargets;;"deg",1, 0, 0, 0, 0
uint16_t turboSpeed;@@GAUGE_NAME_TURBO_SPEED@@;"hz",1, 0, 0, 0, 0
Expand Down
11 changes: 4 additions & 7 deletions firmware/console/status_loop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,13 +620,10 @@ void updateTunerStudioState() {
// 120
tsOutputChannels->firmwareVersion = getRusEfiVersion();

// 276
tsOutputChannels->accelerationX = engine->sensors.accelerometer.x;
// 278
tsOutputChannels->accelerationY = engine->sensors.accelerometer.y;
tsOutputChannels->accelerationZ = engine->sensors.accelerometer.z;
tsOutputChannels->accelerationRoll = engine->sensors.accelerometer.roll;
tsOutputChannels->accelerationYaw = engine->sensors.accelerometer.yaw;
tsOutputChannels->accelerationLat = engine->sensors.accelerometer.lat;
tsOutputChannels->accelerationLon = engine->sensors.accelerometer.lon;
tsOutputChannels->accelerationVert = engine->sensors.accelerometer.vert;
tsOutputChannels->gyroYaw = engine->sensors.accelerometer.yawRate;

#if EFI_DYNO_VIEW
tsOutputChannels->VssAcceleration = getDynoviewAcceleration();
Expand Down
9 changes: 4 additions & 5 deletions firmware/controllers/algo/engine_parts.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@
#define MOCK_ADC_SIZE 26

struct Accelerometer {
float x = 0; // G value
float y = 0;
float z = 0;
float yaw = 0;
float roll = 0;
float lat = 0; // G value
float lon = 0;
float vert = 0;
float yawRate = 0;
};

struct SensorsState {
Expand Down
12 changes: 5 additions & 7 deletions firmware/controllers/can/can_rx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,23 +139,21 @@ static void processCanRxImu_BoschM5_10_YawY(const CANRxFrame& frame) {
float accY = getShiftedLSB_intel(frame, 4);

efiPrintf("CAN_rx MM5_10_YAW_Y %f %f", yaw, accY);
engine->sensors.accelerometer.yaw = yaw * MM5_10_RATE_QUANT;
engine->sensors.accelerometer.y = accY * MM5_10_ACC_QUANT;
engine->sensors.accelerometer.yawRate = yaw * MM5_10_RATE_QUANT;
engine->sensors.accelerometer.lat = accY * MM5_10_ACC_QUANT;
}

static void processCanRxImu_BoschM5_10_RollX(const CANRxFrame& frame) {
float roll = getShiftedLSB_intel(frame, 0);
float accX = getShiftedLSB_intel(frame, 4);
efiPrintf("CAN_rx MM5_10_ROLL_X %f %f", roll, accX);
efiPrintf("CAN_rx MM5_10_ROLL_X %f", accX);

engine->sensors.accelerometer.roll = roll * MM5_10_RATE_QUANT;
engine->sensors.accelerometer.x = accX * MM5_10_ACC_QUANT;
engine->sensors.accelerometer.lon = accX * MM5_10_ACC_QUANT;
}

static void processCanRxImu_BoschM5_10_Z(const CANRxFrame& frame) {
float accZ = getShiftedLSB_intel(frame, 4);
efiPrintf("CAN_rx MM5_10_Z %f", accZ);
engine->sensors.accelerometer.z = accZ * MM5_10_ACC_QUANT;
engine->sensors.accelerometer.vert = accZ * MM5_10_ACC_QUANT;
}

static void processCanRxImu(const CANRxFrame& frame) {
Expand Down
9 changes: 0 additions & 9 deletions firmware/hw_layer/sensors/accelerometer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,3 @@ void initAccelerometer() {
}

#endif /* EFI_MEMS */


float getLongitudinalAcceleration() {
return engine->sensors.accelerometer.x;
}

float getTransverseAcceleration() {
return engine->sensors.accelerometer.y;
}
10 changes: 0 additions & 10 deletions firmware/hw_layer/sensors/accelerometer.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,3 @@
#pragma once

void initAccelerometer();

/**
* Acceleration/braking
*/
float getLongitudinalAcceleration();
/**
* Turns
*/
float getTransverseAcceleration();

9 changes: 4 additions & 5 deletions firmware/integration/rusefi_config_shared.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,10 @@
#define GAUGE_NAME_FUEL_PRESSURE_HIGH_UNITS "bar"
#define GAUGE_NAME_FLEX "Flex Ethanol %"

#define GAUGE_NAME_ACCEL_X "Acceleration: X"
#define GAUGE_NAME_ACCEL_Y "Acceleration: Y"
#define GAUGE_NAME_ACCEL_Z "Acceleration: Z"
#define GAUGE_NAME_ACCEL_ROLL "Acceleration: Roll"
#define GAUGE_NAME_ACCEL_YAW "Acceleration: Yaw"
#define GAUGE_NAME_ACCEL_LAT "Accel: Lateral"
#define GAUGE_NAME_ACCEL_LON "Accel: Longitudinal"
#define GAUGE_NAME_ACCEL_VERT "Accel: Vertical"
#define GAUGE_NAME_GYRO_YAW "Gyro: Yaw rate"

#define GAUGE_NAME_BARO_PRESSURE "Barometric pressure"

Expand Down
9 changes: 4 additions & 5 deletions firmware/tunerstudio/rusefi.input
Original file line number Diff line number Diff line change
Expand Up @@ -1357,11 +1357,10 @@ gaugeCategory = Sensors - Extra 1
AuxL2Gauge = auxLinear2, @@GAUGE_NAME_AUX_LINEAR_2@@, "", -100, 100, -100, -100, 100, 100, 2, 2

gaugeCategory = Sensors - Extra 2
accelerationXGauge = accelerationX, @@GAUGE_NAME_ACCEL_X@@, "acc", -11, 11, 1.0, 1.2, 100, 100, 3, 1
accelerationYGauge = accelerationY, @@GAUGE_NAME_ACCEL_Y@@, "acc", -11, 11, 1.0, 1.2, 100, 100, 3, 1
accelerationZGauge = accelerationZ, @@GAUGE_NAME_ACCEL_Z@@, "acc", -11, 11, 1.0, 1.2, 100, 100, 3, 1
accelerationRollGauge=accelerationRoll, @@GAUGE_NAME_ACCEL_ROLL@@, "acc", -11, 11, 1.0, 1.2, 100, 100, 3, 1
accelerationYawGauge=accelerationYaw, @@GAUGE_NAME_ACCEL_YAW@@, "acc", -11, 11, 1.0, 1.2, 100, 100, 3, 1
accelerationLatGauge = accelerationLat, @@GAUGE_NAME_ACCEL_LAT@@, "acc", -2, 2, -2, -1, 1, 2, 3, 1
accelerationLonGauge = accelerationLon, @@GAUGE_NAME_ACCEL_LON@@, "acc", -2, 2, -2, -1, 1, 2, 3, 1
accelerationVertGauge = accelerationVert, @@GAUGE_NAME_ACCEL_VERT@@, "acc", 0, 1.5, 0.5, 0.6, 1.4, 1.5, 3, 1
gyroYawGauge = gyroYaw, @@GAUGE_NAME_GYRO_YAW@@, "acc", -100, 100, -100, -100, 100, 100, 3, 1
egt1Gauge = egt1, "EGT#1", "C", 0, 2000
egt2Gauge = egt2, "EGT#2", "C", 0, 2000
rpmAccelerationGa = rpmAcceleration, "rpm delta", "RPM/s", -2000, 2000, -2000, 2000, -2000, 2000, 0, 0
Expand Down

0 comments on commit c7cc2de

Please sign in to comment.