display update

wangjing's Avatar

wangjing

22 Sep, 2014 02:07 PM

Hello Chris.
 I have realized that nextFrameTime() - now() gives about 0.2ms jitter. I assume this is about the error of next frame time estimate. Is there a function giving the actual time of updated display?
Thanks!

-Jing

  1. Support Staff 1 Posted by Christopher Sta... on 22 Sep, 2014 05:10 PM

    Christopher Stawarz's Avatar

    Hi Jing,

    The now function just returns the current time. It isn't tied to the display refresh cycle, so there's no reason to expect a constant delta between the values returned by it and nextFrameTime.

    Are you trying to determine when the current frame was displayed? If so, the best available estimate would be

    nextFrameTime() - 10e6 / refreshRate()
    

    Cheers,
    Chris

  2. 2 Posted by wangjing on 22 Sep, 2014 07:36 PM

    wangjing's Avatar

    I try to copy a digital output while updating the stimulus on display (by put a DO channel to high before the action "update display"). I want to know exact time delay between the DO assigned and next frame shown. I found they are 15.5ms with 0.2ms jitter. I guess my question should be What’s the best way to have output synchronized with monitor refresh? we’d like to register/ trigger some events in physiology which requires ms resolution.

    Thanks!

  3. Support Staff 3 Posted by Christopher Sta... on 25 Sep, 2014 02:20 PM

    Christopher Stawarz's Avatar

    Hi Jing,

    What’s the best way to have output synchronized with monitor refresh?

    At present, I think your best option is the following:

    1. Invoke "update_stimulus_display"
    2. Store the current value returned by nextFrameTime
    3. Wait until now() >= stored_next_frame_time
    4. Set the DO line high

    This isn't ideal, because it's possible (though not likely) that there will be sufficient delay between steps 1 and 2 that nextFrameTime will return the time of the frame after the one you want to synchronize with. To make this more robust, we could modify "update_stimulus_display" to store the correct next frame time in a variable.

    Chris

  4. Christopher Stawarz closed this discussion on 14 Oct, 2014 04:43 PM.

  5. Support Staff 4 Posted by Christopher Sta... on 04 Mar, 2015 02:24 PM

    Christopher Stawarz's Avatar

    Hi Jing & Evan,

    To make this more robust, we could modify "update_stimulus_display" to store the correct next frame time in a variable.

    This is done and in the MWorks nightly build. The "update_stimulus_display" action now accepts a new (optional) parameter, predicted_output_time. If the value of this parameter is set to the name of a variable, then "update_stimulus_display" will store in that variable the predicted output time of the frame in which the update will take effect.

    Here's my new recommended method for synchronizing a digital output with a display refresh:

    1. Invoke "update_stimulus_display" with predicted_output_time set to some_var
    2. Wait until now() >= some_var
    3. Set the DO line

    Cheers,
    Chris

  6. Christopher Stawarz closed this discussion on 13 Mar, 2015 04:55 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac