25 Years of Programming
An open source source for C, C++, OWL, BASIC, MDB, XLS, DOT, and more...
Home   Projects   Up   Sitemap   Search   Blog   Forum+Chat   About Us   Privacy   Terms of Use   Feedback   FAQ   Images   Services   Ads   Donate   Humor

MBASIC Bicycle gearing calculator

BIKECALC.BAS

This program will ask you for the following:

1)  The number of teeth on each gear of your bicycle.
2)  The diameter of your rear wheel in inches.
3)  The number of pedal revolutions per minute at which you travel.

It will output the following, for each gear:

1)  The number of the gear.
2)  The 'gear ratio' or mechanical advantage of that gear.
3)  The corresponding measure of 'gear inches' for that gear.
    Gear inches are the most common U.S. measures of bicycle gears.
    The measure equals the gear ratio times the wheel diameter.
    If you travel in a '70-inch' gear, it means you have the same
    mechanical advantage as if you had an old-fashioned tricycle
    or bicycle with the pedals on the front wheel, and a front
    wheel with a diameter of 70 inches!
4)  The distance you will travel forward with each pedal revolution.
5)  The speed you will achieve in that gear if you pedal at the
    specified number of pedal revolutions per minute.

10 'BIKECALC.BAS
11 'COPYRIGHT (C)1982 STEVEN WHITNEY. 
12 'Published under GNU GPL (General Public License) Version 2, with ABSOLUTELY NO WARRANTY.
13 'Initially published by http://25yearsofprogramming.com.
20 CLEAR
30 F1$="##" : F2$="###.#"
40 DIM A(3),B(7)
50 PRINT CHR$(27)"E";"This program will ask for the number of teeth on each gear of your bicycle.":PRINT "It will then print out relevant information about your gearing.":PRINT
60 PRINT "Do you want to use a printer for the output? (Y/N)":X$=INPUT$(1)
70 IF X$="Y" OR X$="y" THEN T=1
80 IF T=1 THEN PRINT "Make sure it's turned on. Press any key to continue.":Z$=INPUT$(1)
90 IF T=1 THEN LPRINT "Bicycle Gear Ratio Calculations":LPRINT STRING$(75,"-")
100 PRINT CHR$(27)"E":PRINT STRING$(75,"-"):PRINT
110 INPUT "How many chainwheels (front gears)";M
120 PRINT STRING$(75,"-")
130 PRINT
140 PRINT "==> Start input with the SMALLEST <=="
150 PRINT : PRINT 
160 FOR I=1 TO M
170 INPUT "Next chainwheel, number of teeth";A(I)
180 NEXT I
190 PRINT STRING$(75,"=")
200 PRINT
210 INPUT "How many freewheel (rear) cogs";N
220 PRINT STRING$(75,"-")
230 PRINT
240 PRINT "==> Again, start with SMALLEST <==":PRINT
250 PRINT 
260 FOR I=1 TO N
270 INPUT "Next cog, number of teeth";B(I)
280 NEXT I
290 PRINT STRING$(75,"=")
300 PRINT 
310 INPUT "Diameter of wheel (in inches)";D
320 PRINT STRING$(75,"-")
330 U=120
340 PRINT "One of the output columns is your speed at a given number of pedal revolutions":PRINT "per minute. Standard is 120 rpm. Do you want to change that (Y/N)":X$=INPUT$(1):IF X$="Y" OR X$="y" THEN PRINT:INPUT "Change to how many rpm";U
350 PRINT STRING$(75,"-")
360 IF T<>1 THEN 420
370 LPRINT:FOR I=1 TO M:LPRINT "Chainwheel # teeth:";:LPRINT A(I):NEXT I
380 LPRINT STRING$(26,"-")
390 FOR I=1 TO N:LPRINT "Freewheel cog, # teeth:";B(I):NEXT I
400 LPRINT STRING$(26,"-")
410 LPRINT "Diameter of wheel (in inches):";D
420 PRINT TAB(30)"'Gear Inches'"
430 PRINT TAB(30)"Ratio times";TAB(45)"Distance per";TAB(60)"Speed in mph"
440 PRINT "Gear";TAB(15);"Ratio to 1";TAB(30);"wheel diam.";TAB(45);"rev. (in feet)";TAB(60)"at";U;"rpm":PRINT "-------";TAB(15);"----------";TAB(30);"-------------";TAB(45);"--------------";TAB(60)"----------":PRINT
450 IF T=1 THEN LPRINT STRING$(75,"-"):LPRINT TAB(30)"'Gear Inches'":LPRINT TAB(30)"Ratio times";TAB(45)"Distance per";TAB(60)"Speed in mph"
460 IF T=1 THEN LPRINT "Gear";TAB(15);"Ratio to 1";TAB(30);"wheel diam.";TAB(45);"rev. (in feet)";TAB(60)"at";U;"rpm":LPRINT "---------";TAB(15);"----------";TAB(30);"-------------";TAB(45);"--------------";TAB(60)"----------":LPRINT
470 FOR I=1 TO M
480 FOR J=N TO 1 STEP -1
490 K=K+1
500 P=A(I)/B(J): REM RATIO
510 Q=P*D : REM TIMES WHEEL DIAM.
520 R=Q*3.14159/12
530 V=R*U/88
540 PRINT USING F1$;K;:PRINT TAB(15);USING F2$;P;:PRINT TAB(30);USING F2$;Q;:PRINT TAB(45);USING F2$;R;:PRINT TAB(60);USING F2$;V
550 PAGE=PAGE+1: IF PAGE MOD 15=0 THEN PRINT "Press Any Key to Continue":P$=INPUT$(1)
560 IF T=1 THEN LPRINT USING F1$;K;:LPRINT TAB(15);USING F2$;P;:LPRINT TAB(30);USING F2$;Q;:LPRINT TAB(45);USING F2$;R;:LPRINT TAB(60);USING F2$;V
570 NEXT J
580 PRINT : IF T=1 THEN LPRINT
590 NEXT I
600 PRINT "Run again with new information? (Y/N)":X$=INPUT$(1)
610 IF X$="Y" THEN 20 ELSE END
620 REM COPYRIGHT (C)1982 STEVEN WHITNEY. 

 

 

Valid HTML 4.01 Transitional Valid CSS
View content labeling at ICRA.
Copyright ©2007 Steven Whitney. Last modified 09/25/2007.