DECLARE SUB FourBIT (x1%, y1%, x2%, y2%, FileNAME$) 7 SCREEN 12 SCREEN 0 Intro1$ = "The program, TK22throttleGripToSlide.BAS, compares the throttle grip's position (as a fraction of full-throttle) to the throttle slide's position (as a fraction of full-throttle). This will be used, for example, to compare the slide's position at the grip's 1/4 rotation." Intro2$ = "The graph of the program shows that the slide position (as a fraction) is very close to being equal to the grip position (as a fraction). The most deviation is near 3/4 throttle where it is off by about 1/64 (the slide is higher than the grip position). Importantly, the slide position is much closer to the grip position in the range below 1/4 throttle. " Intro3$ = "This graph only plots the vertical displacement of the link tied to the throttle shaft. It ignores the small deviation due to the second link attached to the slide itself. The deviation from that second link should be even less than that of the 1st link, and if anything, the deviation from the second link would work to reduce the overall deviation. " Intro4$ = "Because the first lever arm is between -45 deg and 45 deg, the vertical motion is greater than the rotational motion in fractional terms. In other words, the fraction of the vertical position is greater than the fraction of the rotational position for most of the travel. It is equal only at 0 (idle) and 1 (full). The fraction of the vertical motion is greater than the fraction of the rotational motion early. Then the motion becomes equal. Then later, the fraction of the vertical motion is less than the fraction of the rotational motion." Intro5$ = "" 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," PRINT "and save numerical print out of the data to the same file," INPUT "or just press enter to continue."; p IF p = 4 THEN OPEN "TK22tgts.txt" FOR OUTPUT AS #1 ' for "output" so as to overwrite the previous file PRINT #1, Intro1$ CLOSE OPEN "TK22tgts.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 "TK22tgts.txt is saved in this program's current folder." INPUT "Press enter to continue"; a END IF CLS REM this sets up the graphic port and text port SCREEN 12 VIEW (100, 0)-(445, 345) ' This will use 345 pixels square to plot data. it starts at 100 to give room for the vertical scale. WINDOW SCREEN (0, 1)-(1, 0) ' vertical and horizontal scales are from 0 to 1 (remember, using this command will force the vertical scale to be reversed. There is no way to fix it. Must correct for it when plotting. COLOR 8 '8 is dark gray FOR grid = 0 TO 1 STEP (1 / 16) 'draw the grid in sixteenth steps in gray LINE (0, grid)-(1, grid) LINE (grid, 0)-(grid, 1) NEXT grid COLOR 15 '15 is white FOR grid = 0 TO 1 STEP (1 / 4) 'draw the grid in quarter steps in white LINE (0, grid)-(1, grid) LINE (grid, 0)-(grid, 1) NEXT grid VIEW PRINT 1 TO 23 'set up text area on the whole screen to put in vertical scale COLOR 4 'color for vertical scale. 7 is light gray PRINT " Full" 'print vertical scale PRINT "" PRINT "" PRINT "" PRINT "" PRINT "3/4 Throttle" PRINT "" PRINT "" PRINT "" PRINT "" PRINT "1/2 Throttle" PRINT "" PRINT "" PRINT "" PRINT "" PRINT "" PRINT "1/4 Throttle" PRINT "" PRINT "" PRINT "" PRINT "" PRINT " Idle" VIEW PRINT 23 TO 30 COLOR 10 PRINT " Idle 1/4 1/2 3/4 Full "; COLOR 10 PRINT "Horizontal is grip scale. "; COLOR 4 PRINT "Vertical is slide scale." COLOR 10 PRINT "Green line is reference assuming grip position = slide position" COLOR 4 PRINT "Red line shows actual slide position based on grip position." COLOR 10 FOR grip = 0 TO 1 STEP (1 / 345) 'go through all grip positions and plot slide position. slide = grip 'For this iteration, slide = grip (used as a reference) slide = 1 - slide 'correcting for upside down vertical scale PSET (grip, slide) NEXT grip COLOR 4 FOR grip = 0 TO 1 STEP (1 / 345) 'go through all grip positions and plot slide position. slide = (1 / .91) * ((1.27 * SIN((.74 * grip) - .22166)) + .28) 'For this iteration, using slide formula IF p = 4 THEN ' this prints to the output file OPEN "TK22tgts.txt" FOR APPEND AS #1 'now "append" to add to the file PRINT #1, "grip ="; PRINT #1, grip; PRINT #1, " slide ="; PRINT #1, slide CLOSE END IF slide = 1 - slide 'correcting for upside down vertical scale PSET (grip, slide) NEXT grip 25 REM this generates the file name in case a save-to-bitmap is requested. bitmapname$ = "TK22tgts" VIEW PRINT 27 TO 30 COLOR 15 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