Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

to maintain dc motor speed

Status
Not open for further replies.

imisendo_4036

Newbie level 2
Joined
Mar 26, 2008
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,289
hello frenz...
i actually do dc motor speed controller right now...to maintain speed even load change....project from internet
but the problem is when i run the project in simulator..
the result is not as expected...all LED are on...can't maintain the speed
can anyone suggest what should i do....plzzz

[/img]
Code:
;PROGRAM TO CONTROL DC MOTOR SPEED


;*****DECLARATION*****

	PROCESSOR 16F873
   	#include "p16F873.INC"
    __CONFIG _HS_OSC & _WDT_OFF & _PWRTE_ON & _LVP_OFF
	errorlevel -302

;*****DECLARE****

speed equ d'256'
change equ d'1'
led equ h'20'

;****PROGRAM START*****

	org 0
	goto main
	org 4
	goto int

;*****INITIALIZATION PROCESS******

main

;*****PORT****	
	bsf 03h,5
	movlw b'00000001'
	movwf 85h ;set port A bit 0 as input(AN0)
	clrf 86h ;port b as output
	clrf 87h ;port c as output
	bcf 03h,5

;****A/D CONVERTER*****

	movlw b'10000001'  
	movwf 1Fh ;adcon0
	bsf 03h,5
	movlw b'00001110' 
	movwf 9Fh ;adcon1
	bcf 03h,5
	
;*****PWM*****

	clrf 11h ;tmr2
	movlw d'127'
	movwf 15h ;ccpr1L
	bsf 03h,5
	movlw d'255'
	movwf 92h ;pr2
	bcf 03h,5
	movlw b'00000110'
	movwf 12h ;t2con
	movlw b'00001100'
	movwf 17h ;ccp1con

;*****COMPARE MODE*****

	clrf 0Fh ;tmr1h
	clrf 0Eh ;tmr1L
	movlw h'61'
	movwf 1Ch;ccpr2h
	movlw h'A8'
	movwf 1Bh;ccpr2L
	movlw b'00000001'
	movwf 10h;t1con
	movlw b'00001011'
	movwf 1Dh;ccp2con

;****INTERRUPTION CONTROL******

	bsf 03h,5
	movlw b'00000001';ccp2ie enable
	movwf 8Dh;pie2
	bcf 03h,5
	movlw b'11000000';gie on & peie on
	movwf 0Bh;intcon

wait
	goto $

;*****INTERRUPTION PROCESS*****

int
	clrf 0Dh;pir2
	
check

	btfsc 1Fh,2;cek A/D siap x?
	goto check
	movlw 1Eh;adresh, A/D result high register
	sublw speed
	btfsc 03h,0;bit test,skip next instruction if clear
	goto check1

;****LOW SPEED*****
	movlw 15h;ccpr1L
	addlw change
	btfss 03h,0
	movwf 15h;ccpr1L
	goto led_cont

check1
	btfsc 03h,2
	goto led_cont

;****FAST SPEED******
	movlw change
	subwf 15h,1;ccpr1L-1
	btfsc 03h,0
	goto led_cont
	clrf 15h

;******LED CONTROL******

led_cont

	comf 15h,0
	movwf led
	movlw b'00010000
	subwf led,0
	btfsc 03h,0
	goto led1
	movlw b'00000000'
	movwf 06h
	goto int_end

led1
	movlw b'00100000'
	subwf led,0
	btfsc 03h,0
	goto led2 
	movlw b'00000001'
	movwf 06h
	goto int_end

led2
	movlw b'01000000'
	subwf led,0
	btfsc 03h,0
	goto led3 
	movlw b'00000011'
	movwf 06h
	goto int_end

led3
	movlw b'01100000'
	subwf led,0
	btfsc 03h,0
	goto led4 
	movlw b'00000111'
	movwf 06h
	goto int_end

led4
	movlw b'10000000'
	subwf led,0
	btfsc 03h,0
	goto led5 
	movlw b'00001111'
	movwf 06h
	goto int_end

led5
	movlw b'10100000'
	subwf led,0
	btfsc 03h,0
	goto led6 
	movlw b'00011111'
	movwf 06h
	goto int_end
	
led6
	movlw b'11000000'
	subwf led,0
	btfsc 03h,0
	goto led7 
	movlw b'00111111'
	movwf 06h
	goto int_end

led7
	movlw b'11100000'
	subwf led,0
	btfsc 03h,0
	goto led8 
	movlw b'01111111'
	movwf 06h
	goto int_end

led8
	movlw b'11111111'
	movwf 06h




;******END INTERRUPTION******
int_end
	
	retfie

;**********END OF DC MOTOTR SPEED CONTROLLER*******

	END

end
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top