<HELP> microsecond timing resolution using C. 
Author Message
 <HELP> microsecond timing resolution using C.

Hi all,

I need some urgent help.

I am trying to use a PC's internal clock as a timer so that I can write
data to a RAM disk at, say, every 100 machine clock cycles. Also this has
to be accurate as I have to collect data for extended period of time (the
size of RAM disk is ignored at the moment) - accumulative error would be
very large if the timing is not good. Other word is that I need
microsecond resolution timing.

Does anyone know how this is done? With accuracy? I cannot afford to have
too much overhead in the code, as it will slow everything down.

I am programming using Borland C++ 3.1. The application I am writing is
for DOS only. My machine is a DX266.

Please help if u can. Any info regarding to how to get this started will
be greatly appreciated.

Many thanx,
Charles So



Thu, 06 Mar 1997 10:36:19 GMT  
 <HELP> microsecond timing resolution using C.

Quote:

> I am trying to use a PC's internal clock as a timer so that I can write
> data to a RAM disk at, say, every 100 machine clock cycles. Also this has
> to be accurate as I have to collect data for extended period of time (the
> size of RAM disk is ignored at the moment) - accumulative error would be
> very large if the timing is not good. Other word is that I need
> microsecond resolution timing.

> Does anyone know how this is done? With accuracy? I cannot afford to have
> too much overhead in the code, as it will slow everything down.

Depending upon how your RAM-DISK is implemented you may well find that
it takes more than 100 machine cycles to perform the write in which case
you'll be unable to achieve your objective.  The overhead of the mode
switching from real to protect and back alone will account for a fair
amount of that time :-(

Quote:
> I am programming using Borland C++ 3.1. The application I am writing is
> for DOS only. My machine is a DX266.

I doubt this hardware/software combination is up to the task.

+---------------------------------------------------------------+

| P.O. Box 24-394        |  QUICS:  basimpson                   |
| Royal Oak              |  voice:  +64 9 4202554               |
| Auckland               | mobile:  +64 2 5981133 (+vmail)      |
| New Zealand            |    fax:  +64 9 4202762               |
+---------------------------------------------------------------+



Thu, 06 Mar 1997 13:55:03 GMT  
 <HELP> microsecond timing resolution using C.

Quote:

>Hi all,

>I need some urgent help.

>I am trying to use a PC's internal clock as a timer so that I can write
>data to a RAM disk at, say, every 100 machine clock cycles. Also this has
>to be accurate as I have to collect data for extended period of time (the
>size of RAM disk is ignored at the moment) - accumulative error would be
>very large if the timing is not good. Other word is that I need
>microsecond resolution timing.

 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

It will be a *very* hard to do something with a precision better
than 1E-3 - 1E-4 sec.

Quote:

>Does anyone know how this is done? With accuracy? I cannot afford to have
>too much overhead in the code, as it will slow everything down.

>I am programming using Borland C++ 3.1. The application I am writing is
>for DOS only. My machine is a DX266.

>Please help if u can. Any info regarding to how to get this started will
>be greatly appreciated.

Best regards, Jozsef

--

Freie Universitaet Berlin
Institut fuer Organische Chemie       Tel:   +49.30.838-2677, 838-5363
Takustr. 3, D-14195 Berlin, Germany   Fax:   +49.30.838-5163, 838-4248



Fri, 07 Mar 1997 05:25:58 GMT  
 <HELP> microsecond timing resolution using C.

Quote:

> Hi all,

> I need some urgent help.

> I am trying to use a PC's internal clock as a timer so that I can write
> data to a RAM disk at, say, every 100 machine clock cycles. Also this has
> to be accurate as I have to collect data for extended period of time (the
> size of RAM disk is ignored at the moment) - accumulative error would be
> very large if the timing is not good. Other word is that I need
> microsecond resolution timing.

Charles, my reply bounced so I'm responding on the newsgroup.

If I understand you, you want to sample some information from the
real world, at regular intervals, and write this information to
a RAM disk?

This may well be possible, depending on how quickly you need to
sample the data.  Sampling periods of 50us or faster should be
possible on a DX2/66.  The approach I suggest is to speed up the
timer tick interrupt, and have your tick handler read the data
from the real world, and store it in a circular buffer (queue)
in main RAM.  A mainline process would then take the data from
the queue, and write it to the RAM disk.

There are several possible problems with this, so if you could
email me with more details of exactly what you want to do, e.g.
is it a stand-alone machine doing this one task, will you have
EMM386 installed on it (presumably yes, if you have a RAM disk),
and most importantly, how quickly you need to sample the data,
I will try to help.

BTW I am working on a PC Timing FAQ / Application Note that will
cover this, among other subjects, but it will be a week at least
before this is ready.

Kris
--

"Destroy 99% of known household pests with pre-sliced, rustproof, easy-
to-handle, low-calorie Simpson's individual Emperor Stringettes ..."



Fri, 07 Mar 1997 18:34:57 GMT  
 <HELP> microsecond timing resolution using C.


Quote:
> I am trying to use a PC's internal clock as a timer so that I can
> write data to a RAM disk at, say, every 100 machine clock cycles.

a) it will take longer than that to do a disk write, even to a
   RAM disk.  

b) lots of things including interrupt routines disable interrupts
   for longer than that.

c) you won't get that kind of resolution from the system clock

--

THE TIME                  IS WHEN YOU'RE
       TO START                        OFFERED A SUBSTITUTE
              A REAL DISPUTE                              Burma Shave



Thu, 06 Mar 1997 19:21:49 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. <<<<<<<Parsing help, please>>>>>>>>

2. File Format conversion, ascii freeform -->.csv <-->.wk1<-->dbf<-->?HELP

3. <><><>HELP<><><> PCMCIA Motorola Montana 33.6

4. <<<>>>Need C code advice with functions and sorting.<<<>>>

5. >>>Windows Service<<<

6. >>I need help!<<(duh)

7. <<ndbm.h>> - please help

8. help splicing <time.h>, _strdate();

9. Help with <time.h> (GCC)

10. <17103037@kreusa.cs.tu-berlin.de>

 

 
Powered by phpBB® Forum Software