RS232 Simulation?
Thu Jan 17 2008, 12:00 pm
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
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
Fri Jan 18 2008, 06:53 am
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
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, 07:35 pm
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.
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, 04:59 pm
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.
Fri Mar 21 2008, 01:59 am
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..
Powered by e107 Forum System