Discussion in "Project Help" started by    dez    Jan 7, 2008.
Wed Jan 16 2008, 08:25 PM
#41
please just write the pseudo code,
what should i do to increase speed?

Thu Jan 17 2008, 06:30 AM
#42
actually speed of DC motor changes when you change the voltage of motor... and in digital world this is done with the help of Pulse width modulation.
So i think you should see this for learning about PWM.
I have no idea whether x86 processors have timers or not.. if not then it will be difficult to generate PWM, or you have to make use of some external thing to generate PWM.
Please go through this to read about PWM.
www.8051projects.net/forum-t1720-post.html
Tags pulse width modulationPWM
Fri Jan 18 2008, 01:23 AM
#43
Ofcourse they have, In asm there is a subroutine named waitf and all my problem was that. In order to arrange pwms, we should use it. But i didnt know how to use it, anywayi submit my last work as written below...
It may have problems:S

			
; cursor function
cursor	macro	r,c
		
			mov	bh,00
			mov ah,02
			mov	dh,r
			mov dl,c
			int 10h
		
		endm


; display function
display macro	str
			mov ah,09h
			mov dx,offset str
			int 21h
endm 

waitf   macro   ; al times
            local waitloops
            shl al,2
            waitloops:
                 dec al
                 jnz waitloops
            endm

.model small
.stack 64
.data

	;Seven Segment Table
	
	zero		db	01011011b;		-   |	 -	-	| |	|-	|-	-|	|-|	|-|
	one			db	00000110b;		   | |	|    _|	_|   -  |-  |_	-|	 -	 -
	two			db	01011011b;		-	|   |_	_|	  |	 _| |_|	 |	|_|	 _|
	three		db	01001111b;
	four		db	01100110b
	five		db	01101101b
	six			db	01111101b
	seven		db	00000111b
	eight		db	01111111b
	nine		db	01101111b 
	
	direction   db  'n'
	
	speedCtr	db	?
	delayCtr    db  ?
	
	l1			db	'						Welcome									','$'
	l2			db  '			Press f to rotate clockwise							','$'
	l3			db  '		Press r to rotate counter-clockwise						','$'
	l4			db  '	You may adjust the speed by 'u' for up and 'd'for down		','$'
	l5			db  '	  You can see the motor speed on the 7-seg					','$'
	l6			db  '			Press q to quit the program							','$'
	
	
	
.code
		
		mov dx,378h				;parallel port initialization
		mov al,00h				;for writing data
		out dx,al
		; D7 is for forward D6 is for backward D5 is for enabling of dc motor with L293d
		
	main:
		mov	ax,@data
		mov	ds,ax
	
		;clr
	
		cursor 2,6
		display l1
		cursor 4,6
		display l2
		cursor 6,6
		display l3
		cursor 8,6
		display l4
		cursor 10,6
		display l5
		cursor 12,6
		display l6
	
		cursor 16,6
	
		mov	speedCtr,0
		mov delayCtr,10
		
		
		 
	key_check:
	    mov ah,01
	    int 16h
	    mov ah,00
	    int 16h
	    		
		cmp al,'r'
		je	r_pressed
		
		cmp al,'f'
		je f_pressed
		
		cmp al,'u'
		je up_pressed
		
		cmp al,'d'
		je down_pressed
		
		cmp al,'q'
		je	quit
		jmp key_check 

    here:      
            
            mov dl,speedCtr
            cmp speedCtr,0
            je zerow
            cmp speedCtr,1
            je onew
            cmp speedCtr,2
            je twow
            cmp speedCtr,3
            je threew
            cmp speedCtr,4
            je fourw
            cmp speedCtr,5
            je fivew
            cmp speedCtr,6
            je sixw
            cmp speedCtr,7
            je sevenw
            cmp speedCtr,8
            je eightw
            cmp speedCtr,9
            je ninew       
            jmp endt
            
            zerow:
            mov dx,378h
            mov al,00000000b
            out dx,al
            jmp endt
            
            onew:
            mov dx,378h
            mov al,00010000b
            out dx,al
            jmp endt
            
            twow:
            mov dx,378h
            mov al,00100000b
            out dx,al
            jmp endt
            
            threew:
            mov dx,378h
            mov al,00110000b
            out dx,al            
            jmp endt
            
            fourw:
            mov dx,378h
            mov al,01000000b
            out dx,al
            jmp endt
            
            fivew:
            mov dx,378h
            mov al,01010000b
            out dx,al
            jmp endt
            
            sixw:
            mov dx,378h
            mov al,01100000b
            out dx,al
            jmp endt
            
            sevenw:
            mov dx,378h
            mov al,01110000b
            out dx,al
            jmp endt
            
            eightw:
            mov dx,378h
            mov al,10000000b
            out dx,al
            jmp endt
                        
            ninew:
            mov dx,378h
            mov al,00000000b
            out dx,al
            
            endt:
            jmp key_check

		
	r_pressed:
	    cmp direction,'n'
	    jne check_r
	    mov direction,'r'
		;delay 2;					wait for 2 seconds and then start rotating in reverse direction
		;reverse e 1 gonderme fonksiyonu
		rgoes:
		mov al,127
		waitf
		mov al,00000001b;			00000001B for reverse direction
		mov dx,378h
		out dx,al
		jmp here
		jmp	key_check

	
	f_pressed:
	    cmp direction,'n'
	    jne check_r 
	    mov direction,'f'

	    
		fgoes:
	    mov al,100
	    waitf

		mov al,00000010b;			00000010B for forward direction
		mov dx,378h
		out dx,al

		jmp here
		jmp	key_check
		
	check_f:
	    cmp direction,'f'
	    je fgoes
	    waitf 1000;to delay when changing direction
	    jne rgoes
	 check_r:
	    cmp direction,'r'
	    je rgoes
	    jne fgoes	
		
	stop:
	    mov al,00000000b
	    mov dx,378h
	    out dx,al
	    mov al,100
	    jmp here
	    jmp key_check

	
	down_pressed:
	    dec speedCtr
	    inc delayCtr
		cmp speedCtr,0
		je stop
		cmp direction,'f'
		je goingforward
		cmp direction,'r'
		dec speedCtr
		inc delayCtr
		je goingbackward
		
		
	goingforward: 		
	        mov al,00000010b;
	        mov dx,0378h
	        out dx,al 
	        mov al,speedCtr
	        waitf
	        mov al,00000000b;
	        out dx,al
	        mov al,delayCtr
	        waitf
	        jmp key_check
	        jmp goingforward

		
		;pwm signallerini azaltan fonksiyon
		;7segment e speedCtr bastiran fonksiyon
		jmp here
		jmp	key_check
		
	goingbackward:
	        mov al,00000001b ;PIN NUMARASI
	        mov dx,0378h
	        out dx,al
	        mov al,speedCtr
	        waitf
	        mov al,00000000b;
	        out dx,al
	        mov al,delayCtr
	        waitf
	        jmp key_check
	        jmp goingbackward

		
		;pwm signallerini azaltan fonksiyon
		;7segment e speedCtr bastiran fonksiyon
		jmp here
		jmp	key_check

	
	up_pressed:
		cmp direction,'f'
		je increase_forward
		
		cmp direction,'b'
		je increase_backward
		
		jmp key_check
		
		increase_forward:
		    inc speedCtr
		    cmp speedCtr,9
		    je key_check
		    dec delayCtr
		    
	    
		    mov al,00000010b
		    mov dx,0378h
		    out dx,al
		    mov al,speedCtr
		    waitf
		    mov al,00000000b
		    out dx,al
		    mov al,delayCtr
		    waitf

		 jmp here
		 jmp key_check
		    
		increase_backward:
		    inc speedCtr
		    cmp speedCtr,9
		    je key_check 
		    dec delayCtr
		    
		    mov al,00000001b 
		    mov dx,0378h
		    out dx,al
		    mov al,speedCtr
		    waitf
		    mov al,00000000b 
		    out dx,al
		    mov al,delayCtr
		    waitf

		jmp here
		jmp	key_check
		
    		
	quit:
		mov ah,4ch
		int 21h
		end	main
		

   
		

	    
	    
	    
	    
Fri Jan 18 2008, 02:05 PM
#44
Actually in PWM, timers should use interrupts.. wait routine will not work..
i hope you have read the concept of PWM. So all we need to do is change the width of high level. if width is 255 then speed will be full and if width is 0 then speed will be low/motor stops.

in the PWM code i gave you.. it works like this..
R7 contains the value of high level and ranges from 0 to 255 as i explained.
for pwm, i used a flag to indicate if high part of the square wave is done or not, coz the values loaded in the timer are different for both high and low level of square wave but the total value of high and low is 255.
So lets say if high is 50, i.e. R7 is loaded with 50 and low will be 255-50 = 205.
you can see in the code too.. during one part of PWM i am loading Timers with R7 and in other part of square wave i am loading 255-R7 in timer.
so total 255 will remain constant only i am changing the value of R7 to control the width. you can possibly make your program to work as i explained.
Thu Mar 20 2008, 11:29 AM
#45
I want to convert L293D component to library and model file in proteus. But I cant make proper MDF file. Simulation part is starting but motors are not working.
Thu Mar 20 2008, 08:29 PM
#46
to create models you need VSM SDK. All you need to do is use APIs provided... i never tried making one.. but now you have encouraged me to try it out..

Get Social

Information

Powered by e107 Forum System

Conversation

Sun Dec 08 2019, 04:50 PM
Marti Ogrady
Take advantage of this great service today:
Thu Nov 21 2019, 12:30 PM
raj2555
how to interface 8051 microcontroller with NRF24L01+ module
ExperimenterUK
Sat Oct 12 2019, 10:23 PM
Log in.. then post your code in the 8051 forum
Sat Oct 12 2019, 10:18 AM
Bhadra Sajikumar
i am doing a countdown timer with 8051 for my project, unfortunately our professor had to take a leave of absence before he could teach us most of it.. can someone explain the .asm code of it for me?
Mon Sep 23 2019, 07:37 AM
Nathaniel
I am doing a project for my schools wireless security system with cameras,sensors and spot lights using 8051 micro controller, could you help me out with the design and its source code.
Wed Sep 18 2019, 08:48 PM
Caryn Kover
Thank you for your time,
ExperimenterUK
Mon Aug 05 2019, 07:09 PM
@Ismail ..post in forum, give details
Mon Aug 05 2019, 04:33 PM
Ismail balghmi
Hello. Please I won't download
ExperimenterUK
Wed Jul 24 2019, 12:47 AM
@BUSTER123 Please post in the forum
Tue Jul 23 2019, 06:13 PM
BUSTER123
hello! newbie here. i am kind of a guy who hates using ready - made existing libraries, so this helped a lot as i was trying to control and write to a character lcd display. however, i can't figure out how to set the cursor position. for example, i want to set it to the 5th column in the first row, so position 5. so according to the table, i am sending 10000101 on the 8 data lines of the lcd (register select pulled low). the cursor does not move there however. and i cant move the cursor left or right too. is it something wrong that i am doing? thank you.

Downloads

Comments

nabiha_anaya
Sun Dec 08 2019, 09:16 AM
ananyagupta
Tue Dec 03 2019, 07:53 AM
wells
Mon Nov 25 2019, 08:25 PM
auwal
Tue Nov 19 2019, 03:13 PM
ANKITPATEL
Mon Nov 18 2019, 11:00 AM
Casmir
Wed Nov 13 2019, 06:25 AM
DeepakBGattani
Mon Nov 11 2019, 01:31 PM
Jeanbusatta
Sun Nov 10 2019, 04:42 AM

Online

Guests: 43, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 38108
Newest member: nabiha_anaya
Forum Activity
ilylily07 Avatar
Posted By ilylily07
Sun Dec 08 2019, 01:24 PM
Hi .im humbly ask for your advice as i wrongly pur...
nabiha_anaya Avatar
Posted By nabiha_anaya
Sun Dec 08 2019, 09:19 AM
My teacher assign me a project on "voice control h...
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Nov 29 2019, 04:24 AM
" Is it possible to interface a fingerprint scanne...
ilylily07 Avatar
Posted By ilylily07
Thu Nov 28 2019, 03:50 PM
You will not find any code for an 8051 as no one w...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Nov 26 2019, 05:44 PM
You will not find any code for an 8051 as no one w...
ilylily07 Avatar
Posted By ilylily07
Tue Nov 26 2019, 04:13 AM
I tracked down a OV7670 data sheet.The OV7670 puts...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Nov 26 2019, 12:08 AM
I tracked down a OV7670 data sheet.The OV7670 puts...
ilylily07 Avatar
Posted By ilylily07
Mon Nov 25 2019, 04:38 PM
The 8051 has too little memory to do anything us...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Nov 19 2019, 10:44 PM
The 8051 has too little memory to do anything us...
ilylily07 Avatar
Posted By ilylily07
Mon Nov 18 2019, 09:54 AM
0v7670 camera interfacing with stc 8051.using asse...