' Simple Basic Program to control stepper motor. ' Uses the parallel port, pins 3-6. ' Pin: Stepper Motor Coil: ' 3 (&H2) 4 ' 4 (&H4) 3 ' 5 (&H8) 2 ' 6 (&H10) 1 ' NOTE: Obviously you don't want to DRIVE a stepper with the parallel ' port (first, you don't want to run that much current, second, stepper ' motors are driven with grounded impulses, not positive!), so I used ' four simple NPN transistors and a 12V power supply (with a common ground ' to the parallel ports ground pins). The base of the NPN is connected ' to the pin on the parallel port. The collector is connected to the ' Stepper Motor Coil, and the emitter is connected with ground. ' I've seen similar setups with the ULN2003 chip, but I don't have any ' experience with this (I'm working on it!). ' ' Joe Thielen ' joe@joethielen.com ' joethielen@familyandyouth.org ' http://www.familyandyouth.org/joe ' 12/10/1998 ' Set delay D = 12500 temp$="1" cls LOCATE 1,1:print "STEP MOTOR CONTROL" LOCATE 3,1:print "1 = 1 rev clockwise" LOCATE 4,1:print "2 = 1 rev counter-clockwise" LOCATE 5,1:print "3 = 0.5 rev clockwise" LOCATE 6,1:print "4 = 0.5 rev counter-clockwise" LOCATE 7,1:print "5 = 10 rev clockwise" LOCATE 8,1:PRINt "6 = 1 rev clockwise, two-coil excitaion" LOCATE 9,1:PRINT "7 = 1 rev clockwise, half-step" LOCATE 15,1:print "0 = Exit Program" WHILE temp$="1" butt$=INPUT$(1) IF butt$ = "0" THEN temp$="0" END IF IF butt$ = "1" THEN FOR J1=1 to 50 GOSUB forward NEXT J1 END IF IF butt$ = "2" THEN FOR J1=1 to 50 GOSUB REVERSE NEXT J1 END IF IF butt$ = "3" THEN FOR J1=1 to 25 GOSUB forward NEXT J1 END IF IF butt$ = "4" THEN FOR J1=1 to 25 GOSUB REVERSE NEXT J1 END IF IF butt$ = "5" THEN FOR J1=1 to 50*10 GOSUB forward NEXT J1 END IF IF butt$ = "6" THEN FOR J1=1 to 50 GOSUB twocoilf NEXT J1 END IF IF butt$ = "7" THEN FOR J1=1 to 50 GOSUB halff NEXT J1 END IF WEND END FORWARD: FOR SM=1 to D:NEXT SM OUT &H278, &H10 FOR SM=1 to D:NEXT SM OUT &H278, &H8 FOR SM=1 to D:NEXT SM OUT &H278, &H4 FOR SM=1 to D:NEXT SM OUT &H278, &H2 RETURN REVERSE: FOR SM=1 to D:NEXT SM OUT &H278, &H2 FOR SM=1 to D:NEXT SM OUT &H278, &H4 FOR SM=1 to D:NEXT SM OUT &H278, &H8 FOR SM=1 to D:NEXT SM OUT &H278, &H10 RETURN TWOCOILF: FOR SM=1 to D:NEXT SM OUT &H278, &H10 + &H8 FOR SM=1 to D:NEXT SM OUT &H278, &H8 + &H4 FOR SM=1 to D:NEXT SM OUT &H278, &H4 + &H2 FOR SM=1 to D:NEXT SM OUT &H278, &H2 + &H10 RETURN HALFF: FOR SM=1 to D:NEXT SM OUT &H278, &H10 FOR SM=1 to D:NEXT SM OUT &H278, &H10 + &H8 FOR SM=1 to D:NEXT SM OUT &H278, &H8 FOR SM=1 to D:NEXT SM OUT &H278, &H8 + &H4 FOR SM=1 to D:NEXT SM OUT &H278, &H4 FOR SM=1 to D:NEXT SM OUT &H278, &H4 + &H2 FOR SM=1 to D:NEXT SM OUT &H278, &H2 FOR SM=1 to D:NEXT SM OUT &H278, &H2 + &H10 RETURN