# ## Forums

#### Guest Welcome Guest, posting in this forum require registration.

 Pages:  2 Author Topic: Custom Pid Help
userM
Member
Posts: 96  Custom Pid Helpon: April 14, 2017 (GMT)

Can someone tell me if (and how) I can make a pid that it will calculate the the current speed from obd / rpm?

F-150Torqued
Member
Posts: 427  Re: Custom Pid Helpon: April 14, 2017 (GMT)

??Interesting. Another good anti-dementia exercise for old farts like me.

It’s actually pretty easy – by just creating a virtual PID (one with MODE/PID# blank), IF:
o- you don’t care about it being wrong in gears below HI & OD
o- or you don’t care about Torque Converter slip if automatic.
o- your vehicle is standard transmission or has locking TC.
o- you keep your drive tires inflated the same.
o- you know the circumference of the drive tires in ft (Tdia-ft)
o- you know the transmission overdrive transfer ratio (ODr)
o- you know the differential gear ratio (Diffr)
o- you know Torque is able to read standard [RPM PID] [0C]

Then you would simply create a new custom pid (a ‘virtual’ PID) similar to

MODE/PID: blank
Long Name: My RPMSPEED
Short Name: RPMSpeed
Min – Max as appropriate
Units: MPH
Formula: ([0C]/60)*(1/ODr)*(1/Diffr)*(5280/Tdia-ft)
Start Stop Diagnostic: blank

Then you could add a gauge of your choice and select “My RPMSPEED” from your scroll list of pids.

IF you have/can find a PID for GEAR (and knew each gear ratio), I could structure a formula that would work accurately by summing results for each gear while negating formula results for all gears that are not currently true.

But it seems there are lots of variables that would make it result in a meaningless number.

————–

54371019

=======================4/21/17
EDIT: To avoid confusion to future readers, after my errors / mistakes pointed out by @Capp777 were made in following discussions, the correct formula was determined to be:

Formula: ((([OC]/(0.83*2.813))*1.83)*60)/1000 for the OD gear ratio, differential ratio, and tire circumference of this vehicle – in 6th gear.

userM
Member
Posts: 96  Re: Custom Pid Helpon: April 14, 2017 (GMT)

Thanks.

My car is BMW F20 N13 engine 1600cc with manual transmission

1. if I leave blank mode/pid and place a formula [0D]/[0C] will I get Speed (OBD)(km/h) / Engine RPM(rpm) ?
at the end of the following is what I want to try
http://stackoverflow.com/questions/30017271/obdii-determine-gear-given-speed-and-rpm

2. if possible clarify the following

— what is (Tdia-ft)?
my wheels are 245/40/17 (can I have the result in meters)?

— how can I change the formula in kilometers ?

i will try to find out
the transmission overdrive transfer ratio (ODr)
the differential gear ratio (Diffr)

I know right now (to be honest I don’t know what they mean)
the axle ratio = 2.813:1
and the gears ratio
1 = 4.552 (12.8)
2 = 2.548 (7.17)
3 = 1.659 (4.67)
4 = 1.23 (3.46)
5 = 1 (2.81)
6 = 0.83 (2.33)

F-150Torqued
Member
Posts: 427  Re: Custom Pid Helpon: April 14, 2017 (GMT)

1. Leaving the Mode/PID blank makes the whole PID entry work like a ‘virtual’ PID from the PCM – or another way to look at is like a ‘memory variable’ in Torque that shows up in your PID list by the Long Name that you assigned it. [OD] and [OC] are the ‘standard’ hexadecimal PID numbers for VSS (Vehicle Speed) and RPM respectively. Using ANY valid PID number in brackets that way in a formula will return the value from that PID (as per its formula) and use it in any other formula or PID.

I note that the link you provided is calculating the gear from RPM. That would be much easier because the resolution / accuracy could be quiet sloppy without the ‘integer’ (gear) changing much. My 2004 F150 presents GEAR as an integer number at PID # 11B3, but I’m sure that wouldn’t be the same on your BMW.

2. (Tdia-ft) is just the acronym that I chose to mean Tire diameter in feet – because I know there are 5280 feet in a mile and that made it straight forward. I have no idea what the diameter would be of 245/40/17 tires (metric or SAE) but surely that’s readily available – BUT – that would ‘skew’ some depending on inflation pressure, IDK.

The formula, like everything else metric, would be cleaner in metrics. Just put the distance and tire radius in meters and change the PID Units to KPH. That would also cause Torque to treat the speed reading in accordance with the Settings parameters for Kilometers Per Hour or Miles Per Hour as appropriate.

You correctly interpreted te Acronyms for (ODr) and (Diffr). With the gear Ratios you’ve got – looks like you are there.

————–

54371019

Capp777
Member
Posts: 2856  Re: Custom Pid Helpon: April 15, 2017 (GMT)

Tire diameter or circumference used in
equation?

F-150Torqued
Member
Posts: 427  Re: Custom Pid Helpon: April 15, 2017 (GMT)

Thanks @Capp777 for catching my goof. Certainly its circumference. I guess if he can’t find circumference in the tire specs, we could throw ‘pi’ into the formula. But for sure in the end we gotta’ know how far the car travels with one revolution. —————–

54371019

userM
Member
Posts: 96  Re: Custom Pid Helpon: April 17, 2017 (GMT)

Hi
due to Easter holidays I have not got time to test everything. Earlier in the afternoon I tried the method with speed/rpm. It is not very accurate but I am getting (mostly) the correct gear indication. I have not managed to check it in higher speeds but it looks promising.

I can’t find out
the transmission overdrive transfer ratio (ODr)
the differential gear ratio (Diffr)
if someone can help is very welcome

There is another app like torque pro where in the settings just have to fill the gear ratios and the gear indicator is working fine

Why is it so difficult in torque pro?

F-150Torqued
Member
Posts: 427  Re: Custom Pid Helpon: April 20, 2017 (GMT)

Quote from userM on April 17, 2017

I can’t find out
the transmission overdrive transfer ratio (ODr)
the differential gear ratio (Diffr)
if someone can help is very welcome

[end quote]

—————–

Isn’t the answer in the data you provided in ‘post # 3’ above?

Looks to me like (Diffr) is 2.81 to 1.

And the ‘final ratio’ – through the differential – is listed in parenthesis for each gear.

If I multiply third gear ratio 1.659 X axle ratio 2.81, I get (4.66179)

Then Sixth gear (ODr) should be 0.83 x 2.81 or (2.3323)

————–

54371019

userM
Member
Posts: 96  Re: Custom Pid Helpon: April 20, 2017 (GMT)

Sorry, but I didn’t know – understood what this numbers ment.. now I know (in a way)

Thanks

I have to work out the (Tdia-ft)

please have a look later because most probably I will need help

)

thanks!

F-150Torqued
Member
Posts: 427  Re: Custom Pid Helpon: April 20, 2017 (GMT)

NOTE that @Cap777 correctly pointed out that in my haste, I mistakenly was thinking (and chose an acronym) referring to “Diameter” (Tdia-ft) when it should properly be “Circumference”. Not that the acronym makes any difference – but the measurement should be the distance all the way around the tread of the tire – in either feet, or meters/centimeters depending on what distance / hour you are trying to arrive at.

It is an interesting concept. Math in fun. Help me try to convince @piemmm to implement Boolean math in the math routine, and if you can come up with a ‘gear’ pid, I will work out a formula for you that will produce the same speed result, no matter what gear you are in.

Good luck

————–

54371019

userM
Member
Posts: 96  Re: Custom Pid Helpon: April 20, 2017 (GMT)

question.. I can’t understand -ft in formula.

([0C]/60)*(1/2,3323)*(1/2,813)*(5280/Tdia-ft)

lets say I want kilometers per hour = 1000 meters
lest also say that tdia=1meter
so the last part should be
*(1000/1 – ft?) what meters-foot should here?

Capp777
Member
Posts: 2856  Re: Custom Pid Helpon: April 20, 2017 (GMT)

Quote from userM on April 20, 2017
question.. I can’t understand -ft in formula.

([0C]/60)*(1/2,3323)*(1/2,813)*(5280/Tdia-ft)

lets say I want kilometers per hour = 1000 meters
lest also say that tdia=1meter
so the last part should be
*(1000/1 – ft?) what meters-foot should here?

End Quote.

The formula given is in Feet which could be converted
by (meters in a mile/tire circumference in meters).

To me the [0C] rpms should be multiplied by 60 to get
rounds per hour. Would be nice to know your tire
circumference to play with the numbers.

5280 feet in a mile
5280 * 0.3048 equals meters per mile
5280 * 0.0003048 equals Kilometers per mile
miles per hour * 1.609344 equals Kilometers per hour

F-150Torqued
Member
Posts: 427  Re: Custom Pid Helpon: April 20, 2017 (GMT)

Well, I must ask for forgiveness ONCE AGAIN for the poor choice in using a hyphenated acronym. I didn’t mean “Minus” something. You may just drop the ‘-ft’ all together, then your there already. Your example (1000/1) would be correct (ASSUMING again that the ‘circumference’ of your tire was 1 meter) – which I doubt. As I mentioned I’m not a metric kinda’ guy (still have trouble recognizing metric socket sizes without looking at what’s stamped on them!), but my guess would be more on the order of 2 to 2 1/2 meters circumference – instead of your ‘1’.

——————

54371019

Capp777
Member
Posts: 2856  Re: Custom Pid Helpon: April 20, 2017 (GMT)

F-150Torqued:

Could you confirm the divide by 60? It
seems more logical to me that you need
to know the rounds per hour (*60).

userM
Member
Posts: 96  Re: Custom Pid Helpon: April 20, 2017 (GMT)

so the Circumference of 1 tire is 1,83 meters

([0C]/60)*(1/2,3323)*(1/2,813)*(1000/1,83)
I don’t know if we could tell that it equals with
([0C]/60)*83,2903651

Now, I don’t know what can I do with this virtual pid )

If I make it in the settings it turns blue but I can not bring it to torque dials.. :/

Capp777
Member
Posts: 2856  Re: Custom Pid Helpon: April 20, 2017 (GMT)

Quote from userM on April 20, 2017
so the Circumference of 1 tire is 1,83 meters

([0C]/60)*(1/2,3323)*(1/2,813)*(1000/1,83)
I don’t know if we could tell that it equals with
([0C]/60)*83,2903651

Now, I don’t know what can I do with this virtual pid )

If I make it in the settings it turns blue but I can not bring it to torque dials.. :/

End Quote.

[0C] equals revolutions per minute exit engine
([0C]*60) equals revolutions per hour exit engine
([0C]*60)*(1/0.83) equals revolutions per hour exit trans
([0C]*60)*(1/0.83)*(1/2.813) equals revolutions per hour exit diff
([0C]*60)*(1/0.83)*(1/2.813)*tire circumference equals meters per hour
([0C]*60)*(1/0.83)*(1/2.813)*(tire circumference/1000) equals kph
This assumes tire circumference is in meters.

([0C]*60)*(1/0.83)*(1/2.813)*(tire circumference/5280) equals mph
This assumes tire circumference is in feet.

Am I wrong with my thinking?

So if [0C] equals 1600 rpm…

(1600*60)*(1/0.83)*(1/2.813)*(1.83/1000) = 75.244 kph
(1600*60)*(1/0.83)*(1/2.813)*(6.00/5280) = 46.755 mph

in 6th gear.

(1600*60)*(1/0.83)*(1/2.813)*(1.83/1000) = [0D]
(1600*60)*(1/0.83)*(1/2.813)*1.83 = [0D]*1000
(1600*60)*(1/0.83)*1.83 = [0D]*1000*2.813
(1/0.83) = ([0D]*2813)/(1600*60*1.83)
1 = ([0D]*2813)/(1600*60*1.83)*0.83
0.83 = 1*(1600*60*1.83)/([0D]*2813)
0.83 = 1*([0C]*60*1.83)/([0D]*2813)

Gear Ratio = ([0C]*60*TireCir)/([0D]*2813)

0.83 = (1600*60*1.83)/(75.244*2813)

Edited.

F-150Torqued
Member
Posts: 427  Re: Custom Pid Helpon: April 21, 2017 (GMT)

Well, now that I think about it a little more, I’m not so sure. NO argument @CAP777 – but You MUST BE CORRECT because you came up with the correct answer!!!!!. And I have to use parts of your logic to get the right answer myself, so unfortunately that MUST mean I didn’t have it exactly right before. ANYHOW – like they say “math is fun”

Understanding that there are multiple ways get to Denmark, is this a simpler WAY to look at it?

We “KNOW” that the OP’s vehicle moves forward 1.83 ‘meters’ per tire revolution.

At a given RPM (say for example 1600 RPM), with an overall gear ratio through trans & differential of 2.333 —:

means the tire should be turning 1600/2.33 revolutions “PER MINUTE”, or (1600/2.33) = 686.695278 tire revs per minute through the cumulative gear rations per OP’s post. With a tire circumference of 1.83 meters, that would move the vehicle along 1256.6523 meters per minute. Correct?

THEN: we should be able to simply multiply that by 60 to get ‘meters per hour’. Then divide by 1000 for kph: that = 75.399 kph (like you said), or

meters per hour = ([OC]/2.33)*1.83*60

As is usually the case there are several ways to skin a cat. Using my original (though perhaps lame) acronyms, could we correctly express this for a Torque Formula as:

RPM_to_kph Formula = ((([OC]/(ODr*Diffr))*TireCir)*60)/1000

Where:
TireCir is Tire circumference in meters
ODr is Gear ratio, in this case Over Drive
Diffr is Differential ratio

Of course if the Units are specified in ‘kph’ in a Custom PID, Torque should convert it to MPH if that option is set in General Settings.

Whatcha think?

————————–

54371019

EDIT: TireCir & formula brackets

Capp777
Member
Posts: 2856  Re: Custom Pid Helpon: April 21, 2017 (GMT)

Works for me. Math is fun when
you are trying something new.

I could have condensed the equations
but I was trying to show each step to
reaching the final result based upon my
thinking of *60 vs /60.

Hopefully the OP can follow along and

userM
Member
Posts: 96  Re: Custom Pid Helpon: April 21, 2017 (GMT)

So the correct formula should be
RPM_to_kph Formula = ((([OC]/(ODr*Diffr))*TireCir)*60)/1000

or

RPM_to_kph Formula = ((([OC]/(0.83*2.813))*1.83)*60)/1000

and the PID

MODE/PID: blank
Long Name: My RPMSPEED
Short Name: RPMSpeed
Min – Max as appropriate
Units: KPH
Formula: ((([OC]/(0.83*2.813))*1.83)*60)/1000
Start Stop Diagnostic: blank

Please check the numbers when possible, and will let you know later the results )
Thanks for the help and your time

——————————————–
1.
edit: I checked the formula in excel
so for OC=1600 the result is 75.24
for OC = 6000 the results is 282.2
I wish my car could be that fast
——————————————
2.

I can’t find a Gear Pid

Is there any other way to get the current gear?
As I told there is another program which can give the current gear just from the gear ratios
I have check it and it works in my car but for so many other reasons i prefer this app

Capp777
Member
Posts: 2856  Re: Custom Pid Helpon: April 21, 2017 (GMT)

[0C] Engine rpm
[0D] Vehicle Speed in kph
TireCir Tire Circumference in meters

GearRatio = ([0C]*60*TireCir)/([0D]*2813)

0.83 = (1600*60*1.83)/(75.244*2813)

To my knowledge there is no way to look
up a ratio to gear.

 Pages:  2
WP-Forum by: Fredrik Fahlstad, Version: 2.4