'**************************************************************************** 'Copyright 30-9-1998 Luberth Dijkman Bangert 23 1619 GJ Andijk Nederland 'Qbasic plotter -> more @ http://home.wxs.nl/~luberth/ 'Program read a HPGL file and Control's stepper motors connected on parallel port 'this time using 5804 ic's 'Send me a e-mail if u like or use it!? to luberth@wxs.nl 'Please Send me a copy of your program if you make any changes 'Use @ own risk 'Don't blame me if you blown your dad's brand new computer skyhigh! 'This file is not to be sold or to be part of a commercial product without 'prior written permission from Luberth Dijkman 'All rights reserved. '**************************************************************************** ' HPGL file read and display made by James '**************************************************************************** 'Have fun! SCREEN 12: CLS 'screen12 and clear screen scale = 5 'The larger the number, the smaller the drawing on SCREEN OUT (&H378), 0 INPUT " Tell me Path & Name of HPGL plot File "; f$ IF f$ = "" THEN END OPEN f$ FOR BINARY AS #1 MotorX(0) = 1: MotorX(1) = 3: MotorX(2) = 2: MotorX(3) = 6: MotorX(4) = 4: MotorX(5) = 12: MotorX(6) = 8: MotorX(7) = 9 MotorY(0) = 16: MotorY(1) = 48: MotorY(2) = 32: MotorY(3) = 96: MotorY(4) = 64: MotorY(5) = 192: MotorY(6) = 128: MotorY(7) = 144 'above lines are output valeus (step coil firing sequence) xold = 0 yold = 0 DO WHILE NOT EOF(1) a$ = INPUT$(1, 1) 'read file 1 character B$ = B$ + a$ IF a$ = ";" THEN cmd$ = LEFT$(B$, 2) IF cmd$ = "PU" THEN mode$ = "M" 'Move IF cmd$ = "PD" THEN mode$ = "D" 'Draw l = LEN(B$) IF l > 3 THEN IF cmd$ = "PA" OR cmd$ = "PU" OR cmd$ = "PD" THEN comma = INSTR(B$, ",") x$ = MID$(B$, 3, comma - 3) x = VAL(x$) xscreen = VAL(x$) / scale y$ = MID$(B$, comma + 1, l - LEN(x$) - 4) y = VAL(y$) yscreen = VAL(y$) / scale IF mode$ = "M" THEN PSET (5 + xscreen, 475 - yscreen), 0 IF mode$ = "D" THEN LINE -(5 + xscreen, 475 - yscreen), 15 END IF END IF B$ = "" END IF xnew = x ynew = y IF xnew < xold THEN xi = xold - xnew ELSE xi = xnew - xold 'this IF ynew < yold THEN yi = yold - ynew ELSE yi = ynew - yold 'part 'of IF xi <= 0 THEN xi = yi 'the IF yi <= 0 THEN yi = xi 'code 'is IF xi > yi THEN 'for add2x = 1 'lines add2y = yi / xi 'under END IF 'an 'angle IF yi > xi THEN 'other wise add2x = xi / yi 'the add2y = 1 'plotter END IF 'would 'draw IF yi = xi THEN 'lines add2x = 1 'other add2y = 1 'then straight END IF 'or 45 degree 'lines wrong REM IF mode$ = "M" THEN OUT (&H378 + 2), 1 XOR 11 'if move then penup activate "strobe" pin1 parallel port REM IF mode$ = "D" THEN OUT (&H378 + 2), 0 XOR 11 'if pendown then output = off ' the xor 11 is because of inverted state of strobe, init, slct in ' autofeed is not inverted IF xnew > xold THEN xdirection = 16 ELSE xdirection = 0 'data 6 -> pin 7 IF ynew < yold THEN ydirection = 32 ELSE ydirection = 0 'data 7 -> pin 8 IF xnew = xold THEN xdirection = oldxdirection IF ynew = yold THEN ydirection = oldydirection oldxdirection = xdirection oldydirection = ydirection acceleratie = 230 'stepdelay stap: IF INKEY$ = CHR$(27) THEN GOTO theend 'if is pressed then end program IF CINT(u) < x THEN u = u + add2x IF CINT(u) > x THEN u = u - add2x IF CINT(v) < y THEN v = v + add2y IF CINT(v) > y THEN v = v - add2y ValeuX = CINT(u) MOD 8 'used for uln2803 & 5804 ValeuY = CINT(v) MOD 8 'see next lines why for 5804 IF ValeuX <> StoreValeuX THEN stepx = 1 ELSE stepx = 0 'data 1 -> pin 2 IF ValeuY <> StoreValeuY THEN stepy = 2 ELSE stepy = 0 'data 2 -> pin 3 StoreValeuX = ValeuX StoreValeuY = ValeuY OUT (&H378), 0 FOR t = 1 TO 1: NEXT t OUT (&H378), (xdirection + ydirection) FOR t = 1 TO 1: NEXT t OUT (&H378), 0 FOR t = 1 TO 1: NEXT t OUT (&H378), (xdirection + stepx + ydirection + stepy) FOR t = 1 TO 1: NEXT t OUT (&H378), 0 REM OUT (&H378), (MotorX(ValeuX)) + (MotorY(ValeuY)) 'for uln2803 output xi = xi - add2x yi = yi - add2y IF xi > yi THEN IF xi < 20 THEN acceleratie = acceleratie + 2.5 ELSE IF yi < 20 THEN acceleratie = acceleratie + 2.5 END IF IF acceleratie > 230 THEN acceleratie = 230 IF acceleratie < 50 THEN acceleratie = 50 FOR N = 1 TO acceleratie: NEXT N acceleratie = acceleratie - 1.5 IF xnew <> CINT(u) OR ynew <> CINT(v) THEN GOTO stap xold = x yold = y LOOP theend: OUT (&H378), 0 'turn all bits off OUT (&H378 + 2), 0 XOR 11 CLOSE END