Newsgroups: comp.robotics
Path: brunix!sgiblab!spool.mu.edu!uwm.edu!linac!uchinews!raistlin!timbuk.cray.com!hemlock.cray.com!kilian
From: kilian@cray.com (Alan Kilian)
Subject: Miniboard stepper software
Message-ID: <1993Jun9.111030.2400@hemlock.cray.com>
Lines: 161
Nntp-Posting-Host: gopher
Organization: Cray Research, Inc.
Date: 9 Jun 93 11:10:30 CDT

This is written for the Miniboard and should be added as a routine in
hexmon40.asm.

It is not runnable as it stands since these two routines are hacked out
of two different motor drivers. Take either uni-step or bi-step and add them
to hexmon.

For uni-step I used a 5-wire stepper motor. There is one common wire and 4 coil
wires. Connect the common wire to your + voltage. Then each coil wire will be
grounded at the proper time.

This is an 8-state half-step sequence. Each call to uni-polar will take the
motor through 8 states and end up 4-steps further along. You certainly could
write it differnetly if you like.

uni-polar looks like this:

Coil 1	Coil 2	Coil3	Coil4
on	off	off	on	Micro-step #1
off	off	off	on	Micro-step #2
off	off	on	on	Micro-step #3
off	off	on	off	Micro-step #4
off	on	on	off	Micro-step #5
off	on	off	off	Micro-step #6
on	on	off	off	Micro-step #7
on	off	off	off	Micro-step #8

bi-polar looks like this:

Coil 1	Coil 2
For	For	Micro-step #1
For	off	Micro-step #2
For	Rev	Micro-step #3
off	Rev	Micro-step #4
Rev	Rev	Micro-step #5
Rev	off	Micro-step #6
Rev	FOR	Micro-step #7
off	For	Micro-step #8

The upper 4 bits of motctrl and PORTB are 0=off and 1=on
the lower 4 bits are 0=forward, 1=reverse

I write to both motctrl and PORTB so that if I get interrupted by hexmon
it will rewrite the motctrl value into PORTB and nothing will get jammed.
I added a 'f' command and I do this:  f00040000 to step 4*4 steps or
f00100000 to step 16*4 steps
You can vary the LDAA value in the delay routine to get the motor running
faster or slower.

To wire a unipolar motor plug each motor coil wire into the minus side of
each motor connection on the miniboard. You can only drive one unipolar
stepper with the miniboard

To wire a bipolar stepper, wire it like a bidirectional DC motor and plug
each coil into one motor channel. You can drive two bipolar steppers
with the Miniboard.

Make sure that the Miniboard's DC supply voltage matches the voltage of
the stepper motor. If you have 12 Volt steppers, just drive the Miniboard
with 12 Volts.

If you have 5 Volt steppers you will have to figure something else out
since the miniboard takes a minimum of more than 5 volts.
(Although I did drive a 5 volt stepper with 12 volts and it worked fine
but it got hot)

                    -Alan Kilian

bi-polar:			/* A bipolar stepper driver. */
bi-loop:			/* Register Y holds the number of 4-step */
	LDAA	#$30		/* increments to step. */
	STAA	motctrl
	STAA	PORTB
	JSR	delay
	LDAA	#$20
	STAA	motctrl
	STAA	PORTB
	JSR	delay
	LDAA	#$31
	STAA	motctrl
	STAA	PORTB
	JSR	delay
	LDAA	#$11
	STAA	motctrl
	STAA	PORTB
	JSR	delay
	LDAA	#$33
	STAA	motctrl
	STAA	PORTB
	JSR	delay
	LDAA	#$22
	STAA	motctrl
	STAA	PORTB
	JSR	delay
	LDAA	#$32
	STAA	motctrl
	STAA	PORTB
	JSR	delay
	LDAA	#$10
	STAA	motctrl
	STAA	PORTB
	JSR	delay

	DEY
	BNE	bi-loop

	JMP	cmd_loop
uni-polar:
uni-loop:
	LDAA	#$9F
	STAA	motctrl
	STAA	PORTB
	JSR	delay
	LDAA	#$1F
	STAA	motctrl
	STAA	PORTB
	JSR	delay
	LDAA	#$3F
	STAA	motctrl
	STAA	PORTB
	JSR	delay
	LDAA	#$2F
	STAA	motctrl
	STAA	PORTB
	JSR	delay
	LDAA	#$6F
	STAA	motctrl
	STAA	PORTB
	JSR	delay
	LDAA	#$4F
	STAA	motctrl
	STAA	PORTB
	JSR	delay
	LDAA	#$cF
	STAA	motctrl
	STAA	PORTB
	JSR	delay
	LDAA	#$8F
	STAA	motctrl
	STAA	PORTB
	JSR	delay

	DEY
	BNE	uni-loop

	JMP	cmd_loop

delay:
	LDAA	#$02		/* 02 is as fast as my motor will go. */
d1:				/* change to 20, 40, FF or 00 for longer */
	LDAB	#$FF
d2:
	DECB
	BNE	d2
	DECA
	BNE	d1
	RTS

-- 
 -Alan Kilian           kilian@cray.com 612.683.5499 (Work) 612.721.3990 (Home)
 "It is a little bit hard to tell if a cat is sleeping more than normal." -JLF
