Final Report

Dependencies:   mbed

Fork of ecu_reader by Sukkin Pang

Revision:
6:dae9630af6e3
Parent:
3:05bb8f0bd7a4
--- a/ecu_reader.cpp	Tue Aug 28 13:16:46 2012 +0000
+++ b/ecu_reader.cpp	Mon Oct 27 02:46:55 2014 +0000
@@ -3,7 +3,6 @@
 #include "globals.h"
 
 
-// Use a timer to see if things take too long
 Timer CANTimer;  
 namespace mbed { 
 
@@ -46,7 +45,7 @@
         if((can_MsgRx.id == PID_REPLY) && (can_MsgRx.data[2] == pid))
         { 
                         switch(can_MsgRx.data[2])
-                        {   /* Details from http://en.wikipedia.org/wiki/OBD-II_PIDs */
+                        {   
                             case ENGINE_RPM:              //   ((A*256)+B)/4    [RPM]
                                 engine_data =  ((can_MsgRx.data[3]*256) + can_MsgRx.data[4])/4;
                                 sprintf(buffer,"%d rpm ",(int) engine_data);
@@ -54,30 +53,42 @@
                             
                             case ENGINE_COOLANT_TEMP:     //     A-40              [degree C]
                                 engine_data =  can_MsgRx.data[3] - 40;
-                                sprintf(buffer,"%d degC ",(int) engine_data);
+                                sprintf(buffer,"%d degC: ",(int) engine_data);
                             
                             break;
                             
                             case VEHICLE_SPEED:         // A                  [km]
-                                engine_data =  can_MsgRx.data[3];
-                                sprintf(buffer,"%d km ",(int) engine_data);
+                                engine_data =  can_MsgRx.data[3]* 0.6;
+                                sprintf(buffer,"%d MPH: ",(int) engine_data);
                             
                             break;
 
                             case MAF_SENSOR:               // ((256*A)+B) / 100  [g/s]
                                 engine_data =  ((can_MsgRx.data[3]*256) + can_MsgRx.data[4])/100;
-                                sprintf(buffer,"%d g/s",(int) engine_data);
+                                sprintf(buffer,"%d g/s: ",(int) engine_data);
                             
                             break;
 
                             case O2_VOLTAGE:            // A * 0.005   (B-128) * 100/128 (if B==0xFF, sensor is not used in trim calc)
                                 engine_data = can_MsgRx.data[3]*0.005;
-                                sprintf(buffer,"%d v ",(int) engine_data);
+                                sprintf(buffer,"%d v: ",(int) engine_data);
+                            break;
      
                             case THROTTLE:            //
                                 engine_data = (can_MsgRx.data[3]*100)/255;
-                                sprintf(buffer,"%d %% ",(int) engine_data);
-                             
+                                sprintf(buffer,"%d Pos: ",(int) engine_data);     
+
+                            break;
+                            
+                            case AIR_INTAKE_TEMP:               // ((256*A)+B) / 100  [g/s]
+                                engine_data =  can_MsgRx.data[3] - 40;
+                                sprintf(buffer,"%d degC: ",(int) engine_data);
+                            
+                            break;
+                            
+                            case FUEL_PRESSURE:               // ((256*A)+B) / 100  [g/s]
+                                engine_data =  (can_MsgRx.data[3] * 3) * 0.1450;
+                                sprintf(buffer,"%d Fuel PSI: ",(int) engine_data);
                             
                             break;
                         }
@@ -95,4 +106,5 @@
 
 
 }
-} // namespace mbed 
\ No newline at end of file
+} 
+