Cannot send a signal via ParallelPort using PsychoPy on Windows7 (64bit)

Hello,

I try to send my trigger codes via a parallel port to our recording system. Unfortunately, PsychoPy is not satisfied with the installed drivers. To test the the signal transfer I started the “Parallel Ports Demo” provided by Psychopy. Here is the code:

#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
parallel ports demo

This is for win32 only.
"""

from __future__ import division

from psychopy import visual, core
from psychopy import parallel

nFramesOn = 5
nFramesOff = 30
nCycles = 2
parallel.setPortAddress(0x378)  # address for parallel port on many machines
pinNumber = 2  # choose a pin to write to (2-9).

# setup the stimuli and other objects we need
win = visual.Window([1280, 1024], allowGUI=False)  # make a window
win.flip()  # present it
myStim = visual.GratingStim(win, tex=None, mask=None, color='white', size=2)
myClock = core.Clock()  # just to keep track of time

# present a stimulus for EXACTLY 20 frames and exactly 5 cycles
for cycleN in range(nCycles):
    for frameN in range(nFramesOff):
        # don't draw, just refresh the window
        win.flip()
        parallel.setData(0)  # sets all pins low

    for frameN in range(nFramesOn):
        myStim.draw()
        win.flip()
        # immediately *after* screen refresh set pins as desired
        parallel.setPin(2, 1)  # sets just this pin to be high

# report the mean time afterwards
print('total time=%0.6f' % myClock.getTime())
print('avg frame rate=%0.3f' % win.fps())

# set pins back to low
win.flip()
parallel.setData(0)  # sets all pins low again

win.close()
core.quit()

# The contents of this file are in the public domain.

Starting the script produc`es the following errors:

Willkommen auf PsychoPy2!
v1.84.0
()
##### Running: C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.84.0-py2.7.egg\psychopy\demos\coder\hardware\parallelPortOutput.py #####
1.7963     WARNING     psychopy.parallel has been imported but no parallel port driver found. Install either inpout32 or dlportio
1.7964     WARNING     Could not initiate port: global name 'ParallelPort' is not defined

Traceback (most recent call last):
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.84.0-py2.7.egg\psychopy\demos\coder\hardware\parallelPortOutput.py", line 32, in <module>
    parallel.setData(0)  # sets all pins low
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.84.0-py2.7.egg\psychopy\parallel\__init__.py", line 165, in setData
    raise RuntimeError('Port address must be set using setPortAddress')
RuntimeError: Port address must be set using setPortAddress

Following the instructions, I installed the Inpout drivers from this website:

http://www.highrez.co.uk/Downloads/InpOut32/default.htm

As written in the documentation, I used the following file:

D:\InpOutBinaries_1501\Win32\InstallDriver.exe

Then, I got this message:

Successfully installed and opened 64bit InpOut driver InpOutx64.sys.

But, there is no change. I cannot send any signal via the parallel port, thus being not able to log trigger codes in the EEG recordings.

Do you have any idea?

PS: It works with Presentation…

1 Like

Hello Stefan,

It could be that your Python install is not communicating to the correct driver library, could be that it’s looking for the 32-bit version of the lib only in System32. You could try to run Psychopy on 64-bit Python 2.7 to fix the problem. A hacky fix that worked in the past for me (in another application) was to copy the inpoutx64.dll driver into both SysWOW64 and System32.

I’m not sure how it picked it up at the end there and why it’s not working.

Hi Stefan,

Others have run into this before, including myself, you can see my slightly more detailed answer here. But the short answer is that if you put a copy of that dll file in the same folder as your experiment’s script (the one ending with .py), it should work. Please let us know if it works!

Dan

2 Likes

The line above seems to be a part of the problem (if it means what it says) because you don’t want the 64bit driver but the 32bit one. I’m pretty sure on windows (even win64) you’ll need the 32bit driver because you’re using a 32bit python

@stefanrepplinger, was your problem solved? If yes, please tick solved. If not, it would be nice with a follow-up on what happened, so we can solve this.

That solved the problem. I needed to copy the inpout32.dll.Now, it works. I did manage to test your ideas before today. Thank you for the fast replies.

Stefan

Hey guys,

I have exactly the same problem! I have a 64-bit Windows 7 system, with python 2.7.15 and Psychopy 1.90.2. I followed all the same steps as @stedanrepplinger and also tried adding the inpout32.dll file to the experiment folder. However, none of this worked. Somehow “ctypes.windll” does not seem to have any attributes other than kernel132, Kernel132, LoadLibrary and shell132. If I specifically use “windll.LoadLibrary(‘inpoutx64.dll’)” it will output "<WinDLL ‘inpoutx64.dll’, handle 10000000 at 5186ba8>. If I try “windll.LoadLibrary(‘inpout32.dll’)” it throws the following error: “[Error 193] %1 is not a valid Win32 application”.

I found similar issues online, but they all seemed to be resolved when copying the inpout32.dll files to the experiment folder.

Does anyone have a clue on what could go wrong?

I solved my issue, by installing 32-bits Python instead of 64-bits.

1 Like