Using a photodiode to test timing

Dear all,

I am embarking on a project in which it would be useful to be able to use a photodiode (or equivalent) to record when the screen flips relative to when we think it should flip over the full course of an experiment.

I imagine a bunch of folk have do this routinely in time critical experiments with PTB (e.g. neurophysiology studies). It has been many years since I hooked up LabJack stuff to Matlab and PTB so am probably very out of date.

I was wondering if anyone would be able to share a full recipe as to achieving this?

In terms of cost, I have a small budget i.e. <£1000. I would like a simple but reliable solution.

I would be happy to share any resulting code from our work with the PTB community.

I will be using a ViewPixx 3D monitor, running latest Matlab and PTB, under Windows 10 (latest updates installed).

I am aware of the gospel of not being able to do real science on anything but Linux. So, no need for any sarcastic “upgrade” to Linux comments. Indeed, this would actually be contrary to the aims of the experiment.

Many thanks,


I recommend our toy: RTBox. The Github folder contains a doc folder with user manual for more information.


The RTBox photodiode worked well in the past for me, and was one of the methods I used for the ECVP 2010 timing poster and methodology which can be found in the Psychtoolbox/PsychDocumentation/ subfolder. Example use with our PsychRTBox() driver in FlipTimingWithRtBoxPhodoDiodeTest.m, although i don’t know if PTB’s driver still works with the latest RTBox versions and their firmware, as I only have an original Version 1 RTBox. The photo-diode and cable on mine broke many years ago, so I can’t use that method anymore.

Sometimes if i absolutely need a photo-diode nowadays, I use our PsychPhotodiode driver with a sound-card of known reasonably precise timing and photodiode hardware which i inherited and which i think corresponds to the one described in Max Di Luca’s article "New Method to Measure End-to-End Delay of Virtual Reality

A CRS ColorCal-II with hw that can timestamp TTL triggers is another method I occassionally need to use, abusing the ColorCal as a photo-diode’ish thing.

Ofc. there are all kinds of ways one can fool oneself with photo-diodes - i’ve explored many of them myself, and depending on the type of test stimulus sequence, operating system limitations and quirks, display panel (e.g., if it switches quickly from black->white or white->black) and panel backlight (does it modulate? how? which frequencies and how do these “carrier frequencies” interact with specific models of photo-diodes?) there are many more ways to fool oneself in subtle and not so subtle ways nowadays than in the good old days of CRT’s.

If you’d just want to explore the timing precision of the video signal received by a Viewpixx (and trust VPixx that timing from signal reception to photons is very deterministic and well defined), all VPixx devices have built in timestamping usable by PTB’s PsychDatapixx() driver and used in test scripts like VBLSyncTest, (VRRTest iirc.) and FlipTimingWithRtBoxPhodoDiodeTest. That’s what i use the most when possible as i’m mostly interested in verifying/validating PTB + computer + gpu timing precision in the most convenient and fool-proof way. Ofc. the result of those tests over more than a decade was that whenever PTB didn’t give timing warnings, PTB’s Flip software timestamping was always as accurate or more accurate as what the VPixx hardware or other methods (e.g., a VideoSwitcher + RtBox for analog VGA signals) reported.

1 Like

Hello Dr. Scarfe,
Would £0 fit into your budget :wink:
Your VIEWPixx 3D display has this functionality built-in. Using “Pixel Mode”, you can drive digital outputs based on the top-left pixel of the display, with microsecond sync to video. This single pixel is much smaller than a photodiode patch; and RGB bits can drive multiple digital outputs, for things like encoding a trial ID. Sort of a super-photodiode.


            -Peter April

Awesome, thanks. I should have thought about this. It there a help page which discusses pixel mode and how to utilise it?


Two comments:

  • Given that this Pixel Mode will have the same timing precision and reliability of its triggering behavior as Psychtoolbox built-in PSync based timestamping, that means that if one only needs timestamps of stimulus onset from the VPixx device, and not actual triggers for external recording equipment, the most convenient method is the one PTB has built in for VPixx devices, as mentioned in the last paragraph of my previous reply. That also takes care of gamma tables, dithering and other troublemakers on well working operating systems and drivers. In general i encourage any VPixx user to have a look at “help PsychDatapixx” and “help PsychImaging” sections related to VPixx for advanced functionality wrt. VPixx devices, e.g., complex trigger emission beyond what this pixel mode can do. These methods also work with the original Datapixx devices.

  • If one chooses to use Pixelmode for simple trigger emission on supported devices via the top-left pixel, i’d recommend replacing calls described in VPixx like Datapixx('Open') with PsychDataPixx('Open'), ie. generally replace Datapixx with PsychDatapixx, which does the same thing, but coordinates between potential PTB internal use of VPixx devices and such external code to reduce the likelihood of conflicts. Also the LoadIdentityClut command for dealing with gamma tables and dithering.

In any case one has to add the timing offsets to reported timestamps/registered trigger reception to translate to what a photodiode would measure, ie. true photon emission, as explained in the article linked by Peter.


Thanks all, this is really helpful. I will let you know how I get on.


Hi Mario,

Is there any other way to access the ECVP 2010 timing poster you mention here? The link in the PsychDocumentation subfolder is no longer working.


Hm, the PDF is still there in my install of PTB: !open /path/to/Psychtoolbox-3/Psychtoolbox/PsychDocumentation/ECVP2010Poster_VisualTimingPrecision.pdf opens the PDF in my PDF editor from MATLAB (open is the macOS way to open files from terminal, it is xdg-open for Linux), you need to change /path/to to the path for the PTB folder on your computer…

For those without the luxury of a VPixx display, you can use light to voltage photosensors like the TAOS TSL-251R and an arduino. The amplified voltage output makes them easy to integrate with other equipment… I started a wiki page here, but it needs more information as there are several additional tools for this (Mario has some sound card measurement code, but I forgot what it is called :upside_down_face:): Photodiodes and Timing Tools · Psychtoolbox-3/Psychtoolbox-3 Wiki · GitHub

Hi Ian,

For some reason I cannot access the document, could you kindly share the pdf here?


It is here: Psychtoolbox-3/Psychtoolbox/PsychDocumentation at master · Psychtoolbox-3/Psychtoolbox-3 · GitHub

Or direct download:

Thanks a lot, Ian.