issue sending triggers using Neurospec usb-parallel adapter

72 views
Skip to first unread message

TheMetallicatz

unread,
Jul 4, 2017, 2:12:50 AM7/4/17
to psychopy-users
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):
    try:
        windll.inpout32.Out32(portaddress, triggerCode)
        #core.wait(0.05)
        windll.inpout32.Out32(portaddress, 0)
    except RuntimeError: print "Trigger \ ''' + str(triggerCode) + ''\'' could not be sent"
    except WindowsError: print "inpout32.dll couldn't be found"

sendTrigger(1)



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.


#!/usr/bin/env python2
from psychopy import visual, core, logging
from psychopy import parallel
from ctypes import windll

nFramesOn = 5
nFramesOff = 30
nCycles = 2
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
myWin.flip()#present it
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
        myWin.flip()
        parallel.setData(0)#sets all pins low
        
    for frameN in range(nFramesOn):
        myStim.draw()
        myWin.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=', myClock.getTime()
print 'avg frame rate=', myWin.fps()
#set pins back to low
myWin.flip()
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

Michael MacAskill

unread,
Jul 4, 2017, 4:22:59 PM7/4/17
to psychop...@googlegroups.com
Hello,

> This forum is deprecated. Please visit http://discourse.psychopy.org




Reply all
Reply to author
Forward
0 new messages