Thayas
Newbie level 6
Hey all,
I got a code to rotate 6 wire unipolar stepper motor from the internet..
It works fine in PROTEUS Simulator(All four ( RBO,RB1,RB2,RB3) pins gives output)
When i tried it in bread board.Only two pins(RB0,RB1) give the out put.I did not get any signals from RB2,RB3.
coding
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
;RETURN
PUSH BTFSC PORTA,0
CALL STOP
BTFSC PORTA,1
CALL stepcw
CALL stepccw
RETURN
;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
call delay
CALL delay
; Clear the output
CALL PUSH
return
STOP CLRF PORTB
GOTO PUSH
;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
call delay
CALL delay
goto PUSH
; 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
Plc any one help me soon..........
I got a code to rotate 6 wire unipolar stepper motor from the internet..
It works fine in PROTEUS Simulator(All four ( RBO,RB1,RB2,RB3) pins gives output)
When i tried it in bread board.Only two pins(RB0,RB1) give the out put.I did not get any signals from RB2,RB3.
coding
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
;RETURN
PUSH BTFSC PORTA,0
CALL STOP
BTFSC PORTA,1
CALL stepcw
CALL stepccw
RETURN
;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
call delay
CALL delay
; Clear the output
CALL PUSH
return
STOP CLRF PORTB
GOTO PUSH
;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
call delay
CALL delay
goto PUSH
; 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
Plc any one help me soon..........