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. 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 ; pic@beowulf.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 >> Return-path: Phxsys3@aol.com From: Phxsys3@aol.com Full-name: Phxsys3 Message-ID: <8de0765d.2517d3fe@aol.com> Date: Mon, 20 Sep 1999 14:16:30 EDT Subject: Stepper code sample for half step- Strange stepper behavior To: PICLIST@mitvma.mit.edu, PHXSYS@aol.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: AOL 4.0 for Windows 95 sub 26 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. 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 ; pic@beowulf.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