Kia Optima Forums banner

How to add custom PIDs to your Torque Pro Setup (Mass Air Flow, Turbine Speed, FFR

82K views 39 replies 12 participants last post by  KingFatty  
#1 · (Edited)
Hello,
I have started this project to get the turbine/compressor RPM on my car. From there, I added more stuff to get a better understanding of our engine. In addition, I provided an alternate version of some formulas to accommodate the 2.4L platform.

I'm a software engineer, so you will see some weird tricks that I used to make this work with Torque Pro. I recommend to start with the easy equations and validate them one by one. It is quite easy to screw up a formula and get a bad result. Let me know if you find something wrong or just want to add a new gauge to your dashboard.

*: Replace the * by the multiplication sign (x) when entering the equation.
/: Replace the / by the division sign (Ă·) when entering the equation.

In order to create your custom PIDs, you need to go the "Settings > Manage extra PID/Sensors >... Add custom PID" menu.

OBD-II Sensors (For reference only)
[0b]: Intake Manifold Absolute Pressure (kPa)
[0c]: Engine RPM
[0d]: Vehicule Speed (km/h)
[0f]: Intake Air Temperature (C)
[33]: Barometric Pressure (kPa)
[34]: Bank 1 - Sensor 1 Lambda
[46]: Ambient Temperature (C)

For more information: http://en.wikipedia.org/wiki/OBD-II_PIDs

Torque Pro Operations (For reference only)
abs(): Absolute value.
{X:B}: Verify if the bit B is set within the X byte.
[pid]: Refers to the pid number of a sensor.
val{Long Name}: Refers to another equation using its long name.

Air Density
This equation gives the air density inside the intake. Used to calculate the mass air flow rate or as a standalone gauge. The relative humidity is assumed to be constant at 50%.
Unit: lb/cf
Equation: .0717*(303.15/([0f]+273.15))*([33]/101.325)
OBD Header: 7E0

Sea Level Comp
This equation computes a compensation factor to normalize your horsepower/torque values to sea level, 30 celcius, 50% humidity. Useful to compare your HP/Torque values with other members.
Equation: .0717 / (val{Air Density} + .0000001)

IsBoost
This equation indicates whether the car is in boost or not. It is used to filter unwanted results from other equations. It checks if the MAP sensor is between 96 kpa and 255 kpa which means a boost between -0.78 PSI and 22.275 PSI.
PID: 010b
Min: 0.0
Max: 1.0
Equation: ({A:7}+({A:6}*{A:5}))-({A:7}*{A:6}*{A:5})
OBD Header: 7E0

IsRpmGT2048
This equation indicates whether the engine runs at least 2048 revolutions per minute.
PID: 010c
Min: 0.0
Max: 1.0
Equation: {A:6}+{A:5}-({A:6}*{A:5})
OBD Header: 7E0

IsRpmGT3072
This equation indicates whether the engine runs at least 3072 revolutions per minute.
PID: 010c
Min: 0.0
Max: 1.0
Equation: {A:6}+({A:5}*{A:4})
OBD Header: 7E0

IsRpmGT3584
This equation indicates whether the engine runs at least 3584 revolutions per minute.
PID: 010c
Min: 0.0
Max: 1.0
Equation: {A:6}+({A:5}*{A:4}*{A:3})
OBD Header: 7E0

IsRpmGT4096
This equation indicates whether the engine runs at least 4096 revolutions per minute.
PID: 010c
Min: 0.0
Max: 1.0
Equation: {A:6}
OBD Header: 7E0

IsSpeedGT128
This equation indicates whether the car is going over 128 km/h in order to filter unwanted results from other equations.
PID: 010d
Unit: km/h
Min: 0
Max: 255
Equation: {A:7}
OBD Header: 7E0

BSFC
This equation gives the Brake Specific Fuel Consumption at WOT.
Equation (2.0L): (((-0.000025*[0c])+.59)*abs(val{IsRpmGT3584}-1))+(((.000029*[0c])+.40)*val{IsRpmGT3584})
Equation (2.4L): (((-0.000056*[0c])+.68)*abs(val{IsRpmGT4096}-1))+(((.000037*[0c])+.30)*val{IsRpmGT4096})
OBD Header: 7E0

P.S I'm still working to improve this formula based on the engine load when you are not at WOT...

T-Outlet PR
This equation gives the pressure ratio as seen by the turbo outlet. I used an average value of 0.5 PSI drop to compensate for the pipe/filter restriction and 1 PSI drop for the intercooler. Depending of your setup and what you want to monitor, you can change these values to accommodate your needs.
Min: 0.0
Max: 3.0
Equation: (([0b]*.145)+1.0)/(([33]*.145)-0.5)
OBD Header: 7E0

T-Intake PR
This equation gives the pressure ratio as seen by the intake manifold.
Min: 0.0
Max: 3.0
Equation: [0b]/([33]
OBD Header: 7E0

T-RPM
This equation gives an estimate of the turbine/compressor RPM based on the turbo pressure ratio of the td04-19t compressor map. The number is only valid while you are in boost.
Unit: x1000
Min: 50.0
Max: 175
Equation: ((((val{T-Outlet PR}*80)-30)*(([0c]*.000015)+.91))*val{IsBoost})+(abs(val{IsBoost}-1)*50)
OBD Header: 7E0

T-Inlet Air Temp
This equation gives an estimate of the air temperature at the turbo inlet. This estimate assumes that 65% of the air entering the air box is provided by the intake air temperature and 35% by the ambient air temperature at 0 km/h (Idle). As you go, this ratio is changed to reach 100% of the ambient air temperature at 128 km/h. This model is based on data that I collected on my car last summer. You will need to create an extra PID reading this value if you want to convert it to Fahrenheit instead of Celcius.
PID: 010d
Unit: Celcius
Min: -40.0
Max: 215.0
Equation: ((([46]*((.005*A)+.35))+([0f]*((-.005*A)+.65)))*abs(val{IsSpeedGT128}-1))+([46]*val{IsSpeedGT128})
OBD Header: 7E0

T-Outlet Air Temp
This equation gives an estimate of the air temperature at the turbo outlet. You will need to create an extra PID reading this value if you want to convert it to Fahrenheit instead of Celcius.
Unit: Celcius
Min: -40.0
Max: 215.0
Equation: ((((((((val{T-Inlet Air Temp}+273.15)*((val{T-Outlet PR}*.2)+.8)))-273.15)-val{T-Inlet Air Temp})/.7)+val{T-Inlet Air Temp})*val{IsBoost})+(abs(val{IsBoost}-1)*val{T-Inlet Air Temp})

IC Efficiency
This equation gives an estimate of the intercooler efficiency. You will see a negative result when you are not in boost since the air entering the IC is cooler than the intake air temperature (the equation acts a heater in this case). If you do not want to see this, you can multiply the equation by val{IsBoost} to filter out the result.
Unit: %
Equation: (((val{T-Outlet Air Temp}-[0f])+1)/((val{T-Outlet Air Temp}-[46])+1))*100
OBD Header: 7E0

VE
This equation gives an estimate of the volumetric efficiency based on the RPM.
Unit: %
Min: 0.0
Max: 100.0
Equation (2.0L): (((.005*[0c])+81)*abs(val{IsRpmGT3584}-1))+(((-.005*[0c])+117)*val{IsRpmGT3584})
Equation (2.4L): (((.009*[0c])+53)*abs(val{IsRpmGT4096}-1))+(((-.006*[0c])+115)*val{IsRpmGT4096})
OBD Header: 7E0

Volume Air Flow
This equation gives the volume air flow rate of your turbo car.
Unit: cf/min
Min: 0.0
Max: 500.0
Equation (2.0L): (1.998*val{VE}*[0c]*val{T-Intake PR})/5660
Equation (2.4L): (2.359*val{VE}*[0c]*val{T-Intake PR})/5660

Mass Air Flow
This equation gives the mass air flow rate of your car.
Unit: lb/min
Min: 0.0
Max: 100.0
Equation: val{Volume Air Flow}*val{Air Density}

Mass Fuel Flow
This equation gives the mass fuel flow rate of your car. Bank 1 - Sensor 1 Lambda has been used to measure the A/F ratio.
Unit: lb/min
Min: 0.0
Max: 100.0
Equation: val{Mass Air Flow}/(14.7*[34])
OBD Header: 7E0

Horsepower (At the crank)
This equation gives the horsepower at the crank.
Min: 0.0
Max: 300.0
Equation: (val{Mass Fuel Flow}*60)/val{BSFC}

P.S Multiply this equation by val{Sea Level Comp) if your want to normalize the result to sea level, 30 celcius, 50% relative humidity.

Torque (At the crank)
This equation gives the torque at the crank.
Unit: lb.ft
Min: 0.0
Max: 300.0
Equation: (val{Horsepower (At the crank)}*5252)/[0c]
OBD Header: 7E0

Torque (At the wheels)
This equation gives the torque at the wheels based on the circumference of my 215/55/R17 tires.
PID: 010d
Unit: lb.ft
Min: 0.0
Max: 3000.0
Equation: ([0c]/(((A/60)/.0021)+.001))*(val{Torque (At the crank)}*.84)*(A/(A+.001))
OBD Header: 7E0

P.S Replace .0021 km (or 2.1 m) by the circumference of your tires for more accuracy.

Fuel Instant
This equation gives the instant fuel consumption of your car. I used 1.68 pounds/liter of gasoline at 25 celcius in the formula. The gasoline weight is compensated using the ambient temp.
PID: 010d
Unit: L/100 km
Min: 0.0
Max: 100.0
Equation: ((val{Mass Fuel Flow}*60)/(1.68/((([46]-25)*.00095)+1)))*(100/(A+.001))*(A/(A+.001))
OBD Header: 7E0

Fuel MPG Instant
This equation gives the instant fuel consumption of your car in miles per gallon.
PID: 010d
Unit: MPG
Min: 0.0
Max: 100.0
Equation: (((100/(val{Fuel Instant}+.001))*3.785)/1.609)*(A/(A+.001))
OBD Header: 7E0
 
#4 · (Edited)
I had to think a bit about this since the original formula could report 2.0 instead of 1.0 in this situation (the 3 Most Significant Bits are 1 in this case) Finally, I came up with a simple (and rather smart:D) solution to cover the maximum range from our MAP sensor.
Original formula:
{A:7}+({A:6}*{A:5})

Updated formula:
({A:7}+({A:6}*{A:5}))-({A:7}*{A:6}*{A:5})

Since the MAP PID is limited to 1 byte by the OBD II protocol, it means that the highest value reported is 255 KPa, which translate to 36.975 PSI at see level, which translates to a maximum boost of 22.275 PSI (36.975-14.7 PSI). So, if you have a 24 PSI of boost, you will still read 36.975 PSI at see level...

P.S I did not test it on the car but I'm rather confident in this one...
 
#7 ·
Thank you. I use this link a lot and added it as a reference in my first post for quick access . On the other hand, the reader must be aware that a lot of the PIDs listed on the OBD II protocol are not supported by our ECU (for instance, the MAF and Fuel Pressure will read zero).
 
#8 · (Edited)
Updates
1) The volumetric efficiency is computed dynamically via IsRpmGT3072 and VE equations.
2) The Volume Air Flow equation has been updated to use the VE formula.
3) Added the OBD Header field to optimize the communication on the CAN bus.

P.S The Fuel Flow Rate and Instant Fuel Consumption equations should follow soon...
 
#9 ·
Updates
1) Corrected the Volume Air Flow formula which was overestimated in vacuum.
2) Added the Mass Fuel Flow equation.
3) Added the Fuel Instant consumption in L/100km.
 
#11 · (Edited)
My next update should be great for all the members...The HP and Torque numbers given by Torque Pro are way off and there is a lot of lag in the display. I will provide some equations computing these numbers from the engine instead of the wheels. BSFC will be computed dynamically based on the work RedHotDamn has done. VE is already done this way. If it works as I expect, I hope to deliver a VIRTUAL DYNAMOMETER in your car!!! :D

P.S I'm testing the VIRTUAL DYNAMOMETER now, BSFC is working as expected... It's not easy with the traffic I have going to my work. So far, I achieved 267.8 lb.ft for max torque, 255 HP for max horsepower. I'm pretty sure I have enough juice to go over 274 HP with my setup which I estimate to be around 282 HP at the red line. It's a real improvement over the default Torque Pro gauges for sure... :rolleyes:
 
#13 · (Edited)
Sorry for the delay, I have been busy lately. In addition, my harddrive died on my main computer (I need to reinstall Windows 7 and all the stuff)...and I have been sick like **** in the last 3 weeks! And, I was not sure if someone was interested by my stuff (not a lot of activity on the thread :))...:p

It seems to work very well on my car and all the formulas are on my Android tablet. We can see the HP/Torque numbers rolling at a steady speed, not only during the acceleration like the Torque built-in algorithms (and the numbers were not good). I have been able to get 281 HP at the crank shaft (WOT) and 278 ft.lb (WOT) for the torque. Stay tuned, I will post soon the missing formulas... :cool:
 
#15 ·
I just added the BSFC along the horsepower/torque formulas at the crank. Basically, you will need to enter the following formulas to get your virtual dynamometer:

Air Density
IsRpmGT3072
BSFC
T-Intake PR
VE
Volume Air Flow
Mass Air Flow
Mass Fuel Flow
Horsepower (At the crank)
Torque (At the crank)

Let me know if it works, it is so easy to do a typo with this stuff...:)
 
#34 ·
Great work, it's been a while since I checked in on this forum.

I may suggest you join my Performance group. Majority of members there have and actively use torque pro plus the many plugin available.

We also have several members who are participating in reverse engineering ECU tuning solutions, so if any communications protocols are hampering your efforts, I'm certain they could assist, and YOU may be of assistance to them as well. Logging changes are integral to tuning ;)

On Facebook, Search/Groups - Thetaii Turbo Performance
 
#17 ·
excellent work - finally got round to adding...

how do i change this to miles per US gallon please ?

Fuel Instant
This equation gives the instant fuel consumption of your car. I used 1.65 pounds/liter of gasoline in this formula.
PID: 010d
Unit: L/100 km
Min: 0.0
Max: 100.0
Equation: ((val{Mass Fuel Flow}*60)/1.65)*(100/(A+.001))*(A/(A+.001))
OBD Header: 7E0
 
#18 ·
I'm gonna do that for sure.
First, I need to review all the formulas since I overestimated the fuel consumption by 8% compared to what I have computed manually at the gas station (might be the air density formula, sensor error, etc.). On the other hand, the average given by the ECU seems to be underestimated by 2%...
 
#19 ·
cool - loving these - is there a way to export my dashboard settings (file in android file system) and import/copy to another android device (i.e. phone to tablet) ?really appreciate what you are doing here !!

---------- Post added 01-22-2015 at 09:42 AM ---------- Previous post was 01-21-2015 at 08:13 PM ----------

ok - worked out how to share/save dashboards in torque pro.

when in the dashboard on your mobile device ...

go to menu..layout settings and there you have an import or export layout function.

This stores the file to /storage/sdcard0/.torque/dashboards on your phone/tablet ......this might vary depending on android version/profiles etc. I found it by saving a layout with a unique name and then using es file explorer (set to show hidden files) and searching from top directory for the unique name

In the .torque directory there are other useful files - just need to work out how to use them - i believe this is for themes etc - I'll work on this if we need it.

Hope this helps - it means we can perfect the perfect Optima dashboard and share with the forum.
 
#21 ·
I reviewed all the formulas to find what was wrong with the fuel consumption...
1) Mass Fuel Flow has been updated to use 14.71 instead of 14.65. The result was overestimated by 0.5%.
2) Fuel Instant has been updated to to 1.68 instead of 1.65 pounds. The result was overestimated by 2.0%.
3) Fuel Instant must be compensated using a coefficient of thermal expansion...I will work on that to improve the result.
4) I learned that our speedometer might be off by 4%...

The layout project is interesting. Don't give up!

I use VGate Multi-Scan Tool and no problem so far.
Mini Vgate ELM327 Bluetooth ODB2 II Car Auto Diagnostics Scanner w Power Switch | eBay
 
#22 ·
#25 ·
I use the LX as well, due to it's PID latency while keeping the BT function without wires.

K5Canada, this is going to be very useful information to our tuning community. There should be some form of nationwide tune software available to tuners aside from what is on the market now. And therefore being able to data log some of these VE tables will become very useful.

Wonder if you could come up with any way to see some of the VVT cam phase PID's? To be able to read oil pressure to the cam oil control valves which alter our cam phase/timing could be equally as useful for tuning.
 
#24 ·
Update:
- Fuel Instant: Compensated gasoline weight according to the ambient temperature.
- Fuel MPG Instant: New formula. US version.
- Torque (At the wheels): New formula based on car speed, tire circumference and crank shaft speed.
 
#28 ·
Really interesting stuff. Subbed
 
#30 ·
Today, I updated the "Air density" formula to use a constant relative humidity of 50%. The first version assumed it was dry air...and this could introduce an error of 1.5% on the final result.
 
#31 ·
Me personally, I'd love to be able to see and data log the following:

For the engine.....
Crank position sensor (to use a reference)
Intake Cam phasing / Exhaust Cam phasing
Injector intitial open, and how long the 12v pwm signal holds it open (peak- hold times)
Ignition timing
Knock retard per cylinder (this used to be available at one point through Hyundai advanced plugin, but I lost those PID's for some reason.
CVVT Oil pressure regulator (oil temps) another value we used to have and now is gone

Transmission:
Solenoid line pressure
Torque Converter lockup
ATF temp
I'd love to know how this eninge calculates and manages torque on demand. What sensors and calculation it uses to basically inhibit the engine from exceeding it's programmed torque values. This is a big one, as until recently tuners have been a little stumped on this one for lower gears I believe.

Turbo related:
Voltage at rest Boost Control Valve (used to set waste gate spec voltage when fully mechanically shut)
Data log the PWM signal sent from the PCM to the Boost Bypass Solenoid or Diverter valve

And I believe we can access a PID for Catalyst Enrichment % signal from the PCM that dumps fuel into the engine once a certain EGT is read before and after the Catylist.

Any of those items would be an amazing upgrade or plugin to Torque which I'm certain our community would gladly pay for. This would allow many of us to learn better how this engine operates and what sort of triggers exist within the software that manages this vehicle.
 
#33 · (Edited)
Major update today...
- Supported the 2.4L platform.
- Improved the 2.0L VE and BSFC curves using 3584 as RPM peek torque value.
- Added the Sea Level Comp formula to compensate HP/Torque to sea level.

P.S I have been unable to test the 2.4L engine. Beta testers requested...
 
#37 · (Edited)


Thanks for K5CANADA..who was inspiring me with his equation

i have some equation that maybe more accurate based on engine load condition and universal for all displacement volume engine,since BSFC very fluctuative based on engine load as picture describe



PID 0104
long name LOAD25
Equation 1-{A:7}


PID 0104
long name LOAD100
Equation {A:0}*{A:1}*{A:2}*{A:3}*{A:4}*{A:5}*{A:6}*{A:7}


PID 0104
Long name LOAD50
Equation {A:7}*(1-val{LOAD100})


PID leave it blank
Long name BSFC25
Equation
val{LOAD25}*(((1-val{IsRpmGT3072})*(1.3167-(0.00016667*[0c])))+(val{IsRpmGT3072}*(0.7+(0.00020833*([0c]-3072)))))


PID leave it blank
Long name BSFC50
val{LOAD50}*(((1-val{IsRpmGT3072})*(0.95086-(0.00015086*[0c])))+(val{IsRpmGT3072}*(0.47+(0.00018462*([0c]-3072)))))


PID leave it blank
Long name BSFC100
Equation
val{LOAD100}*(((1-val{IsRpmGT3072})*(0.53429-(0.00003429*[0c])))+(val{IsRpmGT3072}*(0.425+(0.00007059*([0c]-3072)))))


PID leave it blank
Long name BSFC TOTAL
Equation
val{BSFC25}+val{BSFC50}+val{BSFC100}


PID leave it blank
Long name POWER BY LOAD
Equation
(val{Mass Fuel Flow}*60)/val{BSFC TOTAL}