free 8051 Microcontroller Projects AVR PIC Microcontroller Projects Tutorials Ebooks Libraries, interfacing tutorials, lcd tutorial, stepper motor, dc motor 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems

 
8051 microcontroller 8051 microcontroller
Forums

Go to page  [1] 2
Moderators: Ajay, Junied , abbas1707, Arun Kumar V, pdi33, Shailesh NAYAK, ۞ TPS ۞, shyam, sashijoseph
Author Post
cestudent
Mon Nov 10 2008, 03:56AM
 User Offline
Registered Member #12089
Joined: Mon Nov 10 2008, 03:46AM

Posts: 16
Thanked 0 times in 0 posts
hello guyz
how r u all?

i have 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
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
   
 


plzz help me

Back to top


Ajay
Mon Nov 10 2008, 09:45AM
Rickey's World Admin

 User Offline

Registered Member #1
Joined: Fri Feb 24 2006, 04:56AM

Posts: 4049
Thanked 754 times in 713 posts
CODE:
  BCF   PORTB,4
   DECFSZ   COUNTD
;    GOTO   LOOP1
;remove this instruction and try again.

   BSF   PORTB,5
LL   NOP
   GOTO LL

   END
 


www.rickeyworld.info
If you feel satisfied with the user's forum reply please click on the thank button.

Obey forum rules!
Respect others!
Back to top


sashijoseph
Mon Nov 10 2008, 11:14AM

 User Offline
Registered Member #5870
Joined: Mon Feb 04 2008, 06:26PM

Posts: 651
Thanked 141 times in 134 posts
CODE:
BCF   PORTB,4
   DECFSZ   COUNTD
    GOTO   LOOP1


The DECFSZ instruction is missing an operand.
Change to...

CODE:
BCF   PORTB,4
   DECFSZ   COUNTD,1
    GOTO   LOOP1


Let there be music........
Back to top


cestudent
Mon Nov 10 2008, 11:27AM
 User Offline
Registered Member #12089
Joined: Mon Nov 10 2008, 03:46AM

Posts: 16
Thanked 0 times in 0 posts
thanx alot Ajay & sashijoseph
am gonna check both codes and feed back with the results
Back to top


cestudent
Tue Nov 11 2008, 09:58AM
 User Offline
Registered Member #12089
Joined: Mon Nov 10 2008, 03:46AM

Posts: 16
Thanked 0 times in 0 posts
the problem has been solved with disabling the watchdog timer
thanx guyz for ur help

Back to top


Ajay
Wed Nov 12 2008, 11:25PM
Rickey's World Admin

 User Offline

Registered Member #1
Joined: Fri Feb 24 2006, 04:56AM

Posts: 4049
Thanked 754 times in 713 posts
great well my answer was wrong sorry.. i did not see your program properly.

[Topic moved to PIC Microcontroller Discussion]

www.rickeyworld.info
If you feel satisfied with the user's forum reply please click on the thank button.

Obey forum rules!
Respect others!
Back to top


cestudent
Thu Nov 13 2008, 01:07PM
 User Offline
Registered Member #12089
Joined: Mon Nov 10 2008, 03:46AM

Posts: 16
Thanked 0 times in 0 posts
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



       
                                               



waiting for ur replies guyz

[ Edited Thu Nov 13 2008, 01:23PM ]
Back to top


cestudent
Fri Nov 14 2008, 06:27AM
 User Offline
Registered Member #12089
Joined: Mon Nov 10 2008, 03:46AM

Posts: 16
Thanked 0 times in 0 posts
any help ppl
Back to top


ExperimenterUK
Fri Nov 14 2008, 12:55PM
 User Offline
Registered Member #9602
Joined: Tue Aug 05 2008, 04:15PM

Posts: 207
Thanked 38 times in 37 posts
You have routines UP and Down which presumably move the stepper one step either way.

Do they work ?
ie if you run UP 50 times, does it move 50 steps ?
if you run UP 50 times and then Down 50 times do you end up at the same place.?

If so, congratulations your hardware works and
you have a way to measure floors , just decide how many loops of UP or Down is a floor.

The general layout of your program seems odd to me.
I would suggest something like,

Start
//Initialize variables
Main:

Read button:
call Check for button pressed //routine to read buttons..set new floor
call Calculate Distance and direction //routine to... guess what..
call Up_ Down loops //do a set number of loops
go to Read button. //Go round again




Use Calls and returns and less GOTOs


[ Edited Fri Nov 14 2008, 01:04PM ]

Learning all the time
Back to top


cestudent
Sun Nov 16 2008, 06:11AM
 User Offline
Registered Member #12089
Joined: Mon Nov 10 2008, 03:46AM

Posts: 16
Thanked 0 times in 0 posts
thanx ExperimenterUK for ur help and advice
i have a question when I output .1 this means that the stepper has to move one step right ?


[ Edited Sun Nov 16 2008, 08:47AM ]
Back to top


Go to page  [1] 2  

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System

8051 Microcontroller Projects 8051 AVR tutorials PIC microcontroller, 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems