Pic ile Bipolar Step Motor Kontrolü
İleri Yönde hareket | Geri Yönde hareket |
Step# | Q2-Q3 | Q1-Q4 | Q6-Q7 | Q5-Q8 |
Step 1 | ON | OFF | ON | OFF |
Step 2 | OFF | ON | ON | OFF |
Step 3 | OFF | ON | OFF | ON |
Step 4 | ON | OFF | OFF | ON |
|
Step# | Q2-Q3 | Q1-Q4 | Q6-Q7 | Q5-Q8 |
Step 1 | ON | OFF | OFF | ON |
Step 2 | OFF | ON | OFF | ON |
Step 3 | OFF | ON | ON | OFF |
Step 4 | ON | OFF | ON | OFF |
|
ASM kodu
list p=PIC16C84
__config h´3ff9´
org 0x2008
dw h´0001´
count equ 0x0c
dly1 equ 0x0d
dly2 equ 0x0e
org 0 ;reset vector
goto start ;go to beginning of program on reset
org 5 ;start of code space
start bsf STATUS,RP0 ;_select_register bank 1
movlw 0xf0 ;rb0-rb3 output (stepper), rb4-rb7 input (switch)
movwf TRISB ;portb all output
bsf OPTION_REG,NOT_RBPU ;disable pullups
bcf STATUS,RP0 ;_select_register bank 0
movlw 0x00 ;start with everything off
movwf PORTB
loop call gofwd
call gobwd
goto loop
gofwd movlw d´6´
movwf count
loopf
movlw 0x0a ;q2-q3 on, q1-q4 off, q6-q7 on, q5-q8 off
movwf PORTB
call delay
movlw 0x06 ;q2-q3 off, q1-q4 on, q6-q7 on, q5-q8 off
movwf PORTB
call delay
movlw 0x05 ;q2-q3 off, q1-q4 on, q6-q7 off, q5-q8 on
movwf PORTB
call delay
movlw 0x09 ;q2-q3 on, q1-q4 off, q6-q7 off, q5-q8 on
movwf PORTB
call delay
decfsz count,1
goto loopf
return
gobwd
movlw d´6´
movwf count
loopb
movlw 0x09 ;q2-q3 on, q1-q4 off, q6-q7 off, q5-q8 on
movwf PORTB
call delay
movlw 0x05 ;q2-q3 off, q1-q4 on, q6-q7 off, q5-q8 on
movwf PORTB
call delay
movlw 0x06 ;q2-q3 off, q1-q4 on, q6-q7 on, q5-q8 off
movwf PORTB
call delay
movlw 0x0a ;q2-q3 on, q1-q4 off, q6-q7 on, q5-q8 off
movwf PORTB
call delay
decfsz count,1
goto loopb
return
delay swapf PORTB,0
andlw 0x0f
movwf dly1
delay1 clrf dly2
delay2 nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
decfsz dly2,1
goto delay2
decfsz dly1,1
goto delay1
return
end
ASM kodu sonu.
Hiç yorum yok:
Yorum Gönder