# Trigger Code Hardware Setup

## Setting up a PC to use a PCIe parallel port card

This information is mostly for Aaron or anyone else who might be setting up a PC for the first time.&#x20;

You will need  to go to <https://www.highrez.co.uk/Downloads/InpOut32/default.htm> and download the latest binaries. Unzip the file, then run **as administrator** `Win32\InstallDriver` to install the drivers system-wide.&#x20;

#### Copy drivers to experiment folder

Once this is done, at least for [PsychoPy](https://psychopy.org/hardware/parallelPortInstr.html), experimenters will also need to  copy the files `inpoutx64.dll` and `inpoutx64.lib` from the `x64` folder, and then the file `inpout32.h` from the `Win32` folder. Place a copy of all of these in the **same folder as your PsychoPy experiment file (the one with the .psyexp filetype)**.

## Setting up a PC to use the USB-1208FS

An alternative to a PCIe card (especially useful with laptops and mini-PCs) is the [USB-1208FS](https://www.mccdaq.com/usb-data-acquisition/USB-1208FS-LS-1408FS-Series.aspx) DAQ. We have one in the lab (enclosed in a literal black box). To make this work, you first need to install the drivers and other support software, specifically the [MCC DAQ Software](https://www.mccdaq.com/Software-Downloads.aspx). This includes several necessary components including InstaCal and Universal Library. Installation is pretty straightforward — just run the installer and say yes to everything it asks, including rebooting as necessary.&#x20;

### Using the USB-1208FS with PsychoPy

This [PsychoPy forum post ](https://discourse.psychopy.org/t/triggering-a-daq-box/1222)was helpful. The first step, installing Universal Library, will have already been done when you installed the MCC DAQ software in the previous step. Now, download and install [PyUniversalLibrary](https://github.com/astraw/PyUniversalLibrary). "Install" here basically means "save it somewhere on the PC where you can acess it", and then open PsychoPy, go to Preferences -> General -> Paths, and add the full path to the PyUniversalLibrary folder (e.g.,&#x20;

The above-linked forum post also notes PyUniversalLibrary can be installed using `pip`.&#x20;

My experience was that PyUniversalLibrary did not work out of the box. Specifically, the line in `UniversalLibrary.py` that reads:`cbw = ctypes.windll.cbw32`

Needs to be changed to: `cbw = ctypes.WinDLL('/Path/to/UniversalLibrary/cbw64')`

Note that the above is case-sensitive (change `windll` to `WinDLL` ) and the 32 needs to be changed to 64 (unless you're running a 32-bit version of Windows, which you probably aren't). As well, the sample code on that PsychoPy forum post should be used as the basis for sending codes in your experiment; the typical `parallel` code will not work. NCIL's GitHub organization page has a repository with sample code, including the modified version of `UniversalLibrary.py` as per the notes above.
