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.

Time Interval measurement from C

Status
Not open for further replies.

Ramesh Maharjan

Newbie level 1
Newbie level 1
Joined
Mar 7, 2006
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,288
hardarware level time interval measurement by interfacing
with parallel port without external timer and oscillator
 

This is unclear, try to explain more!
 

Dear Ramesh Maharjan,

Genraly U can Mesure time interval by Parallel Port But the smallest measurable Unit will depend on Speed of PC and U will Use all Resource of PC just for time mesurement.

To do that (mesure time by PC w\o external timer) frist CONVERT the time interval to electrical signal +5V and 0V say U express the begineng of time interval by fall edge and end by rise edge.
second input this signal on any data pin of LPT and scan falling edge then start count up tp detect falling edg.

But U'r PC can not do any other thing During Mesurment.

U can use external timer or Interrupt of ISA Bus to do this.
 

hi
u can implement a software clock program using c and u can use to evaluate real time by the cpu. And the easiest way is to write a program using delay statements and calculate the time
 

you should prepared dos based program for this
you should boot your computer in dos and launch that program
this reduces the error in measurement

here is code
/* Project To mesure the velocity of the moving vehicle */
/* Uses two status port of parallel pin no. 10 and 11 */
/* For pinouts Reference http://www.ctips.com/spp.html */
/* Base address for parallel port is 0x378 in hex */
/* Base address for parallel input port is 0x379 in hex */

# include<stdio.h>

/* conio.h is needed for the clrscr() and gotoxy() */
#include<conio.h>

/* dos.h is needed for the inportb() and delay()*/
#include<dos.h>
#define PORT 0x379 /* Assign the address of parallel port to PORT */
#define MAX_COUNT 3000


void main()
{
/* Defines the count variable to store the counted time interval */
unsigned long count;

/* Defines the variable for the sensor data and the input port address */
int SENSOR_1, SENSOR_2, data;

/* Assigns the input port address to variable data */

data= inportb(PORT+1);

/* Assigns the Status of the sensor -1 to variable SENSOR_1 */
SENSOR_1=(data & 0x80)/0x80;
/* data&0x80 masks the binary value availabe in data with 0x80 and division by 0x80 returns the status of the Pin 11 */

/* Assigns the Status of the sensor -2 to variable SENSOR_2 */
SENSOR_2=(data & 0x40)/0x40;

while(!kbhit()) /* loop continues until any key is pressed */
{
while (!(SENSOR_1&SENSOR_2)) /* Scans whether both port data is one or not */
{ ;
}
while (SENSOR_1) /* checks whether sensor-1 data changed to zero or not */
{;
}
for(count=0; ;count++) /* Counts the time interval with 1ms Precision */
{
delay(1);

if(SENSOR_2!=1&&count==MAX_COUNT) /* Checks whether sensor-2 data has changed to zero or not and stops count porcess */
break;

}
clrscr();
gotoxy(10,20);
printf("Velocity= %.3ul m/s",1000/count);
}
}

/* End of the program to compute velocity of moving vehicle */
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top