中文字幕无码不卡一区二区三区_少妇被又大又粗又爽毛片久久黑人_91精品国产在热久久无毒不卡_久久久久久亚洲综合网站

技術(shù)熱線: 4007-888-234

專(zhuān)注差異化嵌入式產(chǎn)品解決方案 給智能產(chǎn)品定制注入靈魂給予生命

提供開(kāi)發(fā)工具、應(yīng)用測(cè)試 完善的開(kāi)發(fā)代碼案例庫(kù)分享

從全面的產(chǎn)品導(dǎo)入到強(qiáng)大技術(shù)支援服務(wù) 全程貼心伴隨服務(wù),創(chuàng)造無(wú)限潛能!

技術(shù)支持

用PIC控制步進(jìn)電機(jī)完整資料

更新時(shí)間: 2019-03-26

F84程序,

;********************************************************
;
;               Stepper Motor controller
;
;                                 Author : Seiichi Inoue
;********************************************************

        list            p=pic16f84a
        include         p16f84a.inc
        __config _hs_osc & _wdt_off & _pwrte_on & _cp_off
        errorlevel      -302    ;Eliminate bank warning

;****************  Label Definition  ********************
        cblock  h'0c'
mode                     

 ;Operation mode
                                ;0=stop 1=right 2=left
count1                          ;Wait counter
count2                          ;Wait counter(for 1msec)
        endc

rb0     equ     0               ;RB0 of PORTB
rb1     equ     1               ;RB1 of PORTB
rb2     equ     2               ;RB2 of PORTB
rb5     equ     5               ;RB5 of PORTB
rb7     equ     7               ;RB7 of PORTB

;****************  Program Start  ***********************
        org     0               ;Reset Vector
        goto    init
        org     4               ;Interrupt 

Vector
        clrf    intcon          ;Clear Interruption reg

;****************  Initial Process  *********************

init
        bsf     status,rp0      ;Change to Bank1
        clrf    trisa           ;Set PORTA all OUT
        movlw   b'00100111'     ;RB0,1,2.5=IN RB7=OUT
        movwf   trisb           ;Set PORTB
        movlw   b'10000000'     ;RBPU=1 Pull up not use
        movwf   option_reg      ;Set OPTION_REG
        bcf     status,rp0      ;Change to Bank0
        clrf    mode            ;Set mode = stop
        clrf    count1          ;Clear counter
        clrf    count2          ;Clear counter
        movlw   b'00000101'     ;Set PORTA initial value
        movwf   porta           ;Write PORTA
        bsf     portb,rb7       ;Set RB7 = 1
        btfsc   portb,rb5       ;RB5 = 0 ?
        goto    $-1             ;No. Wait

start
;*************  Check switch condition  *****************
        btfsc   portb,rb1       ;RB1(stop key) = ON ?

 goto    check1          ;No. Next
        clrf    mode            ;Yes. Set stop mode
        goto    drive           ;No. Jump to motor drive
check1
        btfsc   portb,rb2       ;RB2(right key) = ON ?
        goto    check2          ;No. Next
        movlw   d'1'            ;Yes. Set right mode
        movwf   mode            ;Save mode
        goto    drive           ;No. Jump to motor drive
check2
        btfsc   portb,rb0       ;RB0(left key) = ON ?
        goto    drive           ;No. Jump to motor drive
        movlw   d'2'            ;Yes. Set left mode
        movwf   mode            ;Save mode

;********************  Motor drive  *********************
drive
        movf    mode,w          ;Read mode

 bz      start           ;mode = stop
        bsf     portb,rb7       ;Set RB7 = 1
        btfsc   portb,rb5       ;RB5 = 0 ?
        goto    $-1             ;No. Wait
        movlw   d'5'            ;Set loop count(5msec)
        movwf   count1          ;Save loop count
loop    call    timer           ;Wait 1msec
        decfsz  count1,f        ;count - 1 = 0 ?
        goto    loop            ;No. Continue
        bcf     portb,rb7       ;Set RB7 = 0
        btfss   portb,rb5       ;RB5 = 1 ?
        goto    $-1             ;No. Wait
        movf    porta,w         ;Read PORTA
        sublw   b'000000101'    ;Check motor position
        bnz     drive2          ;Unmatch
        movf    mode,w          ;Read mode
        sublw   d'1'            ;Right ?
        bz      drive1          ;Yes. Right
        movlw   b'00001001'     ;No. Set Left data
        goto    drive_end       ;Jump to PORTA write
drive1

 movlw   b'00000110'     ;Set Right data
        goto    drive_end       ;Jump to PORTA write
;-------
drive2
        movf    porta,w         ;Read PORTA
        sublw   b'000000110'    ;Check motor position
        bnz     drive4          ;Unmatch
        movf    mode,w          ;Read mode
        sublw   d'1'            ;Right ?
        bz      drive3          ;Yes. Right
        movlw   b'00000101'     ;No. Set Left data
        goto    drive_end       ;Jump to PORTA write
drive3
        movlw   b'00001010'     ;Set Right data
        goto    drive_end       ;Jump to PORTA write
;-------
drive4
        movf    porta,w         ;Read PORTA
        sublw   b'000001010'    ;Check motor position
        bnz     drive6          ;Unmatch
        movf    mode,w          ;Read mode
        sublw   d'1'            ;Right ?

 bz      drive5          ;Yes. Right
        movlw   b'00000110'     ;No. Set Left data
        goto    drive_end       ;Jump to PORTA write
drive5
        movlw   b'00001001'     ;Set Right data
        goto    drive_end       ;Jump to PORTA write
;-------
drive6
        movf    porta,w         ;Read PORTA
        sublw   b'000001001'    ;Check motor position
        bnz     drive8          ;Unmatch
        movf    mode,w          ;Read mode
        sublw   d'1'            ;Right ?
        bz      drive7          ;Yes. Right
        movlw   b'00001010'     ;No. Set Left data
        goto    drive_end       ;Jump to PORTA write
drive7
        movlw   b'00000101'     ;Set Right data
        goto    drive_end       ;Jump to PORTA write

;-------
drive8
        movlw   b'00000101'     ;Compulsion setting

drive_end
        movwf   porta           ;Write PORTA
        goto    start           ;Jump to start

;*************  1msec Timer Subroutine  *****************
timer
        movlw   d'200'          ;Set loop count
        movwf   count2          ;Save loop count
tmlp    nop                     ;Time adjust
        nop                     ;Time adjust
        decfsz  count2,f        ;count - 1 = 0 ?
        goto    tmlp            ;No. Continue
        return                  ;Yes. Count end

;********************************************************
;             END of Stepper Motor controller
;********************************************************



404
返回首頁(yè) |  返回上一頁(yè)
治多县| 延寿县| 河西区| 兰溪市| 余姚市| 尚志市| 将乐县| 谢通门县| 东港市| 临西县| 二手房| 玛沁县| 吴堡县| 罗源县| 兴安盟| 永春县| 增城市| 惠安县| 凤城市| 年辖:市辖区| 镇雄县| 望都县| 耿马| 易门县| 宜城市| 鄱阳县| 宜昌市| 京山县| 肥乡县| 民权县| 鄯善县| 通江县| 象山县| 宜昌市| 大关县| 江口县| 福鼎市| 米脂县| 佛冈县| 丹东市| 延吉市|