Switch to full style
PIC Assembly Articles
Post a reply

Motor DC Speed Control by switching ON and OFF Assembly

Sun May 19, 2013 11:14 pm

Motor DC Speed Control by switching ON and OFF for short time
Code:

TITLE 
"MoTOR SPEED CONTROL"
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 macrc
bsf STATUS
,RP0
bsf STATUS
,RP1
endm

OFF EQU 0
;MOTOR oFF
DELAY_TIME EQU 0x20
;
ORG 0
NOP 
GOTO START
; MAIN ROUTINE

 
ORG 0x20
START CALL INITP 
;INITIALISE PoRT
MOVLW 1 
;SET MOTOR CW
MOVWF PORTE 
;AND OUTPUT
MOVLW 0 
;SET MOToR CW
MOVWF PORTA 
;AND OUTPUT
CALL START_DELAY 
;WAIT
AGAIN MOVLW 0FF 
;SET MOToR oFF
MOVWF PORTE 
;AND oUTPUT
MOVWF PORTA
CALL OFF_DELAY 
;WAIT
MOVLW 1 
;SET MOToR CW
MOVWF PORTE 
;AND OUTPUT
MOVLW 0 
;SET MOToR cW
MOVWF PORTA 
;AND oUTPUT
CALL ON_DELAY 
;WAIT
GOTO AGAIN 
;DO FOR EvER

;*******


;
 ON DELAy
ON_DELAY
MOVLW 0x80 
;SET DELAy TIME
MOVWF DELAY_TIME
WAIT1 INCFSZ DELAY_TIME 
;OoUNT DoWN
GOTO WAIT1
RETURN

;
 OFF DELAY ROUTIN
OFF_DELAY
MOVLW 0x8O 
;5ET DELAY TIME
MOVWF DELAY_TIME
WAIT2 INCFSZ DELAY_TIME 
;COUNT DOWN
GOTO WAIT2
RETURN

;
 START DELAY ROUTIN
START_DELAY
MOVLW 0x80 
;SET DELAy TIME
MOVWF DELAY_TIME
WAIT3 INCFSZ DELAY_TIME 
;CoUNT DoWN
GOTO WAIT3
RETURN

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




Post a reply
  Related Posts  to : Motor DC Speed Control by switching ON and OFF Assembly
 Infra Read Sensor to Control DC motor Assembly     -  
 Controlling the DC motor , Motor rotate clockwise Assembly     -  
 Control scroll speed using JQuery     -  
 Hide, show and toggle effects with speed control     -  
 TEMPERATURE AND HEAT CONTROL Assembly     -  
 Control Directives usage PIC assembly     -  
 Speed Painting     -  
 calculate speed of a car in javaCV     -  
 Worth switching to Cat 6 cabling?     -  
 Slide automatically-specific speed to a determined position     -