TCCoA Forums banner

1 - 10 of 10 Posts

·
Super Moderator
Joined
·
9,175 Posts
Discussion Starter #1
If anyone's interested, I wrote a little program this evening to calculate vehicle speed and engine RPM based on input tire dimensions. You input the tire size (or diameter) and your gearing, then it will give you an RPM for a certain MPH or vise versa. If there's interest I can add support to export calculated data to file for comparison.
 

·
Super Moderator
Joined
·
9,175 Posts
Discussion Starter #3 (Edited)
Yeah, that would be convenient. I guess my doing this was mostly an experiment to see if I still knew enough C++ to pull it off; last time I wrote anything was back in high school. As far as web languages, I don't know much to speak of. So if someone ambitious wants to try to write it for the web, I'll gladly send them or post the source code, provided of course we could get it hosted on the website...

Heck, here's the source code for anyone interested. I'll probably tweak it anyway over time to have more 'features'.

Code:
#include <iostream.h>

float TWm, TW, SW, RIM, DIA, CIRC, TREV, GEAR, TRANS, RPM, MPH;

int option1 = 1, option2 = 1, option3 = 1, option4 = 2;

main()
{
    do
    { 
            
         if(option4 == 2)
         {
              do
              {    
                  if(option1 != 1 && option1 != 2)
                  {
                     cout << option1 << " is an invalid option. Please select one of the valid options.\n";
                  };     
                  cout << "Calculate tire dimensions (1) or entire tire diameter manually (2)? ";
                  cin >> option1;
                  system("CLS");
              }
              while(option1 != 1 && option1 != 2);
              
              if(option1 == 1)
              {
                         cout << "Enter tire dimensions.\n\nExample: P215/70R15\n\n215 is the treadwidth\n70 is the sidewall ratio\n15 is the rim diameter\n\n";
                         cout << "Enter the treadwidth, in millimters: ";
                         cin >> TWm;
                         system("CLS");
                         cout << "Enter tire dimensions.\n\nExample: P215/70R15\n\n215 is the treadwidth\n70 is the sidewall ratio\n15 is the rim diameter\n\n";
                         cout << "Enter the sidewall ratio: ";
                         cin >> SW;
                         system("CLS");
                         cout << "Enter tire dimensions.\n\nExample: P215/70R15\n\n215 is the treadwidth\n70 is the sidewall ratio\n15 is the rim diameter\n\n";
                         cout << "Enter the rim diameter, in inches: ";
                         cin >> RIM;
                         TW = TWm / 25.4;
                         DIA = TW * SW / 100 * 2 + RIM;
                         system("CLS");
              };
              if(option1 == 2)
              {
                         cout << "Enter tire diameter, in inches: ";
                         cin >> DIA;
                         system("CLS");
              };
              
              CIRC = DIA * 3.14159;
              TREV = 63360 / CIRC;
              
              cout << "Enter final drive gear ratio. ";
              cin >> GEAR;
              system("CLS");
              cout << "4R70W     AOD\n3rd: 1.00 1.00\n4th: 0.70 0.67\n\nEnter ratio of transmisison drive gear: ";
              cin >> TRANS;
              system("CLS");
          };
          do
          {    
              if(option2 != 1 && option2 != 2)
              {
                 cout << option1 << " is an invalid option. Please select one of the valid options.\n";
              };     
              cout << "Calculate engine RPM from vehicle speed (1) or speed from engine RPM (2)? ";
              cin >> option2;
              system("CLS");
          }
          while(option2 != 1 && option2 != 2);
            
                     
          if(option2 == 1)
          {
                     cout << "Enter vehicle speed in miles per hour: ";
                     cin >> MPH;
                     system("CLS");
                     RPM = MPH / 60 * TREV * GEAR * TRANS;
                     
          };
          if(option2 == 2)
          {
                     cout << "Enter engine RPM: ";
                     cin >> RPM;
                     system("CLS");
                     MPH = RPM / GEAR / TRANS / TREV * 60;
          };
          
          cout << "Calculated and input data summary:\n";
          if(TWm != 0 && SW != 0 && RIM != 0)
          {
              cout << "Tire size: P" << TWm << "/" << SW << "R" << RIM << "\n";   
          };
          cout << "Tire diameter: " << DIA << " inches\n";
          cout << "Tire circumference: " << CIRC << " inches\n";
          cout << "Tire revolutions per mile: " << TREV << "\n";
          cout << "Transmission gear ratio: " << TRANS << "\n";
          cout << "Final drive gear ratio: " << GEAR << "\n";
          cout << "Vehicle speed: " << MPH << " MPH\n";
          cout << "Engine speed: " << RPM << " RPM\n\n";
          
          do
          {    
              if(option3 != 1 && option3 != 2)
              {
                 system("CLS");
                 cout << option1 << " is an invalid option. Please select one of the valid options.\n";
              };     
              cout << "New calculation?\n(1) Yes / (2) No ";
              cin >> option3;
          }
          while(option3 != 1 && option3 != 2);
          if(option3 == 1)
          {
              do
              {    
                  if(option4 != 1 && option4 != 2)
                  {
                     cout << option1 << " is an invalid option. Please select one of the valid options.\n";
                  };     
                  cout << "Use existing tire size and gearing values?\n(1) Yes / (2) No ";
                  cin >> option4;
                  system("CLS");
              }
              while(option4 != 1 && option4 != 2);
         };
    }
    while(option3 == 1);           
}
 

·
Super Moderator
Joined
·
11,910 Posts

·
Super Moderator
Joined
·
9,175 Posts
Discussion Starter #5
Yeah, that's the one I use too. It was more a product of boredom at work than anything else. ;)

If I did write it for the web to be integrated into our website, I assume I'd contact Joe or Oscar? Or would I have to try to get ahold of AAN directly?
 

·
Super Moderator
Joined
·
11,910 Posts
Contact AAN directly. They have the master keys to the site.

I think Bill may also still have complete access to the site.

Good luck getting a hold of either one of them ...
 

·
Super Moderator
Joined
·
9,175 Posts
Discussion Starter #8
Well, I'm gonna try my hands at javascript and try to port that code to some sort of useable webpage; if I can get it to work I'll redesign it to match the current template the homepage uses and host it on my server for opinions/debugging before trying to get it hosted here.
 

·
Super Moderator
Joined
·
9,175 Posts
Discussion Starter #9 (Edited)
Okay, I have "version 1" of the calculators webpage up on my server, address here: http://alhscds.dyndns.org/raw/tirecalc.html

There's a MPH/RPM based on gearing and tire size calculator, a calculator to give tire dimensions based on input factors, and a calculator to compare two sizes of tire for speedo accuracy.

I'm still in the process of setting precision to the fields and I haven't written the gear ratios popup yet, but otherwise...

Let me know what you think.

Now that I think on it - mods might want to move this to the work in progress section since it seems to have evolved into such. I'll send Eric at AAN an e-mail once I get sufficient input from enough people here to get it to a "final version".
 
1 - 10 of 10 Posts
Top