Hi everyone
I'm having trouble getting my experiment to send triggers, and I'm thinking it may be to do with using a usb to parallel port converter (Neurospec).
I'm thinking this because triggers are being sent to ActiView when checked via Matlab, and I have the appropriate drivers installed plus inpout32 and have that placed in the folder of my script.
The script I am using within my study is below. It could be a simple address issue (this is the address when checking device managers via control panel). And no error message is displayed, so I gather it is correct.
from psychopy import parallel
from ctypes import windll
portaddress = 0x00000008
def sendTrigger(triggerCode):
windll.inpout32.Out32(portaddress, triggerCode)
windll.inpout32.Out32(portaddress, 0)
except RuntimeError: print "Trigger \ ''' + str(triggerCode) + ''\'' could not be sent"
except WindowsError: print "inpout32.dll couldn't be found"
I've also tried testing via the script below, which again shows no errors but simply doesn't send the trigger when checking via ActiView.
from psychopy import visual, core, logging
from psychopy import parallel
from ctypes import windll
parallel.setPortAddress(0x00000008) #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
myWin = visual.Window([1280, 1024],allowGUI=False)#make a window
myStim = visual.PatchStim(myWin, 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
parallel.setData(0)#sets all pins low
for frameN in range(nFramesOn):
#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=', myClock.getTime()
print 'avg frame rate=', myWin.fps()
parallel.setData(0)#sets all pins low again
I may be going down the wrong rabbit hole here, but Matlab runs the Neurospec usb-parallel adapter as a serial port - could this be the issue? (see URL)
Quoted from the URL below (under subheading Neurospec MMB trigger box) - "The box appears as serial port and trigger codes are sent to this serial port using PTB's IOPort
function"
Any help is massively appreciated!
Brendan