Assembly Code Share

Moderators: None (Apply to moderate this forum)
Number of threads: 387
Number of posts: 703

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
STEPPER MOTOR PROBLEM Posted by cestudent on 10 Nov 2008 at 8:24 AM
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 the count=0 .
am using pic16f84a and 6 wire stepper motor

 
; 
;******************************************************************* 
; 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

plzz help me
Report
Re: STEPPER MOTOR PROBLEM Posted by Atex on 17 Dec 2008 at 12:13 AM
: 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 the count=0 .
: am using pic16f84a and 6 wire stepper motor
:
: 
: 
:  
: ; 
: ;******************************************************************* 
: ; 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 <-- Unconditional jump to beginning of loop, instead should check if COUNTD is 0, if bigger only then jump
: 
:    BSF   PORTB,5
: LL   NOP
:    GOTO LL
: 
:    END
: 
:
: plzz help me
:

Report
Re: STEPPER MOTOR PROBLEM Posted by gibson24 on 3 Mar 2012 at 3:03 AM
hey there...could i use this program for pic 16F54?
i have the same thing to do but on this PIC
help please



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.