3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Computer controlled OTA TV antenna.

Step 6The software.

The software.
This is not a tutorial on programming. You can use what ever language you want but I will use basic for sake of simplicity for these code snippets. If motor goes opposite from what you expect then the wiring is backwards. Use this test code to make sure the steeper motor is working right. Caveat: this worked for the motor i used. you may have to use different wires. Once of the reasons it is good to use a breadboard first before soldering.

Clockwise:

out 888,0
for x = 1 to 10
out 888, 1
sleep 1
out 888, 2
sleep 1
out 888, 4
sleep 1
out 888, 8
sleep 1
next x
out 888, 0

Counter clockwise:

out 888,0
for x = 1 to 10
out 888, 1
sleep 1
out 888, 8
sleep 1
out 888, 4
sleep 1
out 888, 2
sleep 1
next x
out 888, 0

You will compile this code with:
fbc -lang qb progname.bas

Note I will probably put up more extensive code later. You have enough to get you started. The code I have written is copyrighted and has some very special routines which I do not want to publish at this time.

Example: http://www.electro-tech-online.com/general-electronics-chat/3631-qbasic-program-controlling-stepper-motors-i-wrote-one.html



----------------------------------------------------------------------------------------------

What someone else wrote in legacy basic.
If anyone out ther is interested in controlling a unipolar stepper motor via the parallel port on your pc and also uses Qbasic then copy the code below into a qbasic file and have at it. The program will prompt the user for mode of operation eg. single coil excitation mode or double coil excitation mode, direction and how many clock cycles to make the delay. A good value for my "VERY ANCIENT" pentium 133mhz pc is anywhere from 45 to however long you want the delay between coil energization to be. below 45 clock cycles the stepper motor likes to malfuntion. I am using parallel printer sentronics? connector. Modify the program to your liking. Sorry I did not include comments.
pins #2 for coil 1
#3 for coil 2
#4 for coil 3
#5 for coil 4
#18(can be any ground) for ground.

I am also using a uln2803 darlington transistor array to drive the motor.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;
;Written by Sam Bixler ;
;Date 03-10-03 ;
;For controlling a unipolar stepper motor via a parallel port ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;

CLS
VarMode = 0
VarRot = 0
VarRev = 0
VarDelay = 0
int1 = 0


Main:
CLS
OUT 888, 0
DO UNTIL INKEY$ <> ""
PRINT "Enter the number of revolutions"
INPUT VarRev
VarRev = VarRev * 50
PRINT "Enter the Mode of operation"
PRINT " 1 for single coil excitation"
PRINT " 2 for double coil excitation"
INPUT VarMode
PRINT "Enter the number of delay cycles"
INPUT VarDelay
PRINT "Enter the direction of rotation"
PRINT "5 for CW 7 for CCW"
INPUT VarRot
VarMode = VarRot + VarMode
IF VarMode = 6 THEN GOTO ScCW:
IF VarMode = 7 THEN GOTO DcCw:
IF VarMode = 8 THEN GOTO ScCcw:
IF VarMode = 9 THEN GOTO DcCcw: ELSE GOTO nd:

LOOP

ScCW:
DO
GOSUB Step1:
GOSUB Step2:
GOSUB Step3:
GOSUB Step4:
VarRev = VarRev - 1
IF VarRev = 0 THEN GOTO Main:
LOOP

ScCcw:
DO
GOSUB Step4:
GOSUB Step3:
GOSUB Step2:
GOSUB Step1:
VarRev = VarRev - 1
IF VarRev = 0 THEN GOTO Main:
LOOP

DcCw:
DO
GOSUB Step5:
GOSUB Step6:
GOSUB Step7:
GOSUB Step8:
VarRev = VarRev - 1
IF VarRev = 0 THEN GOTO Main:
LOOP

DcCcw:
DO
GOSUB Step8:
GOSUB Step7:
GOSUB Step6:
GOSUB Step5:
VarRev = VarRev - 1
IF VarRev = 0 THEN GOTO Main:
LOOP

Step1:
OUT 888, 0
DO
OUT 888, 1
IF int1 = VarDelay THEN RETURN
int1 = int1 + 1
LOOP


Step2:
OUT 888, 0
DO
OUT 888, 2
IF int1 = 0 THEN RETURN
int1 = int1 - 1
LOOP

Step3:
OUT 888, 0
DO
OUT 888, 4
IF int1 = VarDelay THEN RETURN
int1 = int1 + 1
LOOP

Step4:
OUT 888, 0
DO
OUT 888, 8
IF int1 = 0 THEN RETURN
int1 = int1 - 1
LOOP

Step5:
OUT 888, 0
DO
OUT 888, 3
IF int2 = VarDelay THEN RETURN
int2 = int2 + 1
LOOP

Step6:
OUT 888, 0
DO
OUT 888, 6
IF int2 = 0 THEN RETURN
int2 = int2 - 1
LOOP

Step7:
OUT 888, 0
DO
OUT 888, 12
IF int2 = VarRev THEN RETURN
int2 = int2 + 1
LOOP

Step8:
OUT 888, 0
DO
OUT 888, 9
IF int2 = 0 THEN RETURN
int2 = int2 - 1
LOOP



nd:
OUT 888, 0

« Previous StepDownload PDFView All StepsNext Step »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
66
Followers
203
Author:Computothought(Computothought)
Educator, technician, unchef, and chief bottle washer. Be sure to see http://www.instructables.com/community/Computhoughts/ for updates and status on projects.