# Flip command time stamps - clarification from Mario

**URL:** <https://psychtoolbox.discourse.group/t/flip-command-time-stamps-clarification-from-mario/1785>\
**Category:** Uncategorized\
**Created:** [November 1, 2006, 5:15pm UTC](https://psychtoolbox.discourse.group/t/flip-command-time-stamps-clarification-from-mario/1785 "2006-11-01T17:15:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Allen\_Ingling](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Allen\_Ingling](https://psychtoolbox.discourse.group/u/Allen_Ingling)\
**Post date:** [November 1, 2006, 5:15pm UTC](https://psychtoolbox.discourse.group/t/flip-command-time-stamps-clarification-from-mario/1785/1 "2006-11-01T17:15:16Z")

</div>

Hello all,  
  
I emailed Mario to clarify 'Flip' command timestamps. Here is the   
edited version of that email. I thought of posting it here in case   
you had similar questions.  
  
"Hi Mario,  
  
 Have a quick question. I went through your web document on  
[http://www.kyb.tuebingen.mpg.de/bu/people/kleinerm/ptbosx/ptbdocu-](http://www.kyb.tuebingen.mpg.de/bu/people/kleinerm/ptbosx/ptbdocu-)  
.0.5MK4R1.html. And I gathered the following:  
  
 vbl - time stamp of the beginning of the vertical retrace - i.e.,   
the timestamp when the electron gun 'just' finished the last   
horizontal trace and is ready to move back to the top left corner of   
the screen.  
  
 stimOnsetTime - timestamp of the end of vertical retrace.  
  
 fliptime - timestamp when the flipping process is over.  
  
 If I understood these correctly, the stimOnsetTime must always  
be greater than vbl since vertical retracing takes finite time.   
Fliptime could be after stimOnsetTime. When I ran my code and looked   
at the time stamps, I invariably noted the following  
  
 1. The vbl and stimOnsetTime were equal.  
 2. The Fliptime was always after the stimOnsetTime even for a 100 X   
100 window with 100 random dots. I have copy-pasted the results from   
the MATLAB window after running the code \*Mani\_drawdots.m\* (please   
see the attachments).  
  
 EDU\>\>vbl =  
 9.172154133039482e+004  
 sot =  
 9.172154133039482e+004  
 flipt =  
 9.172154137748956e+004  
 miss =  
 -0.01674934297625  
 beam =  
 -1  
 EDU\>\> \*isequal(vbl,sot)\*  
 ans =  
 1  
 EDU\>\> \*flipt - sot\*  
 ans =  
 4.709474160335958e-005  
  
 Where am I doing the mistake?   
 Thank you  
 Cheers  
 Mani  
  
The results are correct for a machine that does not support   
beamposition queries.  
  
On machines that do support beamposition queries (All OS-X machines   
with PowerPC processor afaik, don't know about the OS-X IntelMacs),   
we use the queried display rasterbeam position to compute a highly   
robust timestamp. See "help Beampositionqueries" at the Matlab   
prompt. In that case, vbl is the timestamp of the beginning of the   
vertical retrace == time of buffer swap. stimOnsetTime is the time   
of end of vertical retrace == real stimulus onset == when the   
display starts drawing the first scanline. fliptime is the time when   
the Flip command itself finished executing, that can be anytime   
after vbl and will be before stimonsettime on a fast machine.  
  
vbl and stimOnsetTime are unaffected by operating system scheduling  
jitter and other timing noise in the machine, whereas the fliptime   
is an indication on how "quick" the Matlab and C code is executed.  
On machines that don't support beamposition queries (all M$-Windows  
PC's, all Linux PC's, maybe some IntelMacs?), we cannot compute these  
precise timestamps, so internally we simply call GetSecs --\> vbl =  
stimOnsetTime and fliptime \> vbl and beam == -1. This method of   
timing is less robust but its the best we can do in that case. Its   
basically the same as calling GetSecs() in Matlab after the 'Flip'   
call, just with slightly less jitter because its executed in the C   
code instead of Matlabs interpreter.  
  
So your machine doesn't support beamposition queries :( -- What   
machine did you test on and with which graphics card?  
  
  
ciao,  
-mario"
