View Single Post
  #1 (permalink)  
Old December 27th, 2003, 03:27 PM
tps tps is offline
Registered User
 
Join Date: Dec 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default NEED HELP FOR THIS SOFTWARE

DEAR THIS SOFTWARE IS FOR PC BASED FREQUENCY MEASURMENT WRITTEN IN TURBO "C" .HELP IT HAS ONLY ONE ERROR

#include
#include
#include
#define MOD 16 /* define counter mod used */
#define LPT 0x379/* LPT1 input port address */
void interrupt(*old_clock)();
void interrupt new_clock();
static int t;
void main()
{ /* tick = Time for which LPT will be read */
float div,mul,tick=54800.0; /* tick is in micro sec. */
double fq,tm,pri;
char data[50000],c;
int count,ls,ps,k,j,N,st;
unsigned i;
old_clock=getvect(0x08);///* capturing time vector */
setvect(0x08,new_clock); /* assigning new time time vector */
do
{ i=0; t=0; clrscr();
gotoxy(25,1); printf("FREQUENCY MEASUREMENT");
gotoxy(23,17); printf("Press any key to pause.....");
while(!kbhit()) /* reading LPT between two time interrupts */
{ /* use "int(LPT)" if using MS product */
while(t2&&t2;k-)
/* analyzing each bit of read data */
{ N=1;
for(j=0;j0&&st<4) count++;
if(st==3)break;/* wave found */
ls=ps;
}
if(st==3) /* calculate frequency of the wave */
{mul=1;for(j=3;jprintf("%d %f %d ",k,mul,count);
tm=((count*div)/mul); fq=1/tm; pri=(100.0/count);
gotoxy(20,7); printf("Frequency = %0.3lf Kilo Hz ", fq*1000);
gotoxy(20,10); printf("Time = %0.3lf micro sec ", tm);
gotoxy(15,23); printf("Precision = %0.5lf percent of main frequency",pri);
gotoxy(15,24); printf("Samples taken in %0.2f ms = %d ", tick/1000,i);
break;
}
if(st<3 && k==3)/* no complete wave was present */
{ gotoxy(24,7); printf("Error in Reading...!");
}
}} t=0; i=0;
}

getch(); gotoxy(13,21);
printf(" Press E Esc for Exit any key other to continue");
c=getch();
}
while (c!=27&&c!='e'&&c!='E');
setvect(0x08,old_clock); /* assigning original time interrupt */
}
void interrupt new_clock() /* new time interrupt service */
{ t++; (*old_clock)();}






TPS PROJECTS