timing issue

I was wondering if anyone had seen this timing issue that I am
having. Basically I am trying to see how long a picture is presented
on the screen so my basic code looks like:

for i = 1:n
SCREEN('CopyWindow', ...);
timeonset = GetSecs;
screen(window,'waitblanking',waitlength);
SCREEN('CopyWindow', ...);
timenextpic = GetSecs;
data(i) = timenextpic-timeonset;
end

The problem is that data looks like:

data =

Columns 1 through 9

0.0333 0.0287 0.0287 0.0332 0.0332 0.0331
0.0332 0.0332 0.0287

Columns 10 through 18

0.0288 0.0332 0.0334 0.0287 0.0332 0.0287
0.0334 0.0334 0.0335

Columns 19 through 21

0.0287 0.0335 0.0335

While the descrepency isn't all that bad. I often seem to get that 5
msec descrepency (note: waitlength = 2). This is not a big deal, but
it is very consistent that most of the lengths are around 33.3 msec
(as they should be), but a significant portion are around 28.7 msec,
which is strange. Any clue what is going on here? Is the refresh
rate of the monitor flipping from 60 to 70 Hz for no apparent
reason? When I use framerate it says that the frame rate is 60 Hz
very very consistently.

Thank you,

Avniel
Hi David

Thank you for the help. I should have mentioned in my miniml example
that I do indeed do this. So the minimal example is actually:

waitlength = 2;
for i = 1:n
SCREEN(window,'WaitBlanking');
SCREEN('CopyWindow', ...);
timeonset = GetSecs;
SCREEN(window,'WaitBlanking',waitlength);
SCREEN('CopyWindow', ...);
timenextpic = GetSecs;
data(i) = timenextpic-timeonset;
end

Thanks again
Avniel
--- In psychtoolbox@y..., David Jones <djones@e...> wrote:
> Hi Avniel,
>
> I think you might get more consistent timing
> if you first wait for the vertical blanking interval
> and then start your timer.
> When you begin your timer asynchronously with your video display,
> but then call 'waitblanking', it will add a jitter
> of up to one frame time (1/60 = 16.7 msec).
> I am not surprised you are seeing variation in timing up to 5 msec.
>
> Add "SCREEN(window,'WaitBlanking');" at the top of your loop
> and see if it reduces the variability in your timing.
>
> -- David Jones
>
>
>
> On Monday, September 9, 2002, at 04:30 PM, aghuman2002 wrote:
>
> > I was wondering if anyone had seen this timing issue that I am
> > having. Basically I am trying to see how long a picture is
presented
> > on the screen so my basic code looks like:
> >
> > for i = 1:n
> > SCREEN('CopyWindow', ...);
> > timeonset = GetSecs;
> > screen(window,'waitblanking',waitlength);
> > SCREEN('CopyWindow', ...);
> > timenextpic = GetSecs;
> > data(i) = timenextpic-timeonset;
> > end
> >
> > The problem is that data looks like:
> >
> > data =
> >
> > Columns 1 through 9
> >
> > 0.0333 0.0287 0.0287 0.0332 0.0332 0.0331
> > 0.0332 0.0332 0.0287
> >
> > Columns 10 through 18
> >
> > 0.0288 0.0332 0.0334 0.0287 0.0332 0.0287
> > 0.0334 0.0334 0.0335
> >
> > Columns 19 through 21
> >
> > 0.0287 0.0335 0.0335
> >
> > While the descrepency isn't all that bad. I often seem to get
that 5
> > msec descrepency (note: waitlength = 2). This is not a big deal,
but
> > it is very consistent that most of the lengths are around 33.3
msec
> > (as they should be), but a significant portion are around 28.7
msec,
> > which is strange. Any clue what is going on here? Is the refresh
> > rate of the monitor flipping from 60 to 70 Hz for no apparent
> > reason? When I use framerate it says that the frame rate is 60 Hz
> > very very consistently.
> >
> > Thank you,
> >
> > Avniel
>
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
> - -
> Prof. David Jones, Dept of Electrical and Computer Engineering
> McMaster University, 1280 Main Street West, Hamilton, Ontario,
CANADA
> email: djones@e... phone: (905) 525-9140 ext.24689
> web: www.ece.mcmaster.ca/~djones fax: (905) 521-2922