Parallel Port in MRI sometimes works, sometimes not

Hey guys,
I am trying to make my experiment work in the fMRI. We already set up the parallel port using this code:
Begin Experiment Tab:

from psychopy import parallel
parallel.setPortAddress(0xE020)

Each frame:

if frameN > 1: #To allow the ‘Waiting for Scanner’ screen to display
trig = parallel.readPin(10)
print(“Pin10 output” + str(trig))
if trig != 0:
continueRoutine = False #A trigger was detected, so move on

The experiment should start, when the first trigger is sent. The experiment runs on Windows. Sometimes the experiment directly starts at the first trigger and works perfectly fine. But sometimes and I don’t know why, it doesn’t. Then there is just the “Wait for Scanner” screen and nothing happens, even if pulses are coming in.

I would be so glad, if somebody could help me.
Best, Saskia

The observation that it sometimes works and sometimes doesn’t suggests to me that you may be experiencing the same issue I did, where a particular bit of the parallel port that controls whether it’s reading or sending data can get flipped. When flipped, it’s set to “output” mode and cannot detect the trigger input.

See my post here for a write up on what could be going on. In the PsychoPy terminal, you can try running the test code lines to flip the control bit.