summaryrefslogtreecommitdiff
path: root/libraries
diff options
context:
space:
mode:
authorStanley Huang <stanleyhuangyc@gmail.com>2014-01-04 12:00:27 +1100
committerStanley Huang <stanleyhuangyc@gmail.com>2014-01-04 12:00:27 +1100
commit9f525a76fa72de7078868cd4b818cdd83043a3ec (patch)
treec8447ca3e2da4b65c102ba174817cd863a9d319e /libraries
parentba3954b0817e10c2f514786005c302b7d707358f (diff)
download2021-arduino-obd-9f525a76fa72de7078868cd4b818cdd83043a3ec.tar.gz
2021-arduino-obd-9f525a76fa72de7078868cd4b818cdd83043a3ec.tar.bz2
2021-arduino-obd-9f525a76fa72de7078868cd4b818cdd83043a3ec.zip
Update OBD PIDs definition
Diffstat (limited to 'libraries')
-rw-r--r--libraries/OBD/OBD.cpp22
-rw-r--r--libraries/OBD/OBD.h28
2 files changed, 36 insertions, 14 deletions
diff --git a/libraries/OBD/OBD.cpp b/libraries/OBD/OBD.cpp
index 3360d07..c357da1 100644
--- a/libraries/OBD/OBD.cpp
+++ b/libraries/OBD/OBD.cpp
@@ -130,10 +130,13 @@ int COBD::normalizeData(byte pid, char* data)
case PID_COOLANT_TEMP:
case PID_INTAKE_TEMP:
case PID_AMBIENT_TEMP:
+ case PID_ENGINE_OIL_TEMP:
result = getTemperatureValue(data);
break;
- case PID_ABS_ENGINE_LOAD:
- result = getLargeValue(data) * 100 / 255;
+ case PID_ABSOLUTE_ENGINE_LOAD:
+ case PID_ETHANOL_PERCENTAGE:
+ case PID_HYBRID_BATTERY_PERCENTAGE:
+ result = getLargeValue(data) * 100 / 255; // %
break;
case PID_MAF_FLOW:
result = getLargeValue(data) / 100;
@@ -146,10 +149,21 @@ int COBD::normalizeData(byte pid, char* data)
case PID_TIMING_ADVANCE:
result = (getSmallValue(data) - 128) >> 1;
break;
- case PID_DISTANCE:
- case PID_RUNTIME:
+ case PID_DISTANCE: // km
+ case PID_RUNTIME: // second
+ case PID_FUEL_RAIL_PRESSURE: // kPa
+ case PID_ENGINE_REF_TORQUE: // Nm
result = getLargeValue(data);
break;
+ case PID_CONTROL_MODULE_VOLTAGE: // V
+ result = getLargeValue(data) / 1000;
+ break;
+ case PID_ENGINE_FUEL_RATE: // L/min
+ result = getLargeValue(data) * 3;
+ break;
+ case PID_ENGINE_TORQUE_PERCENTAGE: // %
+ result = (int)getSmallValue(data) - 125;
+ break;
default:
result = getSmallValue(data);
}
diff --git a/libraries/OBD/OBD.h b/libraries/OBD/OBD.h
index 93856d6..82e1c1a 100644
--- a/libraries/OBD/OBD.h
+++ b/libraries/OBD/OBD.h
@@ -8,7 +8,7 @@
#define OBD_TIMEOUT_SHORT 2000 /* ms */
#define OBD_TIMEOUT_LONG 7000 /* ms */
#define OBD_SERIAL_BAUDRATE 38400
-#define OBD_RECV_BUF_SIZE 128
+#define OBD_RECV_BUF_SIZE 80
#ifndef OBDUART
#if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega644P__)
@@ -19,22 +19,30 @@
#endif
// mode 0 pids
-#define PID_RPM 0x0C
-#define PID_SPEED 0x0D
-#define PID_THROTTLE 0x11
#define PID_ENGINE_LOAD 0x04
#define PID_COOLANT_TEMP 0x05
-#define PID_INTAKE_TEMP 0x0F
-#define PID_MAF_FLOW 0x10
-#define PID_ABS_ENGINE_LOAD 0x43
-#define PID_AMBIENT_TEMP 0x46
#define PID_FUEL_PRESSURE 0x0A
#define PID_INTAKE_MAP 0x0B
-#define PID_BAROMETRIC 0x33
+#define PID_RPM 0x0C
+#define PID_SPEED 0x0D
#define PID_TIMING_ADVANCE 0x0E
-#define PID_FUEL_LEVEL 0x2F
+#define PID_INTAKE_TEMP 0x0F
+#define PID_MAF_FLOW 0x10
+#define PID_THROTTLE 0x11
#define PID_RUNTIME 0x1F
+#define PID_FUEL_LEVEL 0x2F
#define PID_DISTANCE 0x31
+#define PID_BAROMETRIC 0x33
+#define PID_CONTROL_MODULE_VOLTAGE 0x42
+#define PID_ABSOLUTE_ENGINE_LOAD 0x43
+#define PID_AMBIENT_TEMP 0x46
+#define PID_ETHANOL_PERCENTAGE 0x52
+#define PID_FUEL_RAIL_PRESSURE 0x59
+#define PID_HYBRID_BATTERY_PERCENTAGE 0x5B
+#define PID_ENGINE_OIL_TEMP 0x5C
+#define PID_ENGINE_FUEL_RATE 0x5E
+#define PID_ENGINE_TORQUE_PERCENTAGE 0x62
+#define PID_ENGINE_REF_TORQUE 0x63
// states
#define OBD_DISCONNECTED 0