Reading parallel port pin (for acquiring response from response pad) for MEG experiment

So here is the solution if anyone come across this situation. Thanks to everyone who helped out! Especially @jtseng !

I installed two PCIe parallel port cards, one for sending and one for receiving TTL pulses.

For sending trigger to the trigger box, I connected the parallel port of the PsychoPy PC (port address:0x4FF8) directly to the trigger box. I used this method to send the trigger.

For receiving the response outputs from the response pads, I connected the BNC outputs of the trigger box to a Cedrus StimTracker using a dual BNC to RJ45 cable (custom made according to pinout configuration of the Extra port on the StimTracker). I connected the extra port of the StimTracker to the PsychoPy PC parallel port (port address: 0x5FF8).

Codes:

from psychopy import parallel

#port setup
port = parallel.ParallelPort(0x5FF8) 

# pin 3 becomes 0 when left key is pressed
# pin 4 becomes 0 when right key is pressed
response1 = port.readPin(3) 
response2 = port.readPin(4)


# which button is pressed? 
# Note: On the StimTracker the TTL pulses are usually high. When a keypress is made the signal becomes low
while response1 == 1 and response2 ==1:
    if port.readPin(3) == 0:
        print("Left pressed")
        break

    if port.readPin(4) == 0:
        print("Right pressed")
        break
2 Likes