Skip to content

Commit

Permalink
Small bug fix, to correct TPS value over OBD2 (speeduino#1194)
Browse files Browse the repository at this point in the history
* Fix OBD2 TPS value

* Fix the TPS on CAN broadcast too
  • Loading branch information
pazi88 authored Mar 16, 2024
1 parent 6f9348a commit e2bcac6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions speeduino/comms_CAN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void DashMessage(uint16_t DashMessageID)
uint8_t temp_TPS;
uint8_t temp_BARO;
uint16_t temp_CLT;
temp_TPS = map(currentStatus.TPS, 0, 100, 0, 254);//TPS value conversion (from 0x00 to 0xFE)
temp_TPS = map(currentStatus.TPS, 0, 200, 1, 254);//TPS value conversion (from 0x01 to 0xFE)
temp_CLT = (((currentStatus.coolant - CALIBRATION_TEMPERATURE_OFFSET) + 48)*4/3); //CLT conversion (actual value to add is 48.373, but close enough)
if (temp_CLT > 255) { temp_CLT = 255; } //CLT conversion can yield to higher values than what fits to byte, so limit the maximum value to 255.
temp_BARO = currentStatus.baro;
Expand Down Expand Up @@ -363,7 +363,7 @@ void obd_response(uint8_t PIDmode, uint8_t requestedPIDlow, uint8_t requestedPID
// TPS percentage, range is 0 to 100 percent, formula == 100/256 A
uint16_t temp_tpsPC;
temp_tpsPC = currentStatus.TPS;
obdcalcA = (temp_tpsPC <<8) / 100; // (tpsPC *256) /100;
obdcalcA = (temp_tpsPC <<8) / 200; // (tpsPC *256) /200;
if (obdcalcA > 255){ obdcalcA = 255;}
outMsg.buf[0] = 0x03; // sending 3 bytes
outMsg.buf[1] = 0x41; // Same as query, except that 40h is added to the mode value. So:41h = show current data ,42h = freeze frame ,etc.
Expand Down

0 comments on commit e2bcac6

Please sign in to comment.