Switch to full style
PIC Assembly Articles
Post a reply

Controlling the DC motor , Motor rotate clockwise Assembly

Sun May 19, 2013 10:27 pm

Motor is made to rotate clockwise for a time dictated by delay time
Code:
list p=16f877
include <p16f877.inc>
BANK0 macro
bcf STATUS
,RP0
bcf STATUS
,RP1
endm
BANK1 macro
bsf STATUS
,RP0
bcf STATUS
,RP1
endm

BANK2 macro
bcf STATUS
RP0
bsf STATUS
RP1
endm

BANK3 macro
bsf STATUS
RP0
bsf STATUS
RP1
endm

OFF EQU 0 
;MOTOR OFF
DELAY_VHI EQU 0x20
DELAY_HI EQU 0x21
DELAY_LO EQU 0x22
; ****
ORG 0
NOP
GOTO START

MAIN ROUTINE
 
ORG 0x20
START CALL INITP 
;INITIALISE PORT
AGAIN MOVLW 1 
;SET MOTOR CW
MOVWF PORTE 
;AND OUTPUT
MOVLW 0 
;SET MOTOR CW
MOVWF PORTA 
;AND OUTPUT
CALL DELAY 
;WAIT

MOVLW 0FF 
;SET MOTOR OFF
MOVWF PORTE 
;AND OUTPUT
MOVWF PORTA
CALL DELAY 
;WAIT

MOVLW 0 
;SET MOTOR ACW
MOVWF PORTE 
;AND oUTPUT
MOVLW 0x20 
;SET MOTOR ACW
MOVWF PORTA 
;AND oUTPUT
CALL DELAY 
;WAIT
MOVLW OFF 
;5ET MOTOR OFF
MOVWF PORTA 
;AND OUTPUT
MOVWF PORTE
CALL DELAY 
;WAIT
GOTO AGAIN 
;DO FOR EVER

SUBROUTINES

;DELAY
DELAY
MOVLW 0X01
MOVWF DELAY
.LO
MOVLW 0X80
MOVWF DELAY_HI
MOVLW 0XE0
MOVWF DELAY_VHI

BIG
OUTER
INNER

INCFSZ DELAY_LO
,1
GOTO INNER
INCFSZ DELAY_HI
,1
GOTO OUTER
INCFSZ DELAY_VHI
GOTO INNER
RETURN
PORT INITIALISATION


INITP BANK1 
;SET To BANK 1
MOVLW 06 
;MAKE PORT A DIGITAL
MOVWF ADCON1
BCF PORTA
,;MAKE BIT 5 OUTPUT
CLRF TRISE 
;SET PoRT E To otTPUT
BANK0 
;BACK To BANK 0
RETURN
END





Post a reply
  Related Posts  to : Controlling the DC motor , Motor rotate clockwise Assembly
 Motor DC Speed Control by switching ON and OFF Assembly     -  
 Infra Read Sensor to Control DC motor Assembly     -  
 Controlling Web Application Behavior with web.xml     -  
 Transform Rotate Filter     -  
 Bit operations-set-get-xor-rotate on bits arrays     -  
 Rotate Image with specific angle     -  
 rotate sphere in a circle with light     -  
 PIC Assembly For Loop Example     -  
 multiply two numbers in PIC assembly     -  
 macro usage PIC assembly     -