I am working on new useful visualizations for the generated KML. My Jeep does not have MAF, so I cannot use the visualization of Speed, MPG, and Position, which would probably be the first most obvious option.
First though I modified the code to allow me to pass in two colors for the "high" color and the "low" color. (In heightandcolor.c
I kept the original kmlvalueheightcolor function signature by passing red and green to the modified-and-renamed function, so that the rest of the obd2kml code would still run.
Because I can't use Speed, MPG, and Position, I implemented Speed, RPM, and Position. It is cool because it shows how when you rev the engine, you gain speed. (This code is in obdgpskml.c; coloredheightkml is the name of the improved kmlvalueheightcolor.)
Let me say here that the color coding for KML objects is four two-digit hex codes, for a total of eight digits, zero thru F, where the first two mean BLACK, the second two BLUE, the third two GREEN, the last two RED. It took me forever to figure that out.
That all works. The graph output is pretty cool. The next one I want to try is fuel themed: Fuel tank level (height), fuel trim (color), position. That will show how the fuel tank is drained over time. I changed the codes collected and logged so I can play with different metrics:
Code:
static struct obdservicecmd obdcmds[] = {
{ 0x00, 4, NULL, "PIDs supported 00-20" , 0, 0, "Bit Encoded", NULL },
{ 0x01, 4, NULL, "Monitor status since DTCs cleared" , 0, 0, "Bit Encoded", NULL },
{ 0x02, 4, NULL, "DTC that caused required freeze frame data storage" , 0, 0, "Bit Encoded", NULL },
{ 0x03, 8, NULL, "Fuel system 1 and 2 status" , 0, 0, "Bit Encoded", NULL },
{ 0x04, 2, NULL, "Calculated LOAD Value" , 0, 100, "%", obdConvert_04 },
{ 0x05, 1, "temp", "Engine Coolant Temperature" , -40, 215, "Celsius", obdConvert_05 },
{ 0x06, 1, NULL, "Short Term Fuel Trim - Bank 1", -100, 99.22, "%", obdConvert_06_09 },
{ 0x07, 1, NULL, "Long Term Fuel Trim - Bank 1", -100, 99.22, "%", obdConvert_06_09 },
{ 0x08, 1, NULL, "Short Term Fuel Trim - Bank 2", -100, 99.22, "%", obdConvert_06_09 },
{ 0x09, 1, NULL, "Long Term Fuel Trim - Bank 2", -100, 99.22, "%", obdConvert_06_09 },
{ 0x0A, 1, NULL, "Fuel Rail Pressure (gauge)", -100, 99.22, "%", obdConvert_0A },
{ 0x0B, 1, "maf", "Intake Manifold Absolute Pressure", 0, 765, "kPa", obdConvert_0B },
{ 0x0C, 2, "rpm", "Engine RPM", 0, 16383.75, "kPa", obdConvert_0C },
{ 0x0D, 1, "vss", "Vehicle Speed Sensor", 0, 255, "km/h", obdConvert_0D },
{ 0x0E, 1, NULL, "Ignition Timing Advance for #1 Cylinder", -64, 63.5, "degrees relative to #1 cylinder", obdConvert_0E },
{ 0x0F, 1, "iat", "Intake Air Temperature", -40, 215, "Celsius", obdConvert_0F },
{ 0x10, 2, NULL, "Air Flow Rate from Mass Air Flow Sensor", 0, 655.35, "g/s", obdConvert_10 },
{ 0x11, 1, "throttlepos", "Absolute Throttle Position", 1, 100, "%", obdConvert_11 },
{ 0x12, 1, NULL, "Commanded Secondary Air Status" , 0, 0, "Bit Encoded", NULL },
{ 0x13, 1, NULL, "Location of Oxygen Sensors" , 0, 0, "Bit Encoded", NULL },
{ 0x14, 2, NULL, "Bank 1 - Sensor 1/Bank 1 - Sensor 1 Oxygen Sensor Output Voltage / Short Term Fuel Trim", 0, 1.275, "V", obdConvert_14_1B },
{ 0x15, 2, NULL, "Bank 1 - Sensor 2/Bank 1 - Sensor 2 Oxygen Sensor Output Voltage / Short Term Fuel Trim", 0, 1.275, "V", obdConvert_14_1B },
{ 0x16, 2, NULL, "Bank 1 - Sensor 3/Bank 2 - Sensor 1 Oxygen Sensor Output Voltage / Short Term Fuel Trim", 0, 1.275, "V", obdConvert_14_1B },
{ 0x17, 2, NULL, "Bank 1 - Sensor 4/Bank 2 - Sensor 2 Oxygen Sensor Output Voltage / Short Term Fuel Trim", 0, 1.275, "V", obdConvert_14_1B },
{ 0x18, 2, NULL, "Bank 2 - Sensor 1/Bank 3 - Sensor 1 Oxygen Sensor Output Voltage / Short Term Fuel Trim", 0, 1.275, "V", obdConvert_14_1B },
{ 0x19, 2, NULL, "Bank 2 - Sensor 2/Bank 3 - Sensor 2 Oxygen Sensor Output Voltage / Short Term Fuel Trim", 0, 1.275, "V", obdConvert_14_1B },
{ 0x1A, 2, NULL, "Bank 2 - Sensor 3/Bank 4 - Sensor 1 Oxygen Sensor Output Voltage / Short Term Fuel Trim", 0, 1.275, "V", obdConvert_14_1B },
{ 0x1B, 2, NULL, "Bank 2 - Sensor 4/Bank 4 - Sensor 2 Oxygen Sensor Output Voltage / Short Term Fuel Trim", 0, 1.275, "V", obdConvert_14_1B },
{ 0x1C, 1, NULL, "OBD requirements to which vehicle is designed" , 0, 0, "Bit Encoded", NULL },
{ 0x1D, 1, NULL, "Location of oxygen sensors" , 0, 0, "Bit Encoded", NULL },
{ 0x1E, 1, NULL, "Auxiliary Input Status" , 0, 0, "Bit Encoded", NULL },
{ 0x1F, 2, NULL, "Time Since Engine Start", 0, 65535, "seconds", obdConvert_1F },
{ 0x20, 4, NULL, "PIDs supported 21-40" , 0, 0, "Bit Encoded", NULL },
{ 0x21, 4, NULL, "Distance Travelled While MIL is Activated", 0, 65535, "km", obdConvert_21 },
{ 0x22, 2, NULL, "Fuel Rail Pressure relative to manifold vacuum", 0, 5177.265, "kPa", obdConvert_22 },
{ 0x23, 2, NULL, "Fuel Rail Pressure (diesel)", 0, 655350, "kPa", obdConvert_23 },
{ 0x24, 4, NULL, "Bank 1 - Sensor 1/Bank 1 - Sensor 1 (wide range O2S) Oxygen Sensors Equivalence Ratio (lambda) / Voltage", 0, 2, "(ratio)", obdConvert_24_2B },
{ 0x25, 4, NULL, "Bank 1 - Sensor 2/Bank 1 - Sensor 2 (wide range O2S) Oxygen Sensors Equivalence Ratio (lambda) / Voltage", 0, 2, "(ratio)", obdConvert_24_2B },
{ 0x26, 4, NULL, "Bank 1 - Sensor 3 /Bank 2 - Sensor 1(wide range O2S) Oxygen Sensors Equivalence Ratio (lambda) / Voltage", 0, 2, "(ratio)", obdConvert_24_2B },
{ 0x27, 4, NULL, "Bank 1 - Sensor 4 /Bank 2 - Sensor 2(wide range O2S) Oxygen Sensors Equivalence Ratio (lambda) / Voltage", 0, 2, "(ratio)", obdConvert_24_2B },
{ 0x28, 4, NULL, "Bank 2 - Sensor 1 /Bank 3 - Sensor 1(wide range O2S) Oxygen Sensors Equivalence Ratio (lambda) / Voltage", 0, 2, "(ratio)", obdConvert_24_2B },
{ 0x29, 4, NULL, "Bank 2 - Sensor 2 /Bank 3 - Sensor 2(wide range O2S) Oxygen Sensors Equivalence Ratio (lambda) / Voltage", 0, 2, "(ratio)", obdConvert_24_2B },
{ 0x2A, 4, NULL, "Bank 2 - Sensor 3 /Bank 4 - Sensor 1(wide range O2S) Oxygen Sensors Equivalence Ratio (lambda) / Voltage", 0, 2, "(ratio)", obdConvert_24_2B },
{ 0x2B, 4, NULL, "Bank 2 - Sensor 4 /Bank 4 - Sensor 2(wide range O2S) Oxygen Sensors Equivalence Ratio (lambda) / Voltage", 0, 2, "(ratio)", obdConvert_24_2B },
{ 0x2C, 1, NULL, "Commanded EGR", 0, 100, "%", obdConvert_2C },
{ 0x2D, 1, NULL, "EGR Error", -100, 99.22, "%", obdConvert_2D },
{ 0x2E, 1, NULL, "Commanded Evaporative Purge", 0, 100, "%", obdConvert_2E },
{ 0x2F, 1, "fuel", "Fuel Level Input", 0, 100, "%", obdConvert_2F },
{ 0x30, 1, NULL, "Number of warm-ups since diagnostic trouble codes cleared", 0, 255, "", obdConvert_30 },
{ 0x31, 2, NULL, "Distance since diagnostic trouble codes cleared", 0, 65535, "km", obdConvert_31 },
{ 0x32, 2, NULL, "Evap System Vapour Pressure", -8192, 8192, "Pa", obdConvert_32 },
{ 0x33, 1, "baro", "Barometric Pressure", 0, 255, "kPa", obdConvert_33 },
{ 0x34, 4, NULL, "Bank 1 - Sensor 1/Bank 1 - Sensor 1 (wide range O2S) Oxygen Sensors Equivalence Ratio (lambda) / Current", 0, 2, "(ratio)", obdConvert_34_3B },
{ 0x35, 4, NULL, "Bank 1 - Sensor 2/Bank 1 - Sensor 2 (wide range O2S) Oxygen Sensors Equivalence Ratio (lambda) / Current", 0, 2, "(ratio)", obdConvert_34_3B },
{ 0x36, 4, NULL, "Bank 1 - Sensor 3/Bank 2 - Sensor 1 (wide range O2S) Oxygen Sensors Equivalence Ratio (lambda) / Current", 0, 2, "(ratio)", obdConvert_34_3B },
{ 0x37, 4, NULL, "Bank 1 - Sensor 4/Bank 2 - Sensor 2 (wide range O2S) Oxygen Sensors Equivalence Ratio (lambda) / Current", 0, 2, "(ratio)", obdConvert_34_3B },
{ 0x38, 4, NULL, "Bank 2 - Sensor 1/Bank 3 - Sensor 1 (wide range O2S) Oxygen Sensors Equivalence Ratio (lambda) / Current", 0, 2, "(ratio)", obdConvert_34_3B },
{ 0x39, 4, NULL, "Bank 2 - Sensor 2/Bank 3 - Sensor 2 (wide range O2S) Oxygen Sensors Equivalence Ratio (lambda) / Current", 0, 2, "(ratio)", obdConvert_34_3B },
{ 0x3A, 4, NULL, "Bank 2 - Sensor 3/Bank 4 - Sensor 1 (wide range O2S) Oxygen Sensors Equivalence Ratio (lambda) / Current", 0, 2, "(ratio)", obdConvert_34_3B },
{ 0x3B, 4, NULL, "Bank 2 - Sensor 4/Bank 4 - Sensor 2 (wide range O2S) Oxygen Sensors Equivalence Ratio (lambda) / Current", 0, 2, "(ratio)", obdConvert_34_3B },
{ 0x3C, 2, NULL, "Catalyst Temperature Bank 1 / Sensor 1", -40, 6513.5, "Celsius", obdConvert_3C_3F },
{ 0x3D, 2, NULL, "Catalyst Temperature Bank 2 / Sensor 1", -40, 6513.5, "Celsius", obdConvert_3C_3F },
{ 0x3E, 2, NULL, "Catalyst Temperature Bank 1 / Sensor 2", -40, 6513.5, "Celsius", obdConvert_3C_3F },
{ 0x3F, 2, NULL, "Catalyst Temperature Bank 2 / Sensor 2", -40, 6513.5, "Celsius", obdConvert_3C_3F },
{ 0x40, 4, NULL, "PIDs supported 41-60" , 0, 0, "Bit Encoded", NULL },
{ 0x41, 4, NULL, "Monitor status this driving cycle" , 0, 0, "Bit Encoded", NULL },
{ 0x42, 2, NULL, "Control module voltage", 0, 65535, "V", obdConvert_42 },
{ 0x43, 2, NULL, "Absolute Load Value", 0, 25700, "%", obdConvert_43 },
{ 0x44, 2, NULL, "Commanded Equivalence Ratio", 0, 2, "(ratio)", obdConvert_44 },
{ 0x45, 1, NULL, "Relative Throttle Position", 0, 100, "%", obdConvert_45 },
{ 0x46, 1, NULL, "Ambient air temperature", -40, 215, "Celsius", obdConvert_46 },
{ 0x47, 1, NULL, "Absolute Throttle Position B", 0, 100, "%", obdConvert_47_4B },
{ 0x48, 1, NULL, "Absolute Throttle Position C", 0, 100, "%", obdConvert_47_4B },
{ 0x49, 1, NULL, "Accelerator Pedal Position D", 0, 100, "%", obdConvert_47_4B },
{ 0x4A, 1, NULL, "Accelerator Pedal Position E", 0, 100, "%", obdConvert_47_4B },
{ 0x4B, 1, NULL, "Accelerator Pedal Position F", 0, 100, "%", obdConvert_47_4B },
{ 0x4C, 1, NULL, "Commanded Throttle Actuator Control", 0, 100, "%", obdConvert_4C },
{ 0x4D, 2, NULL, "Time run by the engine while MIL activated", 0, 65525, "minutes", obdConvert_4D },
{ 0x4E, 2, NULL, "Time since diagnostic trouble codes cleared", 0, 65535, "minutes", obdConvert_4E },
{ 0x51, 2, NULL, "Fuel Type", 0, 0, "", NULL },
{ 0x52, 2, NULL, "Ethanol fuel %", 0, 100, "%", obdConvert_52 },
{ 0x00, 0, NULL, NULL }
};
Does anyone have any other cool ideas? In addition to my desire to link in photographs, I also want a utility that will add an entry to a "note" table in the database, along with a timestamp. Then the KML output could include these notes along the way, as placemarks. Also, if we were to monitor code 0x01, could we collect DTCs in real time? If so, we could also stash those in the notes table, so that the output could show DTC information. I'll play with that next time I have a chance.