LiniStepper v1.

Operation from a PC

Connect the inputs of the circuit board to a PC’s parallel port, then enter this BASIC program to control the motor’s speed and direction. You may use different wiring, but note that attempting to output CHR$(13) (RETURN character) gives problems on some PCs.

Linistepper pins (starting closest to the diodes) Parallel Port Pins
on the DB25 at the PC
* ground (also attached to the motor ground) 19-35
* +5v regulated (power for PIC chip) n/a
* step input (new step on + going edge) 2
* direction input (hi = reverse) 3
* low power (lo = low power) 4
* mode 0 5
* mode 1 6

REM LiniStep.BAS
REM Setup
MAXDELAY = 20
MAXCOUNT = 32767
Plport = PEEK(1032) + (256 * PEEK(1033))
OUT Plport, 0: OUT Plport + 2, 0
OPEN "lpt1:" FOR OUTPUT AS #1
WIDTH #1, 255
MODE$ = "START": mode = 3
Restart:
rpos = 0: pos = 0
power = 1: dir = 0: Dcnt = MAXDELAY: step = 1
GOTO Display
Main: 'Main motor control loop
A$ = INKEY$
IF A$ <> "" THEN GOTO Incoming
PRINT #1, CHR$(0 + (dir * 2) + (power * 4) + (mode * 8));
PRINT #1, CHR$(step + (dir * 2) + (power * 4) + (mode * 8)); 
IF step = 1 then pos = pos + (2 * dir) - 1: rpos = rpos + (2 * dir) - 1
IF pos > MAXCOUNT OR pos < 0 THEN pos = 0
IF rpos > MAXCOUNT OR rpos < 0 THEN rpos = 0
PRINT "POS:";pos;" RELATIVE:";rpos;chr(13);
IF MODE$="STEP" THEN step = 0
GOSUB DELAY
GOTO Main
Incoming: 'Set appropriate mode
IF A$ = "Q" OR A$ = "q" OR A$ = "." THEN PRINT "Done": PRINT #1, CHR$(0): END
IF A$ = "6" OR A$ = "A" OR A$ = "a" THEN MODE$ = "ADVANCE": IF dir = 1 THEN A$="3" ELSE A$="9"
IF A$ = "4" OR A$ = "B" OR A$ = "b" THEN MODE$ = "BACK": IF dir = 1 THEN A$="9" ELSE A$="3"
IF A$ = "3" THEN Dcnt = Dcnt + MAXDELAY / 4
IF A$ = "9" THEN Dcnt = Dcnt - MAXDELAY / 4
IF A$ = "2" OR A$ = "S" OR A$ = "s" THEN Dcnt = Dcnt + 1: A$ = "S"
IF A$ = "8" OR A$ = "F" OR A$ = "f" THEN Dcnt = Dcnt - 1: IF MODE$ = "HALT" THEN step = 1:dcnt = MAXDELAY
IF Dcnt > MAXDELAY THEN Dcnt = MAXDELAY: IF A$ = "S" THEN A$ = "H"
IF A$ = "7" OR A$ = "G" OR A$ = "g" THEN MODE$ = "GO": step = 1
IF step = 0 THEN dcnt = MAXDELAY
IF MODE$ = "ADVANCE" AND dcnt = MAXDELAY THEN dir = 0
IF MODE$ = "BACK" AND dcnt = MAXDELAY THEN dir = 1
IF (MODE$ = "ADVANCE" OR MODE$ = "BACK") AND step = 0 THEN step = 1: MODE$ = "STEP"
IF Dcnt < 1 THEN Dcnt = 1: MODE$ = "LIMIT": IF mode > 0 THEN mode = mode - 1: dcnt = MAXDELAY / 2: MODE$ = "SHIFT"
REM Don't "shift" modes if you are trying to count steps unless you are on a valid microstep in the new mode.
IF A$ = "5" OR A$ = "T" OR A$ = "t" THEN IF step = 0 THEN A$="G" ELSE A$ = "H"
IF A$ = "1" OR A$ = "H" OR A$ = "h" THEN MODE$ = "HALT": step = 0: rpos = 0
IF A$ = "+" THEN A$ = "R": mode = mode + 1: IF mode > 3 THEN mode = 3
IF A$ = "M" OR A$ = "m" THEN A$ = "R": mode = mode + 1: IF mode > 3 THEN mode = 0
IF A$ = "-" THEN A$ = "R": mode = mode - 1: IF mode < 0 THEN mode = 0
IF A$ = "0" OR A$ = "R" OR A$ = "r" THEN MODE$ = "RESTART": GOTO Restart
IF A$ = "P" OR A$ = "p" THEN power = 1 - power
IF A$ = "*" THEN power = 1
IF A$ = "/" THEN power = 0
Display:
CLS
PRINT "Linistepper Demo"
PRINT ""
PRINT " Use the number key pad or the first letter."
PRINT ""
PRINT "  Power high=* -=More steps"
PRINT "       low=/   +=less"
PRINT "      Go=7 8-9=Faster  "
PRINT "    Back=4 5 6=Advance "
PRINT "    Halt=1 2-3=Slower  "
PRINT "   Reset=0   .=Quit    "
PRINT ""
PRINT "  5 Toggles between Halt and Go."
PRINT "  8 and 2 adjust the speed in small increments."
PRINT "  9 and 3 change it over 4 steps."
PRINT "  when Halted, Advance and Back will single step."
PRINT "  when running, they slow and change direction."
PRINT "  speed is remembered when Halted. Go resumes."
PRINT "  use Reset to move at slowest rate."
PRINT ""
PRINT " MODE "; MODE$; " DELAY"; Dcnt
IF dir = 0 THEN PRINT " FORWARD"
IF dir = 1 THEN PRINT " BACK"
IF mode = 0 THEN PRINT " FULL STEP"
IF mode = 1 THEN PRINT " HALF STEP"
IF mode = 2 THEN PRINT " MICROSTEP 6TH"
IF mode = 3 THEN PRINT " MICROSTEP 18TH"
IF power = 0 THEN PRINT " LOW POWER"
IF power = 1 THEN PRINT " FULL POWER"
GOTO Main
DELAY:
FOR I = 1 TO ( Dcnt * (10 - (mode*3)) )
NEXT I
RETURN 'End of Program