Stepper code sample for half step- Strange stepper behavior
Jon Petty email (remove spam text)
I downloaded the following code to a 16c509 jw chip, which controls a stepper
based on a couple of buttons, figured out the wires on my stepper (with help
from the list), hooked everything up and the stepper displays strange
behavior. Sometimes it will turn 1/2 rev then stop and quiver. I accidentally
found that if it would only turn if the wire leads coming out of the motor
were coiled 180 deg around the motor. When I would hold the shaft and
depress the button the motor would turn, unwind the leads then stop a quiver.
If I put the leads straight it the motor will just quiver. I checked the
connections and 3 other motors that all exhibited this behavior.
I am using a ULN 2803 to drive the stepper. ANy ideas?
The code I used is designed to half step ther stepper.
The stepper I am using is unipolar, two phase, 6 lead, 12v, 15 deg per step
My question is, are all motors capable of half stepping?
What else could be causing this behavior?
Can I change the lookup table to get full steps?
; control a small stepper motor with a 12c509
; There are two controls, run/stop and direction.
; The motor steps when the RUN button is depressed.
; If the DIRECTION button is pressed the direction
; of rotation is reversed.
; Peter Lynch, 13 May 1998
; (this code is NOT certified Year 2000 compliant)
OPMASK EQU B'11000000'
BMASK EQU B'00101000' ; all bits output (except GP3 and 5)
; GP3 controls run/stop
; GP5 controls direction
RUN_BTN EQU 3
DIR_BTN EQU 5
DELAY1 EQU 0C
DELAY2 EQU 0D
INDEX EQU 0E ; step index
; start of main code
; now go into a loop, output the next bit pattern on
; GP0 - GP4 (GP3 is input only)
; check for the run/stop button
BTFSS GPIO, RUN_BTN
INCF INDEX, W
DECF INDEX, W
; here W contains the index (either incremented or decremented, depending
; on the direction switch) into the array for the new stepper actuations
CALL STEP ; convert the index into a bit pattern
; routine to get step index
ADDWF PCL, F
; routine to delay between steps
MOVLW .10 ; 10 mSec per step
MOVLW .250 ; 1 millisecond delay
DECFSZ DELAY2, F
DECFSZ DELAY1, F
See also: www.piclist.com/techref/io/steppers.htm?key=stepper
You must be a member of the
piclist mailing list
(not only a www.piclist.com member) to post to the