DECLARE SUB FourBIT (x1%, y1%, x2%, y2%, FileNAME$) 7 SCREEN 12 SCREEN 0 Intro1$ = "The program, TK22needleGraphic.BAS, compares 2 carburetor needle profiles for TK-22 carbs. The Teikei TK-22 carbs are found on various Kawasaki KZ 550, 500, and 400-cyl motorcycles. The needles compared are the Kawasaki 4D93 needle and the Dynojet DN0205 needle. The 4D93 needle is the adjustable version of the stock 4D92 needle. The 4D93 has 5 clip positions and the second from the top makes the needle identical to the fixed clip 4D92 needle. The DN0205 is a stainless steel replacement needle made by Dynojet and is available in the Dynojet kit #DJ2305. It has 6 clip positions and Dynojet recommends the 3rd position from the top. Each clip position moves the needle by 1 mm." Intro2$ = "As the needle moves upward due to throttle action, it moves through an opening called the needle-jet. The needle's taper determines the amount of area in the needle-jet's orifice that is open for fuel to flow through. The program compares the needles through their range of motion and plots the difference between two needles based on throttle position. The comparison is done by selecting a reference needle and clip position, and comparing a test needle and clip position against the reference. Either needle type can be chosen as a reference, and any available clip position can be chosen for the reference needle. The test needle can also be either needle type and can have any available clip position. Once the needles and clip positions are chosen, the program calculates the difference in exposed cross-sectional area at the needle-jet's mouth, for the two needles, at every throttle position. The percentage difference, relative to the reference needle's exposed cross-sectional area at the jet-needle, is plotted for every throttle position." Intro3$ = "((Test needle's jet area Minus Reference needle's jet area) Divided by the reference needle's jet area) Times 100%." Intro4$ = "The jet area is the area of the needle-jet's mouth that the needle leaves exposed at that particular throttle position. A negative percentage value represents a leaner condition, and a positive percentage value represents a richer condition. For the calculations, the needle-jet orifice inside diameter is 0.102 inch. When the throttle is fully closed, the needle's position in the needle-jet mouth is 16.5 mm (from the bottom of the needle's clip). Full throttle is at 22.5mm of travel. Therefore the needle position at full throttle is 39 mm." Intro5$ = "If an invalid needle or clip position is selected, the program will still try to resolve the error and run, but will indicate the invalid condition. Finally, the program allows the graphic results to be saved as a bitmap image. The bitmap will be saved in the folder that the program resides in. The bitmaps should be loaded in MSpaint and saved as 256 color bitmap (not 24-bit), then saved as gifs." PRINT "The explanantion of this program is available as a text file." PRINT "Enter 4 to save the text file to the current folder this program resides in," INPUT "or just press enter to continue."; p IF p = 4 THEN OPEN "TK22prog.txt" FOR OUTPUT AS #1 ' for "output" so as to overwrite the previous file PRINT #1, Intro1$ CLOSE OPEN "TK22prog.txt" FOR APPEND AS #1 'now "append" to add to the file PRINT #1, " " PRINT #1, Intro2$ PRINT #1, " " PRINT #1, Intro3$ PRINT #1, " " PRINT #1, Intro4$ PRINT #1, " " PRINT #1, Intro5$ PRINT #1, " " CLOSE PRINT "TK22prog.txt is saved in this program's current folder." INPUT "Press enter to continue"; p END IF CLS PRINT "Enter the number of the reference needle." INPUT "1 for Kawasaki, 2 for Dynojet"; reference PRINT "Enter the clip position as counted from the top," INPUT " (1 to 5 for Kawasaki (2 is stock), 1 to 6 for Dynojet)."; referenceclip INPUT "Enter 1 if a shim washer is used (0 if not)"; referenceshim PRINT "" PRINT "" PRINT "Enter the number of the test needle." INPUT "1 for Kawasaki, 2 for Dynojet"; test PRINT "Enter the clip position as counted from the top," INPUT " (1 to 5 for Kawasaki (2 is stock), 1 to 6 for Dynojet)."; testclip INPUT "Enter 1 if a shim washer is used (0 if not)"; testshim REM this calculates the offset due to clip and washers REM the x values are in tenths of millimeters. So a 1mm clip offset is actually 10. REM because of this, measurements are multiplied by 10 for 1mm, 5 for .5mm IF test = 1 THEN testoffset = (testclip * 10) + (testshim * 5) - 20 IF test = 2 THEN testoffset = (testclip * 10) + (testshim * 5) - 30 IF reference = 1 THEN referenceoffset = (referenceclip * 10) + (referenceshim * 5) - 20 IF reference = 2 THEN referenceoffset = (referenceclip * 10) + (referenceshim * 5) - 30 REM These are the arrays that hold the profile (diameter) data DIM kaw(125 TO 550) AS SINGLE DIM dyno(125 TO 550) AS SINGLE DIM testneedle(125 TO 550) AS SINGLE DIM refneedle(125 TO 550) AS SINGLE REM this part puts the needle profiles into an array, position versus diameter. REM first is the Kaw needle. This array assumes clip position 2 FOR x = 125 TO 550 IF x < 201 THEN kaw(x) = .1 GOTO 99 END IF IF x < 241 THEN kaw(x) = .1 - ((.002 / 40) * (x - 200)) GOTO 99 END IF IF x < 434 THEN kaw(x) = .1 - .002 - ((.038 / 193) * (x - 240)) GOTO 99 END IF kaw(x) = 0 99 NEXT x REM next is Dynojet needle. This array assumes clip position 3 FOR x = 125 TO 550 IF x < 216 THEN dyno(x) = .1 GOTO 199 END IF IF x < 510 THEN dyno(x) = .1 - ((.05 / 295) * (x - 215)) GOTO 199 END IF dyno(x) = 0 199 NEXT x REM this converts diameters to radiuses FOR y = 125 TO 550 kaw(y) = kaw(y) / 2 dyno(y) = dyno(y) / 2 NEXT y REM this determines which profiles will be used. (which arrays will be used). FOR z = 125 TO 550 IF test = 1 THEN testneedle(z) = kaw(z) IF test = 2 THEN testneedle(z) = dyno(z) IF reference = 1 THEN refneedle(z) = kaw(z) IF reference = 2 THEN refneedle(z) = dyno(z) NEXT z REM this sets up the graphic port and text port SCREEN 12 VIEW (0, 0)-(639, 345) ' This will use 345 pixels to plot 230 data. That means 3:2 ratio. It's the best I can do to fit the data onto the graphic port. Tmax = 390 ' using full throttle as 39.0 mm means Tmax = 390 WINDOW SCREEN (-150, 165)-(150, Tmax) ' vertical scale is from 16.5mm to 39.5mm COLOR 7 'dark gray FOR Tp = 165 TO Tmax STEP ((Tmax - 165) / 8) 'Tmax - 165 is the throttle movement. Divide by 8 to get 1/8th throttle increments LINE (-100, Tp)-(100, Tp) 'draw horizontal lines at 1/8th throttle increments NEXT Tp COLOR 15 LINE (0, 165)-(0, Tmax) 'draw vertical lines COLOR 7 LINE (25, 165)-(25, Tmax) 'draw horizontal lines LINE (50, 165)-(50, Tmax) LINE (75, 165)-(75, Tmax) LINE (100, 165)-(100, Tmax) 'LINE (125, 165)-(125, Tmax) ' positive side can go beyond 100%. These two lines are optional scale lines, but shouldn't be needed normally 'LINE (150, 165)-(150, Tmax) LINE (-25, 165)-(-25, Tmax) LINE (-50, 165)-(-50, Tmax) LINE (-75, 165)-(-75, Tmax) LINE (-100, 165)-(-100, Tmax) VIEW PRINT 1 TO 23 'set up text area on the whole screen to put in vertical scale COLOR 7 'color for vertical scale PRINT " Idle" 'print vertical scale PRINT "" PRINT "" PRINT "" PRINT "" PRINT "1/4 Throttle" PRINT "" PRINT "" PRINT "" PRINT "" PRINT "1/2 Throttle" PRINT "" PRINT "" PRINT "" PRINT "" PRINT "" PRINT "3/4 Throttle" PRINT "" PRINT "" PRINT "" PRINT "" PRINT "Full Throttle" VIEW PRINT 23 TO 30 COLOR 10 PRINT " Lean -100% -75% -50% -25% "; COLOR 15 PRINT "0% "; COLOR 4 PRINT "25% 50% 75% 100% Rich " COLOR 7 PRINT "Scale is % change in needle-jet flow area.Test-needle versus reference-needle." REM This is the loop that compares the needles. REM Full throttle movement requires 23 mm of travel to be compared. That is from 16.5mm to 395mm away from bottom of clip. REM The formula after solving is: REM REM ReferenceRadius^2 - TestRadius^2 REM %difference = --------------------------------------------------------- x 100 REM HoleRadius^2 - ReferenceRadius^2 REM the hole is given diameter .102" holeradius = .051 FOR mm = 165 TO Tmax percentdif = (((refneedle(mm + referenceoffset)) ^ 2) - ((testneedle(mm + testoffset)) ^ 2)) / (((holeradius) ^ 2) - ((refneedle(mm + referenceoffset)) ^ 2)) * 100 COLOR 3 ' plot blue if no change IF percentdif > 0 THEN COLOR 4 IF percentdif < 0 THEN COLOR 2 LINE (0, mm)-(percentdif, mm) NEXT mm COLOR 15 LINE (0, 165)-(0, Tmax) 'redraw 0% line COLOR 15 IF reference = 1 THEN PRINT "Kaw needle is reference. "; IF reference = 2 THEN PRINT "Dyno needle is reference. "; IF (reference <> 1) AND (reference <> 2) THEN COLOR 13 PRINT "needle invalid. "; ' I'm allowing the program to run with invalid entries, but the output will show the entries are invalid COLOR 15 referenceclip = 0 ' if needle is invalid, clip is invalid END IF IF reference = 1 THEN ' checking clip positions for kaw needle IF (referenceclip <> 1) AND (referenceclip <> 2) AND (referenceclip <> 3) AND (referenceclip <> 4) AND (referenceclip <> 5) THEN referenceclip = 0 'check for valid clip positions END IF IF reference = 2 THEN 'checking clip positions for dyno needle IF (referenceclip <> 1) AND (referenceclip <> 2) AND (referenceclip <> 3) AND (referenceclip <> 4) AND (referenceclip <> 5) AND (referenceclip <> 6) THEN referenceclip = 0 'check for valid clip positions END IF IF referenceclip = 0 THEN COLOR 13 PRINT " Clip position invalid. "; COLOR 15 ELSE PRINT "Clip position:"; referenceclip; ". "; END IF IF referenceshim = 1 THEN PRINT "Shim under clip."; PRINT " " IF test = 1 THEN PRINT "Kaw needle under test. "; IF test = 2 THEN PRINT "Dyno needle under test. "; IF (test <> 1) AND (test <> 2) THEN COLOR 13 PRINT "needle invalid. "; ' I'm allowing the program to run with invalid entries, but the output will show the entries are invalid COLOR 15 testclip = 0 ' if needle is invalid, clip is invalid END IF IF test = 1 THEN ' checking clip positions for kaw needle IF (testclip <> 1) AND (testclip <> 2) AND (testclip <> 3) AND (testclip <> 4) AND (testclip <> 5) THEN testclip = 0 'check for valid clip positions END IF IF test = 2 THEN 'checking clip positions for dyno needle IF (testclip <> 1) AND (testclip <> 2) AND (testclip <> 3) AND (testclip <> 4) AND (testclip <> 5) AND (testclip <> 6) THEN testclip = 0 'check for valid clip positions END IF IF testclip = 0 THEN COLOR 13 PRINT " Clip position invalid. "; COLOR 15 ELSE PRINT "Clip position:"; testclip; ". "; END IF IF testshim = 1 THEN PRINT "Shim under clip."; PRINT " " 25 REM this generates the file name in case a save-to-bitmap is requested. IF reference = 1 THEN bitmapname$ = "K" IF reference = 2 THEN bitmapname$ = "D" referenceclip$ = STR$(referenceclip) bitmapname$ = bitmapname$ + LTRIM$(referenceclip$) IF referenceshim = 1 THEN bitmapname$ = bitmapname$ + "S" IF test = 1 THEN bitmapname$ = bitmapname$ + "K" IF test = 2 THEN bitmapname$ = bitmapname$ + "D" testclip$ = STR$(testclip) bitmapname$ = RTRIM$(bitmapname$) + LTRIM$(testclip$) IF testshim = 1 THEN bitmapname$ = bitmapname$ + "S" VIEW PRINT 27 TO 30 PRINT "Enter 1 to quit, Enter 2 to run again," INPUT "Enter 3 to save graph to a bitmap file in the current folder"; p IF p = 1 THEN SYSTEM IF p = 3 THEN PRINT "Please wait. Saving "; bitmapname$; ".BMP" VIEW WINDOW FourBIT 0, 0, 639, 479, bitmapname$ END IF IF p = 2 THEN CLS 0 GOTO 7 END IF CLS 2 GOTO 25 '------------------------this is the screen 12 bitmap generator--------------- SUB FourBIT (x1%, y1%, x2%, y2%, FileNAME$) DIM FileCOLORS%(1 TO 48) DIM Colors4%(15) IF INSTR(FileNAME$, ".BMP") = 0 THEN FileNAME$ = RTRIM$(LEFT$(FileNAME$, 8)) + ".BMP" END IF FOR x = x1% TO x2% FOR y = y1% TO y2% Colors4%(POINT(x, y)) = 1 NEXT y NEXT x FOR n = 0 TO 15 IF Colors4%(n) = 1 THEN SigCOLORS& = SigCOLORS& + 1 NEXT n FileTYPE$ = "BM" Reserved1% = 0 Reserved2% = 0 OffsetBITS& = 118 InfoHEADER& = 40 PictureWIDTH& = x2% - x1% + 1 PictureDEPTH& = y2% - y1% + 1 NumPLANES% = 1 BPP% = 4 Compression& = 0 WidthPELS& = 3780 DepthPELS& = 3780 NumCOLORS& = 16 IF PictureWIDTH& MOD 8 <> 0 THEN ZeroPAD$ = SPACE$((8 - PictureWIDTH& MOD 8) \ 2) END IF ImageSIZE& = (((ImageWIDTH& + LEN(ZeroPAD$)) * ImageDEPTH&) + .1) / 2 FileSIZE& = ImageSIZE& + OffsetBITS& Colr = 0 FOR n = 1 TO 48 STEP 3 OUT &H3C7, Colr FileCOLORS%(n) = INP(&H3C9) FileCOLORS%(n + 1) = INP(&H3C9) FileCOLORS%(n + 2) = INP(&H3C9) Colr = Colr + 1 NEXT n OPEN FileNAME$ FOR BINARY AS #1 PUT #1, , FileTYPE$ PUT #1, , FileSIZE& PUT #1, , Reserved1% 'should be zero PUT #1, , Reserved2% 'should be zero PUT #1, , OffsetBITS& PUT #1, , InfoHEADER& PUT #1, , PictureWIDTH& PUT #1, , PictureDEPTH& PUT #1, , NumPLANES% PUT #1, , BPP% PUT #1, , Compression& PUT #1, , ImageSIZE& PUT #1, , WidthPELS& PUT #1, , DepthPELS& PUT #1, , NumCOLORS& PUT #1, , SigCOLORS& u$ = " " FOR n% = 1 TO 46 STEP 3 Colr$ = CHR$(FileCOLORS%(n% + 2) * 4) PUT #1, , Colr$ Colr$ = CHR$(FileCOLORS%(n% + 1) * 4) PUT #1, , Colr$ Colr$ = CHR$(FileCOLORS%(n%) * 4) PUT #1, , Colr$ PUT #1, , u$ 'Unused byte NEXT n% FOR y = y2% TO y1% STEP -1 FOR x = x1% TO x2% STEP 2 HiX = POINT(x, y) LoX = POINT(x + 1, y) HiNIBBLE$ = HEX$(HiX) LoNIBBLE$ = HEX$(LoX) HexVAL$ = "&H" + HiNIBBLE$ + LoNIBBLE$ a$ = CHR$(VAL(HexVAL$)) PUT #1, , a$ NEXT x PUT #1, , ZeroPAD$ NEXT y CLOSE #1 END SUB