BASIC Motion Control

Off topic posts are welcome in this forum!
No smear campaign, or you will be banned!

Moderator: Mike Everman

PyroJoe
Posts: 1743
Joined: Wed Aug 29, 2007 5:44 pm
Antipspambot question: 125
Location: Texas

BASIC Motion Control

Found some fun stuff from the past, as I was shifting most of my archived software stuff to thumb drives.

Here is a QBASIC program written and run on a retired 486 machine, It was used to send a binary output to the lpt port. The binary number would energize specific pins. the pins would then trigger relays to close on a lpt relay board.

This particular program would energize a gear motor, which advanced 1/2" diameter polyethylene tube spooling from a large coiled roll. A electrical pneumatic cylinder with blade would be actuated by a electrical controlled air valve.

The 18000 count on line 124 would gave approx. 1" cut length
The 100 count on line 144 would give the knife relay enough time to acuate, otherwise the energize period was to brief for the relay to act.

Crude yes, but effective, as these few lines of code produced thousands of cut pieces.
Would like someday to send binary to the USB port controlling a relay, but this is proving difficult as the USB is not easily accessed for output. There are some work arounds, but nothing as slick as the lpt was.

'AUGUST 8, 2000
'QBASIC PROGRAM FOR MOTION CONTROL USING PARALLEL PORT
'AND PARALLEL PORT RELAY BOARD
'
'
CLS
PRINT " MOTION CONTROL SCREEN"
PRINT "----------------------------------------------------------------"

'---------PRESET PINS ON OR OFF------CLEARS COUNTERS
60 LET x = 0
61 LET c = 0
62 LET p = 0
70 LET PINS = 0 'CLEARS PIN 2 THROUGH 9 ON START
80 OUT 888, PINS
90 LET A = 0
100 LET B = 0
'---------RUNS COUNTER AND ENERGIZES PINS THROUGH BINARY
110 PRINT "input number to be cut": INPUT x 'asks how many units
111 PRINT "---hit esc key to stop cycle--"
112 LET c = c + 1'counter for how many units to be cut
119 LET p = c - 2: PRINT p
120 IF c = x + 2 THEN GOTO 240'cycle has cut required needed
121 LET A = 0
122 LET A = A + 1
124 IF A = 18000 THEN GOTO 140' TIMER FOR LENGTH OF TUBE
125 IF INKEY\$ = CHR\$(27) GOTO 240 'escapes cycle
126 GOTO 122
140 LET PINS = 5 'BLADE DOWN motor on
141 OUT 888, PINS
142 LET B = 0
143 LET B = B + 1 'TIMER TO LET BLADE cycle
144 IF B = 100 THEN GOTO 222
146 GOTO 143
222 LET PINS = 4 'BLADE UP motor still on
223 OUT 888, PINS
230 GOTO 112
240 OUT 888, 0
250 END