| Reference | Downloads | Github

Low-Latency Hardware Interfaces


Hello Everyone,

I frequently need to build external hardware to control stimuli presentation or receive responses in a novel way. I’m interested in what peripheral interfaces (USB, parallel, etc.) researchers conducting psychophysics experiments typically use to communicate with custom external hardware (i.e. micro-controllers, custom input interfaces, FPGAs, sensors, etc.) when using PsychoPy (or any other similar package), and how communication latency is handled if the operation is time-sensitive.


I’ve used the BBTK USB to TTL device in psychopy for event marking but it has input and output pins so could be hooked up to hardware. It interfaces really nicely with pyserial and claims to be millisecond accurate.

That being said - you would need to implement any time sensitive studies (i.e <17ms with a 60hz monitor) in coder because builder’s code components run every frame so millisecond accuracy is not as useful


Hello Oli,

That’s really neat. How does “event marking” work, I’m assuming the BBTK has an on-board clock that is asynchronous to the PCs.


In my case, I used pyserial to send binary digits (converted from hex from a column in the conditions file) to a biopac mp36 through the ttl device to a din connector in the back of the device, which was recorded as pulses in a channel in biopac student lab which could then be converted to events.

I’m not sure how the hardware works, but it comes with a calibration package to test latency. If you want asynchronous timing I think BBTK have other hardware that does that and more. I just needed to get around IT services’ declaration that parallel ports were obsolete so I couldn’t have one installed!


It would be nice if PCs shipped with GPIO (with IRQ) or SCSI ports. You can possibly use DAQ cards but the drivers can have hit-or-miss support for the specific platform you are using.


I’ve just fired up a Raspberry Pi to get readings from a light sensor via its GPIO port. I’m not an electronics person at all but the Pi is attractive as it is strongly oriented around Python programming.

The eventual goal is to send triggers to the Pi from a computer running PsychoPy via network messages, and use the Raspberry Pi for the hardware interfacing. The goal is to get some validation of synchronisation of various events (visual and auditory stimulus onsets and network messages). Not sure how it will go performance-wise, but being a computer in itself, and being able to communicate over the network, platform and hardware compatibility issues should tend to disappear.

There is something very cool in a lo-fi kind of way in seeing a computer directly responding to changes in the world:


Hello Michael,

I’ve seen an uptick in RPi use for prototyping and validation in vision science (likely other neuroscience fields too). I’m always a bit worried about the OS adding variance to interval measurements, but that is probably not much of a real issue.

I’ve built asynchronous timing circuits for stimulus interval validation using TTL logic in the past. Using SN74LV8154 chips hooked up to an oscillator for clocking. A rising/falling edge enables the chip to begin/stop counting. The internal register can be read out very quickly with an MCU. Two chips can give you a 64-bit register that can run on a clock of a few MHz. I think sub-microsecond resolution might be overkill, but it’s nice that it could be done. Variance is pretty low since we are dealing with “bare-metal” logic gates.


We’ve been using the U-HID nano boards ( for pretty much everything recently. They’re dirt cheap (£25) little interface devices that take an input on the pins on one end and spit out a standard USB keyboard click (or mouse click, or whatever - highly configurable) on the other end. Very reliable and simple. I haven’t done any extensive timing checks on them, but they should be fine for most applications. I probably wouldn’t use them if I had to do something with really accurate timing though.


We’re using the Teensy 3.2, with Linux we get submillisecond accuracy with the emulated serial port but it can also present as HID device (keyboard, mouse, joystick). It also has plenty TTL IO ports, costs about 24€ and has several extension boards.

Edit: there’s also the Radboud ButtonBox