Haberler:

Foruma Resim Yükleme ve Boyut Sınırlaması ( ! )  https://bit.ly/2GMFb8H

Ana Menü

proteus pic step motor

Başlatan murats123, 04 Kasım 2005, 02:33:00

murats123

Arkadaşlar proteus taki örnek devrelerden  motor examples  içindeki  picstepr  devresini yaptım  proteusta çalıştırınca her butona bastığımda motor bir adım ilerliyor devreyi yaptım butona basınca motor bir adım yerine devamlı hareket ediyor .ben her butona bastığımda motorun bir adım atmasını istiyorum, bir projede  kullanacağım  nasıl yapacağım konusunda  asm  veya pic basic ile ilgili bir program (pic16f84)  verebilirmisiniz. Aşağıdaki  asm programı.



                  LIST    p=16F84 ; PIC16F844 is the target processor

             #include "P16F84.INC" ; Include header file

             CBLOCK 0x10   ; Temporary storage                
                pos
                dc1
                dc2
             ENDC
             LIST    p=16F84 ; PIC16F844 is the target processor

             #include "P16F84.INC" ; Include header file

             CBLOCK 0x10   ; Temporary storage
             ENDC

             ORG   0
entrypoint    goto  start

             ORG   4
intvector     goto  intvector
       
start         clrw                    ; Zero.

             movwf   PORTB           ; Ensure PORTB is zero before we enable it.
             bsf     STATUS,RP0      ; Select Bank 1
             movlw   0xF0            ; Set port B bits 0-3 as outputs
             movwf   TRISB           ; Set TRISB register.          
                                                             
             bcf     STATUS,RP0      ; Select Bank 0
               
             movlw   3           ; Initialize the motor position
             movwf   pos                                            
             movwf   PORTB
             call    delay
             clrf    PORTB         ; Motor drive off   

;Main loop              
loop         btfss   PORTA,0         ; Test clockwise button
         call    stepcw
         btfss   PORTA,1         ; Test anti-clockwise button
         call    stepccw
         goto loop
                             
;Rotate one step clockwise                              
stepcw        bcf    STATUS,C         ; Clear the carry flag
         btfsc  pos,3            ; Set carry if this bit set
         bsf    STATUS,C
         rlf    pos,W         ; Pick up and rotate the motor's current position
             andlw  0x0F             ; Mask to lower nibble
             movwf  pos
             movwf  PORTB         ; Drive the outputs
             call   delay         ; Wait
             clrf   PORTB            ; Clear the output
             return

;Rotate one step counter clockwise                                                                                   
stepccw       bcf    STATUS,C         ; Clear the carry flag
         btfsc  pos,0
         bsf    pos,4
         rrf    pos,W         ; Pick up and rotate the motor's current position
             andlw  0x0F             ; Mask to lower nibble
             movwf  pos
             movwf  PORTB         ; Drive the outputs
             call   delay         ; Wait
             clrf   PORTB            ; Clear the output
             return

; This routine implements the delay between steps,
; and thus controls the motor speed.
delay         movlw   18        ; Outer loop iteration count
         movwf   dc1      
dl1         clrf    dc2            ; Initialize inner loop
dl2         nop
         nop
         decfsz  dc2,F        
         goto    dl2
         decfsz  dc1,F
         goto    dl1
         return

         END

stlg

Sevgili murats123
Arkadasım eger asm program yazmayı biliyorsan bu işlem cok basit
butonunu tanımlarsın, butonun basılıp basılmadıgını bir dongude kontrol
edersin ,basılmıssa tablodan sıradaki degeri al gel dersin, bu degeri step
motorunun baglı oldugu porta gonderirsin tabi her donguden cıkısında
bir sayıcıyı artırır, onu w ye yuklersin tablodan sıradaki veriyi alabilmen
icin, olusturacagın tablo alt programında ise step motora uygulayacagın
formatı kaydedersin bu işle ilgili internette bircok bilgiye ulasabilirsin step motorların farklı sürülüs bicimleri oldugunu unutma kolay gelsin

NOT:Yapacagın dongudeki gecikme cok hızlı olursa pıc cok hızlı oldugundan step motor birkac adım atabilir ya sureyi uzun tutacaksın yada
kesmeleri biliyorsan bu şekli kullanacaksın butona her basısta bir kesme olusacak step motor bir adım atıp duracak yeniden basılınca işlem yeni adımlarla devam edecek
           
ALLAHA EMANET OLUNUZ
ALLAHA EMANET OLUNUZ Hoştur bana senden gelen,  Ya gonca gül yahut diken,  Ya kaftandır yahut kefen,  Kereminde hoş lütfunda hoş.