Holcombe:ButtonBox

From OpenWetWare

(Difference between revisions)
Jump to: navigation, search
Line 9: Line 9:
from struct import unpack
from struct import unpack
-
And to initialize the box:\n
+
And to initialize the box:
-
\t s = serial.Serial('/dev/tty.usbserial-FT3ERKOD', 115200)
+
s = serial.Serial('/dev/tty.usbserial-FT3ERKOD', 115200)
To erase all info in the box about previous button-presses:  
To erase all info in the box about previous button-presses:  
-
\t s.flushInput()
+
s.flushInput()
To reset the button-box internal clock to 0:
To reset the button-box internal clock to 0:

Revision as of 00:16, 24 April 2008

Members

Alex Holcombe
Sarah McIntyre
Fahed Jbarah
• Shih-Yu Lo
• Patrick Goodbourn
Lizzy Nguyen
Alumni


Technical

Skills Checklist
Python Programming
Psychopy/VisionEgg Installation Notes
R analysis,plot,stats
Statistics
Buttonbox
Verifying timing
Programming Cheat Sheets



The button-box we have used for our "sensorimotor synchronisation" experiments is a Cedrus RB-730 response pad. It is on loan from Nenad and the IT office. It connects to the computer via a USB port, and is controlled by the computer as a serial port (or something like that). [1]. To work, you must install a driver from the Cedrus website here:[2], and surprisingly, I also had to install a USB to serial port driver from a company called Keyspan: [3]. I used the driver for their USA-28x product.

I had all of the little dip switches in back in the down position.

To use the button-box with a python program, you need these lines at the start of your code: from psychopy import serial from struct import unpack

And to initialize the box:

s = serial.Serial('/dev/tty.usbserial-FT3ERKOD', 115200)

To erase all info in the box about previous button-presses:

s.flushInput()

To reset the button-box internal clock to 0:

s.write('e5')

Critically, the box records both the press and release of the button and sends a signal in exactly the same way (at least how it's set up now). To avoid this, you need to record both separately. Inside the program loop that's actually drawing the stimuli on every frame, I have code like this:

if s.inWaiting() > 0:

if PRESSED == False:

response = s.read(6)

formatted_response = unpack('<cBI', response)

time_of_keypress_ms = formatted_response[2] timePressRecorded = t framePressRecorded = frame PRESSED = True

s.flushInput()

T_END = t + t_end_delay

elif RELEASED == False: ReleaseResponse=s.read(6) formatted_ReleaseResponse=unpack('<cBI', ReleaseResponse) time_of_release_ms = formatted_ReleaseResponse[2] timeReleaseRecorded = t frameReleaseRecorded = frame RELEASED = True

s.flushInput()
Views
Personal tools