dear dan
i enhanced your GetCharTest.m and polished GetChar.mex slightly. I
think that it's now self explanatory.
help getchartest now says this:
GetCharTest evaluates the accuracy of the timing information returned by
GetChar. GetChar returns two values: when.ticks and when.secs.
when.ticks is passed on directly from the Mac OS. when.secs is an
estimate, based on when.ticks, of what GetSecs would have returned.
There are three issues that limit the accuracy of the timing:
1. The time, in ticks, of the keypress returned by the Mac OS is
inaccurate, with errors of more than one tick. This may reflect
coarse quantization of time in the the hardware interface to the
keyboard. Different kinds of keyboard interface (built-in laptop
keyboard, ADB, USB) may have different quantizations.
2. A tick is an integer, with a unit of 1/60.15 s.
3. The value of when.secs necessarily inherits all the inaccuracies of
when.ticks, and has a further problem. If you know the rates of two
clocks, it's easy to convert times from one kind of time to the other.
We do that by estimating Tick0Secs, the value of GetSecs at the moment
when GetTicks was zero.
tick0Secs=GetSecs-GetTicks/60.15;
We can then convert any value of ticks to secs by the formula:
secs=ticks/60.15+tick0Secs;
However, it turns out that the Mac OS tick counter often misses ticks
when the computer is very busy. I.e. the ticks clock may be slow. Thus,
the value of tick0Secs, which tracks the slippage, will keep changing.
It's fine to measure it once and use it for a few minutes, but not for
hours. It should be remeasured. GetCharTest begins by asking SCREEN to
remeasure Tick0Secs.
best
denis
p.s.
i'm enclosing all the relevant new files: GetChar.mex, GetChar.m,
GetCharTest.m, SCREEN.mex,
i enhanced your GetCharTest.m and polished GetChar.mex slightly. I
think that it's now self explanatory.
help getchartest now says this:
GetCharTest evaluates the accuracy of the timing information returned by
GetChar. GetChar returns two values: when.ticks and when.secs.
when.ticks is passed on directly from the Mac OS. when.secs is an
estimate, based on when.ticks, of what GetSecs would have returned.
There are three issues that limit the accuracy of the timing:
1. The time, in ticks, of the keypress returned by the Mac OS is
inaccurate, with errors of more than one tick. This may reflect
coarse quantization of time in the the hardware interface to the
keyboard. Different kinds of keyboard interface (built-in laptop
keyboard, ADB, USB) may have different quantizations.
2. A tick is an integer, with a unit of 1/60.15 s.
3. The value of when.secs necessarily inherits all the inaccuracies of
when.ticks, and has a further problem. If you know the rates of two
clocks, it's easy to convert times from one kind of time to the other.
We do that by estimating Tick0Secs, the value of GetSecs at the moment
when GetTicks was zero.
tick0Secs=GetSecs-GetTicks/60.15;
We can then convert any value of ticks to secs by the formula:
secs=ticks/60.15+tick0Secs;
However, it turns out that the Mac OS tick counter often misses ticks
when the computer is very busy. I.e. the ticks clock may be slow. Thus,
the value of tick0Secs, which tracks the slippage, will keep changing.
It's fine to measure it once and use it for a few minutes, but not for
hours. It should be remeasured. GetCharTest begins by asking SCREEN to
remeasure Tick0Secs.
best
denis
p.s.
i'm enclosing all the relevant new files: GetChar.mex, GetChar.m,
GetCharTest.m, SCREEN.mex,