psychopy.org | Reference | Downloads | Github

Issue reading parallel port pin for button box

Hello there! I’m trying to run an experiment using PsychoPy that uses a button box connected to the stimulus computer via parallel port, but unfortunately we are unable to grab these responses.

System: Windows 7, 64-bit
PsychoPy Version: 1.85.2
Standalone install?: Yes

What have we tried?

  1. Ensuring that 32-bit Python was installed alongside 32-bit PsychoPy.
  2. Ensuring that the inpout32.dll driver is installed through the highrez link.
  3. Placing the inpout32.dll driver into the working directory of the program.
  4. Checking that we have the right parallel port address (LPT2, which is 0x3048 for us).
  5. Testing on Presentation: Presentation can hear the button responses just fine.
  6. Using the newer ParallelPort functions rather than legacy setPortAddress functions.

What else are we trying?

  1. @ulrikeh - our problem seems similar to yours, in that the issue was also inability to read the pins but other programs work fine. The pyparallel solution you found set the control register bit 5 to 0, to force operating in output mode. I’m confused because the built-in parallel functions should also do this? (parallel/_inpout32.py, line 43-44). We don’t have the simpleio driver required for pyparallel so unfortunately I can’t try using those functions.
  2. I’m thinking about the Device Manager interrupt options and whether those mean anything to the parallel port operation. Right now, it’s currently set to “Never use an interrupt”, but on our other system where PsychoPy works, it’s set to “Use any interrupt assigned to the port”. I’m not 100% sure on what the implications here are, although just trying to switch it over didn’t fix the issue.

I’m running out of ideas on how to fix this issue, so any help would be greatly appreciated! Let me know if I’m missing any info.

I fixed it! In case anyone else runs into this issue, here’s what happened.

The control register
In a parallel port, bit 5 of the control register (located at the parallel port’s base address + 2) will control the directional flow of the data. If this bit is flipped, then you will be unable to read any changes (see page 4 of this PDF for a detailed description). Setting this bit does seem to be included in the PsychoPy parallel class port instantiation, but I think it’s set to 0 whereas we needed it set to 1.

I used the ctypes/windll function library that underlies parallel port reading with the InpOut32.dll driver in PsychoPy to read and flip this bit accordingly. Now that I think about it, the PsychoPy parallel class should be able to read this bit if we use it to read the control register address… Will report back on that.

Edit: Also, there was a similar issue reported here where the fix came from using the pyparallel class instead. Their fix and our fix are fundamentally the same: pyparallel has a function that allows you to set the data direction, which is flipping bit 5 of the control register.

Read the button box documentation
We were using a RESPONSEPixx/MRI button box (4-button handheld). No one documented how the system was installed, and it turned out that a parallel port adapter provided by the company was not used, thus mapping the button responses onto unexpected pins. For us, the red button was being mapped onto pin 1 (i.e., strobe of the control register).

Hope this helps someone out there!

1 Like