Accuracy of rt_get_time_ns()?
John F. Wesseling
jwesseling at unav.es
Fri Aug 4 18:21:49 CEST 2006
Thank you Paolo and Calin,
I have gotten it working now.
I could calibrate for a better accuracy with
calibrate -c, but even then, rt_get_time_ns()
seemed to have a precise and repeatable
inaccuracy of ~1:10E4; I do have confidence in my
measurement devices. To the best of my
knowledge, I am not using power saving features or CPU frequency scaling.
Perhaps I am doing something else wrong, but, no
matter, the "drift" seems to have been fixed by
adjusting - by hand - the rtai_cpufreq_arg that I
pass to the hal module. (I switched to RTAI 3.2
with linux kernel 2.6.10 because the calibration
tests weren't as easy to use with RTAI 3.1 - for a novice, at least).
This fix seems to be stable, accurate, and
precise down to at most 100 microseconds over 100
seconds, which is what I need.
>John F. Wesseling writes:
>>What is the timing accuracy of rt_get_time_ns() supposed to be?
>>Also, what is the preferred way to keep track of timing?
>>In my hands - details below - the timer is losing 1 ms every 3 s (1:3000).
>>I only need 100 microsecond precision, but I do need much better accuracy,
>>i.e. something like 100 microseconds/100 s (1:1E6).
>>Details: kernel: 22.214.171.124 patched with rtai 3.1 patch hal7-126.96.36.199.patch
>> processor: 333MHz Pentium 2
>> lxrt (I think)
>> one shot mode (I think)
>>Apologies if this question is obvious: I am new to Linux and RTAI.
>In oneshot rt_get_time_ns gives the CPU time
>stamp in nanos. The calibration is done against
>the 8254 freq (1182180 Hz?). On my PIII if I
>calibrate with the CPU freq in the range of 10
>nanos uncertainty I can see that the default
>Linux calibration is in error by 2.5/10000,
>which is roughly what you get too. So, if no
>other check source is implied in your
>verification, you should calibrate for a better
>ratio using the RTAI calibration tool, letting
>it run till only the very last figure is
>changing by a few units. It can take a few minutes.
John F. Wesseling, Ph.D.
Departamento de Neurociencias
Centro de Investigación Médica Aplicada (CIMA)
Pio XII, 55
Phone +34 948 19 47 00 ext. 2005
(if you don't speak Spanish, when the recording comes on,
just enter the extension and wait)
Fax +34 948 19 47 15
More information about the Rtai