Tachistoscope - Software

From Display-Corner
Jump to: navigation, search

Controlling two monitors

Controlling two monitors for visual stimulation often comes with the problem of having to properly synchronize the software to the monitor's refresh cycle which, in turn, is defined by the graphics card. In a typical tachistoscope application, however, this is not a problem at all, because the software usually changes the output image only while the LED backlight of the respective monitor is switched off and, thus, synchronization artifacts like tearing would not be visible anyway. In fact, synchronizing image output with the refresh cycle might even not be desirable, because deferring image changes to the next refresh cycles only results in less time for the monitor pixels to settle to the new pixel values. Therefore, it might be useful to switch off double-buffering altogether which otherwise would be required for proper synchronization.

Controlling the LED backlight

In the simplest case, the LED backlight can be controlled through the parallel port of the experimental PC. Of course, timing is an issue here and high-level programming environments like Matlab/Psychtoolbox, E-Prime, or alike, might not provide the necessary accuracy, apart from the inevitable inaccuracies imposed by the operating system. Here is a solution for Matlab under Windows XP/7/10 (32 or 64bit) or for GNU Octave (5.1.0) under Windows 10 (64bit):

inpout32 driver (required by parPulse, includes also 64bit version) [InpOutBinaries_1500.zip]
→ for MATLAB: parPulse.mexw32 parPulse.mexw64 or for GNU Octave 5.1.0: parPulse.mex (v1.1, see also parPulse documentation)

parPulse can be used to generate short output pulses with an accuracy of a few microseconds. This is accomplished by temporarily raising the CPU priority to its maximum and using the high-precision timer for timing the pulse width. parPulse accesses the parallel port directly on a register level. This is normally forbidden by the operating system but overcome by the use of the inpout32 driver.

parPulse can also be used more generally, e.g. for generating triggers or even reading the state of two control lines which could be connected to external switches, push-buttons, or alike.

Installation of parPulse

  1. Copy the 32bit or 64bit parPulse mex-file either into the directory where your MATLAB script resides or into any of the directories listed in the MATLAB path. If you intend to switch between the 32bit and the 64bit MATLAB version, just copy both mex-files.
  2. Download and unzip the inpout32 driver. Run InpOutBinaries_1500\Win32\InstallDriver.exe (as Administrator), even when working on a 64bit Windows system.
  3. Put the inpout32 libraries (DLLs) where they can be found when the parPulse mex-file gets loaded by MATLAB. Either copy InpOutBinaries_1500\Win32\inpout32.dll or InpOutBinaries_1500\x64\inpout64.dll (or possibly both) into the directory with the parPulse mex-files, or copy them into the Windows system directory. When doing the latter, be careful, because it is somewhat counter-intuitive where the files should go. On a 32bit-Windows, it is inpout32.dll which goes into C:\Windows\system32\, whereas on a 64bit-Windows, it is inpout64.dll which goes there (i.e., into C:\Windows\system32\). If you want to run the 32bit MATLAB version on a 64bit-Windows, copy input32.dll into C:\Windows\SysWOW64\.
  4. If parPulse fails to work, the error messages are often misleading (if there are any). The most common cause of failure is that some DLLs cannot be found or don't load correctly due to insufficient access privileges. You might also have to install the Microsoft Visual C++ 2010 Redistributable Package (32bit 64bit).
  5. In order to use the parPulse() function, the correct hardware address of the parallel port has to be figured out (see Port address in the parPulse documentation).
  6. Windows might occasionally probe the parallel port for connected devices and, thus, interfere with parPulse(). In order to permanently prevent Windows from doing so, the Windows registry should be tweaked by running DisableParallelPortPolling.reg "as Administrator" once (possibly download via "Save Link Target As...").

Personal tools