Switch to full style
PIC Assembly Articles
Post a reply

Infra Read Sensor to Control DC motor Assembly

Wed May 22, 2013 11:12 pm

Infra Read Sensor ( IR) to Control DC motor
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 ozF
DELAY_TIME EQU 0x20
DELAY_LO EQU 0x21
DELAY_HI EQU 0x22
DELAY_VHI EQU 0x23
; *******
ORG 0
NOP
GOTO START
; *****
;*** 
MAIN  ROUTINE
ORG 0x20


START CALL INITP 
;INIIIAIJSE PORT

AGAIN MOVLW 1 
;SET MoTOR CW
MOVWF PORTE 
; AND oUTPtT
MOVLW 0 
;SET MoToR CW
MOVWF PORTA 
;AND OUTPUT
ON1 BTFSS PORTA
,;TEST FoR IR BIT
GOTO ON1 
;IF NOT SET WAIT
ON2 BTFSC PORTA
,;TEST ZR BIT
GOTO 0N2 
;IF SET WAIT
MOVLW 0xFF 
;SET MOTOR OFF
MOVWF PORTE 
;AND oUTPtT
MOVWF PORTA
CALL OFF_DELAY 
;WAIT
GOTO AGAIN 
;DO FOR EVER

SUBROUTINES
oFF DELAY RoUTIN
OFF_DELAY
MOVLW 0XE0
MOVWF DELAY_LO
MOVLW 0XA1
MOLWF DELAY_HI
MOVLW 0xFF
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 OUTPUT
BANK0 
BACK TO BANK 0
RETURN
END




Post a reply
  Related Posts  to : Infra Read Sensor to Control DC motor Assembly
 Motor DC Speed Control by switching ON and OFF Assembly     -  
 Controlling the DC motor , Motor rotate clockwise Assembly     -  
 Control Directives usage PIC assembly     -  
 TEMPERATURE AND HEAT CONTROL Assembly     -  
 PIC Assembly For Loop Example     -  
 multiply two numbers in PIC assembly     -  
 macro usage PIC assembly     -  
 MULTIPLEXING Seven SEGMENT DECODER Assembly     -  
 playfair cipher assembly code     -  
 Elements of Assembly Language Instruction     -