# Sending trigger via parallel port

**URL:** <https://psychtoolbox.discourse.group/t/sending-trigger-via-parallel-port/4595>\
**Category:** Programming Help\
**Tags:** linux\
**Created:** [September 13, 2022, 8:20am UTC](https://psychtoolbox.discourse.group/t/sending-trigger-via-parallel-port/4595 "2022-09-13T08:20:07Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Ian-Max-Andolina](https://yyz2.discourse-cdn.com/free1/user_avatar/psychtoolbox.discourse.group/ian-max-andolina/32/4_2.png) [@Ian-Max-Andolina](https://psychtoolbox.discourse.group/u/Ian-Max-Andolina)\
**Post date:** [September 13, 2022, 9:29am UTC](https://psychtoolbox.discourse.group/t/sending-trigger-via-parallel-port/4595/2 "2022-09-13T09:29:19Z")

</div>

I’ve never used the parallel port, so don’t know what current code may control it on Linux. There are **many** ways to send a trigger. But for many users USB I/O devices work well. In MATLAB there are several ways to control a serial device, including PTB’s IOPort, and comparing performance I found that IOPort is clearly the fastest (~60µs TTL switch time using an Arduino):

> [@Serial port interface code -- a performance comparison](https://psychtoolbox.discourse.group/t/serial-port-interface-code-a-performance-comparison/3781):
>
> MATLAB has a fairly new (R2019B+) serial port interface, [Serialport](https://www.mathworks.com/help/matlab/serial-port-devices.html). Some of my arduino control code had previously used the [serial](https://www.mathworks.com/help/matlab/ref/serial.html) command that MATLAB has now deprecated. So I was curious to compare the old and new interfaces. In addition I also compared IOPort, the PTB serial controller. For the test I basically toggled the state of a digital pin on a [Seeduino Xiao](https://wiki.seeedstudio.com/Seeeduino-XIAO/) as fast as possible. I used the legacy MATLAB [arduino interface sketch](https://github.com/iandol/opticka/blob/master/communication/arduino/adio/adio.ino), which receives and sends the data via USB serial commands…

What are the parameters of the trigger you need to send? Some hardware require strobed words with a trigger bit, others simple TTLs etc…

There is some more info here:

> **[FAQ: TTL Triggers via USB](https://github.com/Psychtoolbox-3/Psychtoolbox-3/wiki/FAQ:-TTL-Triggers-via-USB)**
>
> Psychophysics Toolbox Version 3 (PTB-3) is a free set of Matlab and GNU Octave functions for vision and neuroscience research. - Psychtoolbox-3/Psychtoolbox-3

And some specific details for the LabJack:

> **[LabJack](https://github.com/Psychtoolbox-3/Psychtoolbox-3/wiki/LabJack)**
>
> Psychophysics Toolbox Version 3 (PTB-3) is a free set of Matlab and GNU Octave functions for vision and neuroscience research. - Psychtoolbox-3/Psychtoolbox-3

And Arduinos:

> **[Arduino](https://github.com/Psychtoolbox-3/Psychtoolbox-3/wiki/Arduino)**
>
> Psychophysics Toolbox Version 3 (PTB-3) is a free set of Matlab and GNU Octave functions for vision and neuroscience research. - Psychtoolbox-3/Psychtoolbox-3

@xiangrui from this forum made a response button + I/O box with very robust PTB support and high reliability that you can look at here, this would also allow you to compare timings to a photodiode etc:

[https://lobes.osu.edu/rt-box.php](https://lobes.osu.edu/rt-box.php)

---

_[View the full topic](https://psychtoolbox.discourse.group/t/sending-trigger-via-parallel-port/4595)._
