piclist 1999\09\20\141757a >
Thread: Stepper code sample for half step- Strange stepper behavior
www.piclist.com/techref/io/steppers.htm?key=stepper
picon face BY : Jon Petty email (remove spam text)



Hi everyone

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.
http://www.beowulf.demon.co.uk.
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
; picspam_OUTspambeowulf.demon.co.uk

; (this code is NOT certified Year 2000 compliant)

       LIST P=12c509

   include "\mplab\P12c509.inc"

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

   ORG 0

; start of main code

   MOVWF   OSCCAL

   MOVLW   OPMASK
   OPTION

   MOVLW   BMASK
   TRIS    GPIO


; now go into a loop, output the next bit pattern on
; GP0 - GP4 (GP3 is input only)

   CLRF    INDEX
NEXT

; check for the run/stop button

   BTFSS   GPIO, RUN_BTN
   GOTO    NEXT

   BTFSS   GPIO,DIR_BTN
   GOTO    CWISE

   INCF    INDEX, W
   GOTO    NEW_IDX
CWISE
   DECF    INDEX, W
NEW_IDX
   ANDLW   .7
   MOVWF   INDEX

; 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
   MOVWF   GPIO
   CALL    DELAY

   GOTO    NEXT


; routine to get step index

STEP
   ADDWF   PCL, F
   RETLW   B'00000001'
   RETLW   B'00000101'
   RETLW   B'00000100'
   RETLW   B'00000110'
   RETLW   B'00000010'
   RETLW   B'00010010'
   RETLW   B'00010000'
   RETLW   B'00010001'


; routine to delay between steps

DELAY

   MOVLW   .10     ; 10 mSec per step
   MOVWF   DELAY1
DEL_0
   MOVLW   .250        ; 1 millisecond delay
   MOVWF   DELAY2

DEL_1

   NOP
   DECFSZ  DELAY2, F
   GOTO    DEL_1

   DECFSZ  DELAY1, F
   GOTO    DEL_0

   RETURN

   END

<8de0765d.2517d3fe@aol.com> 7bit

See also: www.piclist.com/techref/io/steppers.htm?key=stepper

Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) Stepper code sample for half step- Strange stepper behavior

month overview.

new search...