Photodiode Tuner

This tool tests the response characteristics of a monitor connected to NIMH ML and adjusts the timing of screen flips so that stimuli can be presented immediately during the next frame. It is not necessary to use this tool, though, if the result of the latency test is normal.

1. Background

A frame is drawn by rasters scanning the screen (or scanlines; blue arrows in the figure below) from top left to bottom right. Some scanlines are not shown on the screen but used to fill in the vertical blank time (VBLANK; red arrows) between frames. It is a very common technique to replace screen contents during VBLANK, so that graphics may not be split into two frames. (Failure to avoid splits causes "tearing".) To use this technique, a memory buffer for new screen contents should be submitted sufficiently early before VBLANK occurs (green arrow). If the submission time is late and close to VBLANK, the contents may be delayed and displayed one frame later.

However, it does not necessarily mean that earlier buffer submission is always better. After the buffer submission, NIMH ML has to wait until the first scanline (scanline 8 in the above figure) begins, to record the exact time the new frame is displayed on the screen. This waiting takes away time for graphics and data processing. Therefore, we measure the optimal timing for buffer sumission to maximize the performance of NIMH ML.

2. Photodiode setup

To use the photodiode tuner, connect the photodiode input to a DAQ analoginput channel and assign the channel to "PhotoDiode" on the I/O menu.

Then choose a screen location for photodiode trigger display in the Video menu as shown below.

Note: 1. In NIMH ML, an eventmarker for a new frame is recorded when the first scanline is drawn from the upper left corner of the monitor. If the location of the photodiode is not upper left, the interval between the eventmarker and the photodiode response can be longer. 2. Flipping the screen upside-down in the Windows display settings changes the location of the photodiode trigger, but it does not affect the direction and location of scanlines.

Click the activated [Tune] button and the tuner window will pop up.

  • Photodiode response: Voltage changes in the photodiode input around the time when the photodiode trigger (white square) was presented on the display.
    • Vertical dotted line: Start time of a new frame after buffer submission
    • Blue line: Trace of the photodiode signal
    • Horizontal dotted line: Voltage threshold to detect the rise or fall of the photodiode signal
    • Black bar: Length of one frame measured
  • [Help] button: Open this document.
  • Scanline: The first and last scanline numbers of the subject screen.
  • Default threshold: By default, NIMH ML submits the screen buffer, if less than 10% of the total scanlines remain before VBLANK. This value is a good starting point for the [New thresold].
  • Old threshold: Scanline threshold when this tool was opened
  • New threshold: If this value is increased too much, the buffer submission time gets closer to VBLANK and new contents may not be presented in the immediate next frame. If this value is set too low, new graphics are likely to be presented in the immediate next frame but NIMH ML may not receive enough time to complete other tasks.
  • Voltage range: The voltage range of the photodiode signal. Determined automatically.
  • Voltage threshold: Move the voltage threshold (horizontal dotted line) up (100 max) and down (0 min)
  • One-shot test: Present the trigger (white square) and record the response once.
  • # of triggers and Multi-shot test: Repeat the one-shot test multiple times

3. Tuning

The results shown here are examples tested with a 3840x2160 monitor at 60 Hz. Each system is likely to have a different scanline range and a different threshold number.

In the figure below, the new threshold was set to 2110, which was closer to the last scanline (=2167), compared to the previous threshold (=1951). This number was too close to VBLANK so the photodiode trigger was pushed back by another frame, as shown by the estimated latencies (23.7 ms) and voltage traces in the figure below. Therefore, the value of 2110 would be a poor choice.

When the threshold was set to 2080, the photodiode trigger was presented in the frame drawn immediately after buffer submission, but sometimes it was delayed by another frame. This value would still not be a safe threshold.

With a threshold value of 2050, the photodiode trigger was presented in the immediate next frame every single time. This new threshold can be safely used. Click the [Save] button to keep the new threshold value.

The National Institute of Mental Health (NIMH) is part of the National Institutes of Health (NIH), a component of the U.S. Department of Health and Human Services.