Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

testing stepper motor problem- it doesn't stop

Status
Not open for further replies.

CEstudent

Junior Member level 1
Joined
Feb 13, 2008
Messages
17
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,396
steeper motor application in lifts

hello guyz
how r u all?

i had a problem while testing stepper motor
i wrote an assembly code to rotate the stepper motor for a Specific number of steps and then it should stop but the stepper is still moving!!! can u tell what to do coz i want to stop the stpper motor after count=0 .
am using pic16f84a and 6 wire stepper motor

this is the code
Code:
; 
;*******************************************************************
; NOTES:
; 
;
;       PORTBO= NORTH POLE
;       PORTB1= EAST POLE 
;       PORTB2= SOUTH POLE
;       PORTB3= WEST POLE 
;*****************************************************************


PORTA		EQU     5
PORTB                      EQU     6 
STATUS		Equ 	3
TMR0		EQU	1
COUNT		EQU	0CH 
COUNT1		EQU	0DH
INTCON		EQU	0BH
COUNTD		EQU	0FH

;******************************************************************
        LIST    P=16F84A
        
        org   	0
        goto 	START

;*********************************************
 

DELAY	CLRF	TMR0
	MOVLW	.10
	MOVWF	COUNT
	BCF	STATUS,5
WAITA	BCF	INTCON,2
WAITB	BTFSS	INTCON,2
	GOTO	WAITB
	DECFSZ	COUNT,1
	GOTO	WAITA
	RETURN
	RETLW	0
;**************************************

START 
 
	BSF	STATUS,5 ;BANK1
	MOVLW	B'00000000'		 
	TRIS	PORTB               ; b0:b3 " stepper output " 
	MOVLW	B'00000011'		
	TRIS	PORTA	
	MOVLW	B'0000001'
	OPTION
	BCF  	STATUS,5  ; BANK0 

	CLRF	PORTB
	MOVLW	.10
	MOVWF	COUNTD
	
LOOP1	
	BSF	PORTB,4 
	CALL	DELAY 

	MOVLW	.1
	MOVWF	PORTB

	CALL   DELAY
	


	MOVLW	.2
	MOVWF	PORTB


	CALL	DELAY 
	

	MOVLW	.4
	MOVWF	PORTB

	CALL	DELAY 
	
	 
	MOVLW	.8
	MOVWF	PORTB
	

	BCF	PORTB,4
	DECFSZ	COUNTD
 	GOTO	LOOP1

	BSF	PORTB,5
LL	NOP
	GOTO LL

	END


plz help
 

Re: stepper motor problem

Hi

the watchdog timer is configured on and is reseting the program, modify the lines:

WAITB BTFSS INTCON,2
GOTO WAITB
CLRWDT ; <------ kick the watch dog
DECFSZ COUNT,1
GOTO WAITA


LL NOP
CLRWDT ; <------ kick the watch dog
GOTO LL

or disable the watchdog timer with the directive:

LIST P=16F84A
__CONFIG 0x200B

and finally the instruction retlw 0 in the delay routine is never reached because the instruction return before you can leave any or both but in your code is not needed.

regards
 

Re: stepper motor problem

thanx alooot narccizzo:D

it works am happy :D
 

Re: stepper motor problem

sorry guys i have an other problem

let me tell u what i do , i am doing lift project , in this code am using the input switches as floor requests and each floor request has specific number of steps and the lift should calculate the distance and the direction

but the problem when i tested the code the distance was wrong !!

maybe because i dont know how to tell the stepper motor to move for 30 steps for example or is there any calculation to do that in a correct way
here my code

Code:
; 
;*******************************************************************
; NOTES: 
; 
;
;       PORTBO= NORTH POLE
;       PORTB1= EAST POLE 
;       PORTB2= SOUTH POLE
;       PORTB3= WEST POLE 
;*****************************************************************


PORTA		EQU     5
PORTB           EQU     6 
STATUS		Equ 	3
TMR0		EQU	1
COUNT		EQU	0CH 
COUNT1		EQU	0DH
INTCON		EQU	0BH
COUNTD		EQU	20H
CURRENTCOUNT	EQU	21H 
DISTANCE	EQU	22H 

;******************************************************************
        LIST    P=16F84A
        __CONFIG 0x200B 
        org   	0
        goto 	START

;*********************************************
 

DELAY	CLRF	TMR0
	MOVLW	.3
	MOVWF	COUNT
	BCF	STATUS,5
WAITA	BCF	INTCON,2
WAITB	BTFSS	INTCON,2
	GOTO	WAITB
	DECFSZ	COUNT,1
	GOTO	WAITA
	RETURN
	RETLW	0
;**************************************

START 
 
	BSF	STATUS,5 ;BANK1
	MOVLW	B'00000000'		 ; SET B0 , B1 ,B2,B3,AS OUTPUT  
	TRIS	PORTB	
	MOVLW	B'00001111'		 ; SET A0 , A1 ,A2,A3,AS INPUT SWITCHES 
	TRIS	PORTA	
	MOVLW	B'0000001'
	OPTION
	BCF  	STATUS,5  ; BANK0 

	CLRF	PORTB
	


	MOVLW	.0
	MOVWF	CURRENTCOUNT 

loop1	BTFSS	PORTA,0 	; check for a floor1 request 
	goto	check1
	MOVLW	.0
	MOVWF	COUNTD
	GOTO	MAIN
		
	
check1	BTFSS	PORTA,1		; check for a floor2 request 
	goto	check2
	MOVLW	.30
	MOVWF	COUNTD
	GOTO	MAIN



check2	BTFSS	PORTA,2		; check for a floor3 request 
	goto	check3
	MOVLW	.50
	MOVWF	COUNTD
	GOTO	MAIN
	
	
check3	BTFSS	PORTA,3		; check for a floor4 request 

	goto	check4
	MOVLW	.70
	MOVWF	COUNTD
	GOTO	MAIN

check4	goto	loop1	


MAIN 



	MOVF	COUNTD,W
	subwf	CURRENTCOUNT,W   ; distanation is w 
	MOVWF	DISTANCE
	MOVF	COUNTD,W
	MOVWF	CURRENTCOUNT 
	btfss	STATUS,0        ; test if the result is positive or negative 
	goto	UP
	goto    DOWN

	



UP 	MOVLW	.8
	MOVWF	PORTB

	CALL   DELAY
	


 	MOVLW	.4
	MOVWF	PORTB


	CALL	DELAY 
	

 	MOVLW	.2
	MOVWF	PORTB

	CALL	DELAY 
	
	MOVLW	.1
	MOVWF	PORTB
	

	CALL	DELAY  
	DECFSZ	DISTANCE,1
 	GOTO	UP
	GOTO	loop1 
	 




DOWN 	MOVLW	.1
	MOVWF	PORTB

	CALL   DELAY
	


 	MOVLW	.2
	MOVWF	PORTB


	CALL	DELAY 
	

 	MOVLW	.4
	MOVWF	PORTB

	CALL	DELAY 
	
	MOVLW	.8
	MOVWF	PORTB
	

	CALL	DELAY  
	DECFSZ	DISTANCE,1
 	GOTO	DOWN 
	GOTO	loop1 
	 

END
 

stepper motor problem

any help ppl ??
 

stepper motor problem

Just out of curiosity, why do you need a stepper motor for such an application.

An ordinary motor can work well for this application..
Since you are using individual inputs for each floor, to detect the arrival of the lift, you could use individual inputs (say from an opto-interruptor or a magnetic limit switch) to detect the passage of the lift as it travels up and down. This way the mcu can determine which of the lifts have been reached and most importantly act as a feedback as to whether the lift is actually moving.

Say a person on floor 5 presses the button, assume the lift is in floor 1, the mcu moves the motor in the forward direction, it continously keeps track of the passing floors (the limit switches will pulse every time the lift passes by), when floor 5 is reached, the mcu switches of the motor (you could reduce the motor speed by using PWM or simply switching to a lower speed).

This will eliminate all the calculations and simplify the hardware.

thanks
a
 

stepper motor problem

arbj thanx for u idea it seems so easier

gurpreet312 thanx for the site
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top