Go Back   Infamous Nissan - Hardbody / Frontier Forums > Model Specific > Hardbody Forum (D21)

Reply
 
Thread Tools Display Modes
Old 05-04-2018, 06:44 PM   #1
jp2code
Software Developer
 
jp2code's Avatar
 
Join Date: Dec 2011
Location: Longview, TX [USA]
Age: 48
Posts: 8,044
Vehicle: 94 LB 2x4 Manual VG33e
Thanks: 1,158
Thanked 996 Times in 873 Posts
Default Speedometer Calculator

There was a Facebook post earlier where people were talking about why putting bigger tires would make the speedometer read differently.

The topic evolved into what actual MPH to expect with different size tires, which was dependent upon what rear axle gear is in the truck.

I'm a software developer, so I played around with the idea. Shortly, I had a simple little program to calculate the MPH for a vehicle, given the tire height in inches.

For tire sizes, 3 values are provided from this website:
http://www.jekylhyderacing.com/HeightofTires.htm

Code:
tireHeight in new double[] { 25.52, 26.31, 33 }
// 25.52 is how tall stock 195/75/14 tires are.
// 26.31 is the height of my 225/60/18 tires.
// 33 is the height of the tires in the Facebook post.

axle in new double[] { 3.5, 4.1, 4.6 }
// 3.5 = gear ratio of the HF35 axle in the Facebook post.
// 4.1 = gear ratio of the HG41
// 4.6 = gear ratio of the HG46

rpm in new int[] { 2500, 3000, 3500 }
Here is the piece of code I wrote to calculate MPH:

Code:
    public static double CalculateMPH(int revolutionsPerMinute, double tireHeightInInches, double axleRatio)
    {
        double result = 0;
        if ((0 < revolutionsPerMinute) && (0 < tireHeightInInches) && (0 < axleRatio))
        {
            double tireHeightToMilesAround = Math.PI * tireHeightInInches / INCHES_PER_MILE;
            double revolutionsPerHour = MINUTES_PER_HOUR * revolutionsPerMinute;
            result = tireHeightToMilesAround * revolutionsPerHour / axleRatio;
        }
        return result;
    }
The Main() method simply calls the calculation (3 x 3 x 3 = 27) times.

Anyone can look at the output, or even change the parameters to what happens.

Here is the code, hosted on Dot Net Fiddle's website.

https://dotnetfiddle.net/kaAhRJ
__________________
Joe (not a mechanic!) Don't have an account? EMAIL ME
Free Service Manuals: -
Walk-through: Checking Nissan Trouble Codes
Everyone you meet is fighting a battle you know nothing about. Be kind always.

jp2code is online now   Reply With Quote
Old 05-04-2018, 06:47 PM   #2
jp2code
Software Developer
 
jp2code's Avatar
 
Join Date: Dec 2011
Location: Longview, TX [USA]
Age: 48
Posts: 8,044
Vehicle: 94 LB 2x4 Manual VG33e
Thanks: 1,158
Thanked 996 Times in 873 Posts
Default

On my truck with the HG46 axle:

If I get my engine up to 5500 RPM on stock 195/75/14 tires, I would be going 90.8 MPH.

If I were running 33-inch tires and my engine had enough horsepower to push itself up to 5500 RPM in 5th gear, it would be going 117.4 MPH.
__________________
Joe (not a mechanic!) Don't have an account? EMAIL ME
Free Service Manuals: -
Walk-through: Checking Nissan Trouble Codes
Everyone you meet is fighting a battle you know nothing about. Be kind always.

jp2code is online now   Reply With Quote
Old 05-04-2018, 07:12 PM   #3
Vuko
 
Join Date: Mar 2018
Location: NE
Posts: 37
Vehicle: 1992 SE KC
Thanks: 32
Thanked 3 Times in 3 Posts
Default

That's pretty cool you can do that. Thanks for sharing this with us.
Vuko is offline   Reply With Quote
Thanked by:
jp2code (05-04-2018)
Old 05-04-2018, 07:15 PM   #4
OldGreyBeast
1986.5 HB 4x4 3.0V6
 
OldGreyBeast's Avatar
 
Join Date: Mar 2012
Location: North AL
Age: 30
Posts: 3,418
Vehicle: 1986.5 Nissan D21
Thanks: 292
Thanked 389 Times in 340 Posts
Default

Reading some C code takes me back about 15 years. Been a long time. Pretty neat calculator, if only I had a working tach lol.
__________________
Build log for the Beast - https://beastbuildlog.blogspot.com - Last Updated 18 OCT 2016
OldGreyBeast is offline   Reply With Quote
Thanked by:
jp2code (05-04-2018)
Old 05-04-2018, 07:31 PM   #5
SBJ
Total Buzzkill
 
Join Date: Nov 2016
Location: OR
Posts: 1,312
Vehicle: '90 D21 4cyl 5spd 2wd
Thanks: 141
Thanked 147 Times in 136 Posts
Default

Neat. I have failed 2 programming classes in my life, one of which was for C.
SBJ is online now   Reply With Quote
Thanked by:
jp2code (05-04-2018)
Old 05-04-2018, 10:38 PM   #6
Deerhurst
4/86 SE-V6 2 tone 4x4 HB
 
Deerhurst's Avatar
 
Join Date: Apr 2013
Location: Oregon
Posts: 4,811
Vehicle: 1986.5 Hardbody
Thanks: 685
Thanked 436 Times in 404 Posts
Default

Neato! Guess I'll have to reinstall visual studio and compile it. Mind if I do that and do some tweaks? Not guarantee I'll get a chance to.
__________________
1986.5 SE-V6 4X4 D21 Hardbody
Pacesetter Long Tube Headers
Morimoto Mini D2S HID Projectors and Hella 500s
VG33i
Deerhurst is offline   Reply With Quote
Old 05-04-2018, 11:44 PM   #7
Hands On
XXXXXXXXXXXX
 
Hands On's Avatar
 
Join Date: Aug 2017
Location: United States
Posts: 166
Vehicle: A Hardbody
Thanks: 53
Thanked 25 Times in 24 Posts
Default

Take nothing away from JP2's code, but I have a manual swap planned for another car and came up on this gearing calculator online last night. Lots of features to save, print, email the data. Click the home button and it takes you to a plethora of other calculators as well. Excellent resource.

https://www.blocklayer.com/rpm-geareng.aspx
__________________
Yep.
Hands On is offline   Reply With Quote
Old 05-04-2018, 11:59 PM   #8
Foul_Mouth
Infamous Autocrosser
 
Foul_Mouth's Avatar
 
Join Date: Mar 2010
Location: Western NY
Posts: 3,893
Vehicle: 1986.5 4WD Reg Cab/ 1991 2WD Reg Cab(Red)/ 1995 2WD Reg Cab(Green)/ 91 & 92 WD21 4WD PathFinders
Thanks: 373
Thanked 555 Times in 451 Posts
Default

This takes it a step further.
http://www.grimmjeeper.com/gears.html
__________________
Nissan Truck Videos (Builds-Racing-Shows-Tech)
https://www.youtube.com/c/NissanTruckguy








Foul_Mouth is offline   Reply With Quote
Old 05-05-2018, 02:18 AM   #9
jp2code
Software Developer
 
jp2code's Avatar
 
Join Date: Dec 2011
Location: Longview, TX [USA]
Age: 48
Posts: 8,044
Vehicle: 94 LB 2x4 Manual VG33e
Thanks: 1,158
Thanked 996 Times in 873 Posts
Default

Holy crap! HandsOn and FM, those are certainly some extreme calculators!

Quote:
Originally Posted by Deerhurst View Post
Neato! Guess I'll have to reinstall visual studio and compile it. Mind if I do that and do some tweaks? Not guarantee I'll get a chance to.
The cool thing about these Fiddle sites:
  1. You can make whatever changes you want to the code on the screen. When you exit, it will ask if you want to save your changes. If you answer YES, it will branch off the original code and make a copy based on your changes ...and give you a slightly different URL.
  2. You do not need a compiler to make it run. It should run on the screen.
__________________
Joe (not a mechanic!) Don't have an account? EMAIL ME
Free Service Manuals: -
Walk-through: Checking Nissan Trouble Codes
Everyone you meet is fighting a battle you know nothing about. Be kind always.

jp2code is online now   Reply With Quote
Old 05-05-2018, 03:38 AM   #10
street_rulerr
 
Join Date: Nov 2015
Location: West Coast
Posts: 1,721
Vehicle: 1996 4x4 5spd
Thanks: 0
Thanked 122 Times in 117 Posts
Default

i did the same thing in excel months ago when i thought (and still think) my speedo vs tach were wildly off.
street_rulerr is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:04 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.