PDA

توجه ! این یک نسخه آرشیو شده میباشد و در این حالت شما عکسی را مشاهده نمیکنید برای مشاهده کامل متن و عکسها بر روی لینک مقابل کلیک کنید : کنترل دور موتور با پورت پیرینتر



hadi-e
08-03-2009, 20:45
سلام دوستان ای برنامه اش است اولی بیسیک و دومی c
$regfile = "m8def.dat"
$crystal = 1000000
Config Timer0 = Timer , Prescale = 256
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Config Int0 = Rising
Config Portb = Output
Config Pind.0 = Input
Enable Interrupts
Enable Ovf0
On Ovf0 T0_rut
Enable Int0
On Int0 Ex0_rut
Dim A As Byte
Dim Half As Bit
Dim Ref As Word
Dim Place As Word
Dim S As Integer
A = &B00110011
Half = 1
Start Adc
Start Timer0
Ref = Getadc(0)
Place = Ref
'***************
Do
S = Ref - Place
If S > 7 Then
Rotate A , Left
Place = Place + 5
Portb = A
Waitms 3
End If
S = Place - Ref
If S > 7 Then
Rotate A , Right
Place = Place - 5
Portb = A
Waitms 3
End If
Loop
End
'***************
T0_rut:
Ref = Getadc(0)
Return
'***************
Ex0_rut:
If Pind.0 = 1 Then
Rotate A , Left
End If
If Pind.0 = 0 Then
Rotate A , Right
End If
Portb = A
Return و



به زبان
c
#include <stdio>
#include <dos>
#include <conio>
#define dataport 0X0378
#define controlport 0X037A
main()
{
int i,t,s,n;
char ch,d;
outp(controlport,0X00);
while(ch!=27)
{
t=0;
clrscr();
printf("enter step number: ");
scanf("%d",&n);
printf("\nenter speed(step/second): ");
scanf("%d",&s);
printf("\nenter direct (L or R): ");
d=getch();
printf("\n---------------program process-------------");
if(d=='r')
{
t=1;
outp(dataport,0);
}
if(d=='l')
{
t=1;
outp(dataport,1);
}
for(i=1;i<=n;i++)
{
if(t==1)
{
outp(controlport,1);
delay(1);
outp(controlport,0);
gotoxy(10,8);
printf("\n\tstep number: %d",i);
delay(s);
}
}
outp(controlport,0x00);
printf("\n press any key to continiu (enter Esc to exit)");
ch=getch();
}
return 0;
}

البته ببینم مشتاق مدار ان کسی است ان را می کذارم اگر شما نظر دهید
من ان را در پروتئس میکشم ومیذارم توی سایت اگه نظر ندید نه