<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://tsgdoc.socsci.ru.nl/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=131.174.202.225</id>
	<title>TSG Doc - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://tsgdoc.socsci.ru.nl/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=131.174.202.225"/>
	<link rel="alternate" type="text/html" href="http://tsgdoc.socsci.ru.nl/index.php/Special:Contributions/131.174.202.225"/>
	<updated>2026-04-05T12:42:52Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.4</generator>
	<entry>
		<id>http://tsgdoc.socsci.ru.nl/index.php?title=Main_Page&amp;diff=511</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://tsgdoc.socsci.ru.nl/index.php?title=Main_Page&amp;diff=511"/>
		<updated>2014-05-26T12:38:12Z</updated>

		<summary type="html">&lt;p&gt;131.174.202.225: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Welcome to the TSG-Wiki page.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Welcome to the TSG Wiki. On this wiki you will find various documentation about Hardware, Software, Research Equipment used in the Lab Environments. In this wiki you wil also find some other usefull information.&lt;br /&gt;
&lt;br /&gt;
The TSG is specialized in three things, building hardware, electronics and experiment software. We develop hardware and electronics in-house due to the specifications of our researchers. Writing code for software has again three options, create your experiment in presentation(need a dongle), psychopy(multi platform (Windows, Linux, Mac) open source) or let your experiment be programmed for you.&lt;br /&gt;
&lt;br /&gt;
== Hardware Documentation ==&lt;br /&gt;
&lt;br /&gt;
*[[ButtonBoxes]]&lt;br /&gt;
&lt;br /&gt;
*[[JoySticks]]&lt;br /&gt;
&lt;br /&gt;
*[[Eyetrackers]]&lt;br /&gt;
&lt;br /&gt;
*[[Head Mounted Displays]]&lt;br /&gt;
&lt;br /&gt;
*[[Biopac]]&lt;br /&gt;
&lt;br /&gt;
*[[Computers]]&lt;br /&gt;
&lt;br /&gt;
*[[Laptops]]&lt;br /&gt;
&lt;br /&gt;
== Software Documentation ==&lt;br /&gt;
&lt;br /&gt;
*[[Neurobs Presentation]]&lt;br /&gt;
&lt;br /&gt;
*[[Psychopy]]&lt;br /&gt;
&lt;br /&gt;
*[[Brainvision]]&lt;br /&gt;
&lt;br /&gt;
*[[Noldus Software]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
&lt;br /&gt;
*Python Libraries&lt;br /&gt;
&lt;br /&gt;
*[[Video Codecs]]&lt;br /&gt;
&lt;br /&gt;
== Lab Setups ==&lt;br /&gt;
&lt;br /&gt;
*[[Cubicles]]&lt;br /&gt;
&lt;br /&gt;
*[[EEG Lab]]&lt;br /&gt;
&lt;br /&gt;
*VoiceKey Lab&lt;br /&gt;
&lt;br /&gt;
*[[RIVER Labs]]&lt;br /&gt;
&lt;br /&gt;
*Balanceboard Lab&lt;br /&gt;
&lt;br /&gt;
*Interaction Lab&lt;br /&gt;
&lt;br /&gt;
*Flex Lab&lt;br /&gt;
&lt;br /&gt;
*[[SensoriMotorLab]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Lab Use Policy and Guidelines ==&lt;br /&gt;
&lt;br /&gt;
*[[Bookings]]&lt;br /&gt;
&lt;br /&gt;
*[[Cleaning Procedures]]&lt;br /&gt;
&lt;br /&gt;
*[[Computer Equipment]]&lt;br /&gt;
&lt;br /&gt;
*[[Lab Equipment]]&lt;br /&gt;
&lt;br /&gt;
*[[Software Usage]]&lt;br /&gt;
&lt;br /&gt;
*[[Hygiene]]&lt;br /&gt;
&lt;br /&gt;
*[[Maintenance Window Lab Computers]]&lt;br /&gt;
&lt;br /&gt;
== Wall of fame ==&lt;/div&gt;</summary>
		<author><name>131.174.202.225</name></author>
	</entry>
	<entry>
		<id>http://tsgdoc.socsci.ru.nl/index.php?title=ButtonBox&amp;diff=460</id>
		<title>ButtonBox</title>
		<link rel="alternate" type="text/html" href="http://tsgdoc.socsci.ru.nl/index.php?title=ButtonBox&amp;diff=460"/>
		<updated>2014-05-01T12:25:07Z</updated>

		<summary type="html">&lt;p&gt;131.174.202.225: val= forgotten&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== General ==&lt;br /&gt;
&lt;br /&gt;
The buttonbox is used for time accurate(1ms) button press registration. We use it to register buttonpresses, soundkey, voicekey signals and to send tone onset, analog output, triggers with the BITSI protocol. It is suitable for Behavioral, EEG, MEG, and fMRI experiments.&amp;amp;nbsp;The buttonbox is connected to a computer with a usb connection.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[File:foto 1small.jpg|200px|Image: 200 pixels]]&lt;br /&gt;
| [[File:foto 2 small.jpg|200px|Image: 200 pixels]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The output connector has two binary eight bit ports: input and output. The two ports can be used for responses (input) and stimulus triggers (output). Two 8 bits analog outputs and three 8 bits analog inputs. The output connector has a sound and voicekey which triggers when a amplitude reaches a threshold. By using the serial port, the BITSI can be used platform independently: it works on Windows, Linux and Mac OSX. Most programming environments and stimulus packages support serial communication.&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
== BITSI Protocol ==&lt;br /&gt;
&lt;br /&gt;
BITSI stands for Bits to Serial Interface. Because the BITSI is designed to interface both in- and output signals, the 'protocol' is asymmetric: the input and output protocols differ.&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;'''Input'''&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The input port can be used to interface eight buttons maximally. Button presses are translated to serial output characters/bytes according to the following table:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;0&amp;quot; width=&amp;quot;462&amp;quot; style=&amp;quot;width:462px;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
'''Signal / Button'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
'''ASCII''' (rising / falling)&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
'''Code''' (rising / falling)&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
1&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
A / a&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
65 / 97&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
2&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
B / b&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
66 / 98&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
3&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
C / c&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
67 / 99&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
4&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
D / d&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
68 / 100&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
5&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
E / e&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
69 / 101&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
6&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
F / f&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
70 / 102&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
7&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
G / g&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
71 / 103&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
8&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
H / h&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
72 / 104&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
SoundKey&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
S / s&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
83 / 115&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
VoiceKey&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
V / v&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
86 / 118&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This means that when signal 1 gets /activated?, a capital A will be sent to the serial port. A lowercase 'a' will be sent when the signal is deactivated?. Mechanical buttons can be connected directly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;'''Output'''&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output knows two protocols: BITSI simple or BITSI extended. To enter a certain protocol two buttons have to be pressed when the BITSIbox is powered. Press button H and A for simple mode and H and B for extended mode.&lt;br /&gt;
&lt;br /&gt;
If no button is pressed when powered it boots the last known protocol. In the simple protocol every byte sent to the BITSI over the serial port, is represented at the 8 bit output.&lt;br /&gt;
&lt;br /&gt;
The '''extended''' protocol uses two bytes?, this combination can access two analog outputs and a tone generator. The first byte selects the output. The second byte determines the value written to this output.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;0&amp;quot; width=&amp;quot;434&amp;quot; style=&amp;quot;width:434px;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
'''Function'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
'''Byte 1 (ASCII / code)'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
'''Byte 2'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Marker out&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
M / 77&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
Marker value&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Analog out 1&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
Y / 89&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
Analog output value&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Analog out 2&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
Z / 90&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
Analog output value&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Tone&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
T / 84&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
Start tone&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Detect Sound&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
D&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
S / 83&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Detect Voice&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
D /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
V / 83&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Calibrate Sound&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
C /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
S&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Calibrate Voice&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
C /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
V&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Analog in 1&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
A /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
1&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Analog in 2&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
A /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
2&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Analog in 3&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
A /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
3&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Analog in 4&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
A /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
4&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
LEDs off&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
L /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
X&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
LEDs input&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
L /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
I&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
LEDs output&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
L /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
O&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;'''Trigger port settings'''&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Connector.png|300x300px|Connector.png]]&lt;br /&gt;
&lt;br /&gt;
The 25 pins female connector has 8 inputs and 8 outputs, respectively 1-8 are inputs and 9-16 are outputs. Three analog input with an analog to digital convertor of 12 bit, pins 17,18,20 and 21. Two analog outputs with an digital to analog convertor of 12 bits on pins 22 and 23.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;'''Serial port settings'''&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our hardware design allows to be connected to the computers USB and emulates a serial [[Port]].&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;0&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
'''Baudrate'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:69px;&amp;quot; | &lt;br /&gt;
115200&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
'''Parity'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:69px;&amp;quot; | &lt;br /&gt;
none&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
'''Data bits'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:69px;&amp;quot; | &lt;br /&gt;
8&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
'''Stop bits'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:69px;&amp;quot; | &lt;br /&gt;
1&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
'''Flow control'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:69px;&amp;quot; | &lt;br /&gt;
none&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== USB-Com port settings ==&lt;br /&gt;
&lt;br /&gt;
1.Connect the BITSIbox to your computer using the USB cable.&lt;br /&gt;
&lt;br /&gt;
2.When you connect the BITSIbox, Windows should initiate the driver installation process (if you haven't used the computer with an BITSIbox board before).&lt;br /&gt;
&lt;br /&gt;
3.On Windows Vista/7, the driver should be automatically downloaded and installed.&lt;br /&gt;
&lt;br /&gt;
4.On Windows XP, the Add New Hardware wizard will open:&lt;br /&gt;
&lt;br /&gt;
*When asked&amp;amp;nbsp;'''Can Windows connect to Windows Update to search for software?'''&amp;amp;nbsp;select&amp;amp;nbsp;'''No, not this time'''. Click next.&lt;br /&gt;
*Select&amp;amp;nbsp;'''Install from a list or specified location (Advanced)'''&amp;amp;nbsp;and click next.&lt;br /&gt;
*Make sure that&amp;amp;nbsp;'''Search for the best driver in these locations'''&amp;amp;nbsp;is checked; uncheck&amp;amp;nbsp;'''Search removable media'''; check&amp;amp;nbsp;'''Include this location in the search'''&amp;amp;nbsp;and browse to the&amp;amp;nbsp;'''c:/beheer/arduino/drivers '''directory.&lt;br /&gt;
*The wizard will search for the driver and then tell you that a &amp;quot;USB Serial Converter&amp;quot; was found. Click finish.&lt;br /&gt;
*The new hardware wizard will appear again. Go through the same steps and select the same options and location to search. This time, a &amp;quot;USB Serial Port&amp;quot; will be found.&lt;br /&gt;
&lt;br /&gt;
'''How to Check the Com Port settings(important!)'''&lt;br /&gt;
&lt;br /&gt;
*From the Start menu, open the '''Control Panel'''.&lt;br /&gt;
&lt;br /&gt;
*From the control panel, open the '''System window'''.&lt;br /&gt;
&lt;br /&gt;
*From the system properties window, go to the '''Hardware tab''' and click the '''Device Manager''' button.&lt;br /&gt;
&lt;br /&gt;
*From the Device Manager window, click '''Ports (Com&amp;amp;LPT).''' You should now be able to see which Com Port the USB adapter is assigned to.&lt;br /&gt;
&lt;br /&gt;
*If the Com Port is 10 or higher, you will have to change it to a lower port.&lt;br /&gt;
&lt;br /&gt;
*From the Device Manager window, click on '''USB Serial Port (Com#).''' Click the '''Port Settings tab''' of the USB Serial Port Properties window, and then click the '''Advanced''' button.&lt;br /&gt;
&lt;br /&gt;
*In the Advanced Settings window, use the scroll input to select a '''Com Port''' (select 10 or lower). Change '''Receive (bytes)''' and '''Transmit (bytes)''' to 64. Change the '''Latency Timer''' to 1.&lt;br /&gt;
&lt;br /&gt;
*Click the OK button.&lt;br /&gt;
&lt;br /&gt;
Always connect the usb device to the same port and your settings will be remembered.&lt;br /&gt;
&lt;br /&gt;
== TSG ButtonBox hardware 2013 ==&lt;br /&gt;
&lt;br /&gt;
Find the hardware design here&amp;amp;nbsp;[[Buttonbox 2013 Hardware|Buttonbox_2013_Hardware]]&lt;br /&gt;
&lt;br /&gt;
== TSG ButtonBox software 2013 ==&lt;br /&gt;
&lt;br /&gt;
Find the code here [[Media:BITSI_tempalte2013_duemilanove.zip]]&lt;br /&gt;
&lt;br /&gt;
== Presentation Settings ==&lt;br /&gt;
&lt;br /&gt;
The experiment files needs a few settings for the device to work:&lt;br /&gt;
* In the settings tab:  port -&amp;gt; input port -&amp;gt; 1 must be the device that identifies itself as &amp;quot;Arduino Uno&amp;quot; in the device manager. Note that the port must have a number not higher than 10 (COM1-COM10). Use re-enumerate if it is higher.&lt;br /&gt;
* Rate must be set 115200, Parity to None, Data Bits to 8 and Stop Bits to 1, Uncheck FIFO Interrupt.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[File:Buttonbox1.png]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Buttonbox in Python and PsychoPy ==&lt;br /&gt;
&lt;br /&gt;
Download this site package to use the buttonbox: [https://pypi.python.org/pypi/RuSocSci rusocsci]&lt;br /&gt;
&lt;br /&gt;
Example using buttons from the buttonbox in Python:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
# import the rusocsci.buttonbox module&lt;br /&gt;
from rusocsci import buttonbox &lt;br /&gt;
&lt;br /&gt;
# make a buttonbox&lt;br /&gt;
bb = buttonbox.Buttonbox()&lt;br /&gt;
&lt;br /&gt;
# wait for a single button press&lt;br /&gt;
b = bb.waitButtons()&lt;br /&gt;
&lt;br /&gt;
# print the button pressed&lt;br /&gt;
print(&amp;quot;b: {}&amp;quot;.format(b)) &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example using markers with the buttonbox in Python:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
# import the rusocsci.buttonbox module&lt;br /&gt;
from rusocsci import buttonbox &lt;br /&gt;
&lt;br /&gt;
# make a buttonbox&lt;br /&gt;
bb = buttonbox.Buttonbox()&lt;br /&gt;
&lt;br /&gt;
# wait for a single button press&lt;br /&gt;
bb.sendMarker(val=100)    #This is your marker code, range code 1-255 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;Example using the Buttonbox in PsychoPy:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
# import psychopy and rusocsci&lt;br /&gt;
from psychopy import core, visual &lt;br /&gt;
from rusocsci import buttonbox&lt;br /&gt;
&lt;br /&gt;
## Setup Section&lt;br /&gt;
win = visual.Window(monitor=&amp;quot;testMonitor&amp;quot;)&lt;br /&gt;
bb = buttonbox.Buttonbox()&lt;br /&gt;
text = visual.TextStim(win, &amp;quot;Press a button on the buttonbox&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
## Experiment Section&lt;br /&gt;
# show text&lt;br /&gt;
text.draw()&lt;br /&gt;
win.flip()&lt;br /&gt;
# wait for response&lt;br /&gt;
b = bb.waitButtons()&lt;br /&gt;
# show response&lt;br /&gt;
text.setText(&amp;quot;you pressed: {}&amp;quot;.format(b))&lt;br /&gt;
text.draw()&lt;br /&gt;
win.flip()&lt;br /&gt;
core.wait(5)&lt;br /&gt;
&lt;br /&gt;
## Cleanup Section&lt;br /&gt;
core.quit() &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Matlab Settings ==&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 ===================================================================================================&lt;br /&gt;
 function handle = serial_buttonbox_common(cmd,varargin)&lt;br /&gt;
 % to initialize connection:&lt;br /&gt;
 % handle = serial_buttonbox('open',se)&lt;br /&gt;
 % settings (se):&lt;br /&gt;
 % define settings as a structure, i.e.:&lt;br /&gt;
 % se.Device = 'COM1';&lt;br /&gt;
 % se.BaudRate = 115200;&lt;br /&gt;
 % se.DataBits = 8;&lt;br /&gt;
 % se.StopBits = 1;&lt;br /&gt;
 % se.Parity = 0;&lt;br /&gt;
 % se.PTBPath = 'c:\MyToolboxes\PsychToolbox'&lt;br /&gt;
 %&lt;br /&gt;
 % to close the connection:&lt;br /&gt;
 % serial_buttonbox('close',handle);&lt;br /&gt;
 &lt;br /&gt;
 persistent old_hdl&lt;br /&gt;
 &lt;br /&gt;
 % set defaults&lt;br /&gt;
 se.Device = 'COM1';&lt;br /&gt;
 se.BaudRate = 115200;&lt;br /&gt;
 se.DataBits = 8;&lt;br /&gt;
 se.StopBits = 1;&lt;br /&gt;
 se.Parity = 0;&lt;br /&gt;
 se.PTBPath = 'c:\Pgrogram Files\PsychToolbox';&lt;br /&gt;
 &lt;br /&gt;
 if nargin &amp;lt; 1&lt;br /&gt;
 cmd = 'open';&lt;br /&gt;
 end&lt;br /&gt;
 if nargin &amp;gt; 1&lt;br /&gt;
 % user overwrites default settings&lt;br /&gt;
 flds = fields(varargin{1});&lt;br /&gt;
 for n = 1 : numel(flds)&lt;br /&gt;
 se.(flds{n}) = varargin{1}.(flds{n});&lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 switch cmd&lt;br /&gt;
 case 'open'&lt;br /&gt;
 addpath(genpath(se.PTBPath));&lt;br /&gt;
 % get handle to serial device&lt;br /&gt;
 handle = open_buttonbox(se.Device);&lt;br /&gt;
 return&lt;br /&gt;
 case 'close'&lt;br /&gt;
 handle = varargin{1};&lt;br /&gt;
 IOPort('close',handle);&lt;br /&gt;
 return&lt;br /&gt;
 case 'run'&lt;br /&gt;
 % read incoming data&lt;br /&gt;
 if isempty(old_hdl)&lt;br /&gt;
 help serial_buttonbox_common&lt;br /&gt;
 error('Buttonbox not yet initialized');&lt;br /&gt;
 end&lt;br /&gt;
 handle = old_hdl;&lt;br /&gt;
 otherwise&lt;br /&gt;
 fprintf('Unknown option %s\n',cmd);&lt;br /&gt;
 return&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 % only gets here when cmd = 'run'&lt;br /&gt;
 while 1 &lt;br /&gt;
 % start polling for characters (indicating start of scan)&lt;br /&gt;
 navailable = IOPort('BytesAvailable', handle);&lt;br /&gt;
 if navailable&lt;br /&gt;
 data = [];&lt;br /&gt;
 while navailable&lt;br /&gt;
 % read incoming data&lt;br /&gt;
 [newdata, ~, err] = IOPort('Read', handle, 0, navailable);&lt;br /&gt;
 if ~isempty(err), disp(err); end&lt;br /&gt;
 data = [data newdata];&lt;br /&gt;
 %pause(0.001); % if possible just add a small pause to not claim entire core&lt;br /&gt;
 navailable = IOPort('BytesAvailable', handle);&lt;br /&gt;
 end&lt;br /&gt;
 if numel(data)&amp;gt;1&lt;br /&gt;
 fprintf('\nReceived characters: %d\n',numel(data));&lt;br /&gt;
 end&lt;br /&gt;
 for n = 1 : numel(data)&lt;br /&gt;
 % disp(char(data(n)));&lt;br /&gt;
 fprintf('incoming: %d\t%s\n',data(n),char(data(n)));&lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 end %while 1&lt;br /&gt;
 &lt;br /&gt;
 function hdl = open_buttonbox(device)&lt;br /&gt;
 % open handle to serial device (mini buttonbox)&lt;br /&gt;
 try&lt;br /&gt;
 hdl = IOPort('OpenSerialPort',device,['BaudRate=' num2str(se.BaudRate)]);&lt;br /&gt;
 catch&lt;br /&gt;
 if ~isempty(old_hdl)&lt;br /&gt;
 IOPort('close',old_hdl);&lt;br /&gt;
 end&lt;br /&gt;
 hdl = IOPort('OpenSerialPort',device,['BaudRate=' num2str(se.BaudRate)]);&lt;br /&gt;
 end&lt;br /&gt;
 old_hdl = hdl;&lt;br /&gt;
 &lt;br /&gt;
 fprintf('Wait for device buttonbox....\n');&lt;br /&gt;
 tic&lt;br /&gt;
 while ~IOPort('BytesAvailable', hdl) &amp;amp;&amp;amp; toc&amp;lt;10&lt;br /&gt;
 % wait for welcome message device&lt;br /&gt;
 end&lt;br /&gt;
 pause(0.5);&lt;br /&gt;
 &lt;br /&gt;
 % clear buffer&lt;br /&gt;
 %IOPort('flush', hdl);&lt;br /&gt;
 IOPort('purge', hdl);&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 end&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>131.174.202.225</name></author>
	</entry>
	<entry>
		<id>http://tsgdoc.socsci.ru.nl/index.php?title=ButtonBox&amp;diff=339</id>
		<title>ButtonBox</title>
		<link rel="alternate" type="text/html" href="http://tsgdoc.socsci.ru.nl/index.php?title=ButtonBox&amp;diff=339"/>
		<updated>2014-04-30T08:15:52Z</updated>

		<summary type="html">&lt;p&gt;131.174.202.225: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== General ==&lt;br /&gt;
&lt;br /&gt;
The buttonbox is used for time accurate(1ms) button press registration. We use it to register buttonpresses, soundkey, voicekey signals and to send tone onset, analog output, triggers with the BITSI protocol. It is suitable for Behavioral, EEG, MEG, and fMRI experiments.&amp;amp;nbsp;The buttonbox is connected to a computer with a usb connection.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[File:foto 1small.jpg|200px|Image: 200 pixels]]&lt;br /&gt;
| [[File:foto 2 small.jpg|200px|Image: 200 pixels]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The output connector has two binary eight bit ports: input and output. The two ports can be used for responses (input) and stimulus triggers (output). Two 8 bits analog outputs and three 8 bits analog inputs. The output connector has a sound and voicekey which triggers when a amplitude reaches a threshold. By using the serial port, the BITSI can be used platform independently: it works on Windows, Linux and Mac OSX. Most programming environments and stimulus packages support serial communication.&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
== BITSI Protocol ==&lt;br /&gt;
&lt;br /&gt;
BITSI stands for Bits to Serial Interface. Because the BITSI is designed to interface both in- and output signals, the 'protocol' is asymmetric: the input and output protocols differ.&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;'''Input'''&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The input port can be used to interface eight buttons maximally. Button presses are translated to serial output characters/bytes according to the following table:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;0&amp;quot; width=&amp;quot;462&amp;quot; style=&amp;quot;width:462px;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
'''Signal / Button'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
'''ASCII''' (rising / falling)&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
'''Code''' (rising / falling)&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
1&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
A / a&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
65 / 97&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
2&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
B / b&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
66 / 98&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
3&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
C / c&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
67 / 99&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
4&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
D / d&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
68 / 100&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
5&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
E / e&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
69 / 101&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
6&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
F / f&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
70 / 102&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
7&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
G / g&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
71 / 103&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
8&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
H / h&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
72 / 104&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
SoundKey&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
S / s&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
83 / 115&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
VoiceKey&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
V / v&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
86 / 118&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This means that when signal 1 gets /activated?, a capital A will be sent to the serial port. A lowercase 'a' will be sent when the signal is deactivated?. Mechanical buttons can be connected directly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;'''Output'''&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output knows two protocols: BITSI simple or BITSI extended. To enter a certain protocol two buttons have to be pressed when the BITSIbox is powered. Press button H and A for simple mode and H and B for extended mode.&lt;br /&gt;
&lt;br /&gt;
If no button is pressed when powered it boots the last known protocol. In the simple protocol every byte sent to the BITSI over the serial port, is represented at the 8 bit output.&lt;br /&gt;
&lt;br /&gt;
The '''extended''' protocol uses two bytes?, this combination can access two analog outputs and a tone generator. The first byte selects the output. The second byte determines the value written to this output.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;0&amp;quot; width=&amp;quot;434&amp;quot; style=&amp;quot;width:434px;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
'''Function'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
'''Byte 1 (ASCII / code)'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
'''Byte 2'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Marker out&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
M / 77&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
Marker value&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Analog out 1&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
Y / 89&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
Analog output value&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Analog out 2&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
Z / 90&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
Analog output value&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Tone&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
T / 84&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
Start tone&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Detect Sound&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
D&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
S / 83&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Detect Voice&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
D /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
V / 83&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Calibrate Sound&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
C /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
S&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Calibrate Voice&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
C /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
V&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Analog in 1&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
A /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
1&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Analog in 2&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
A /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
2&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Analog in 3&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
A /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
3&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Analog in 4&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
A /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
4&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
LEDs off&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
L /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
X&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
LEDs input&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
L /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
I&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
LEDs output&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
L /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
O&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;'''Trigger port settings'''&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Connector.png|300x300px|Connector.png]]&lt;br /&gt;
&lt;br /&gt;
The 25 pins female connector has 8 inputs and 8 outputs, respectively 1-8 are inputs and 9-16 are outputs. Three analog input with an analog to digital convertor of 12 bit, pins 17,18,20 and 21. Two analog outputs with an digital to analog convertor of 12 bits on pins 22 and 23.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;'''Serial port settings'''&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our hardware design allows to be connected to the computers USB and emulates a serial [[Port]].&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;0&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
'''Baudrate'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:69px;&amp;quot; | &lt;br /&gt;
115200&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
'''Parity'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:69px;&amp;quot; | &lt;br /&gt;
none&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
'''Data bits'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:69px;&amp;quot; | &lt;br /&gt;
8&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
'''Stop bits'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:69px;&amp;quot; | &lt;br /&gt;
1&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
'''Flow control'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:69px;&amp;quot; | &lt;br /&gt;
none&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== USB-Com port settings ==&lt;br /&gt;
&lt;br /&gt;
1.Connect the BITSIbox to your computer using the USB cable.&lt;br /&gt;
&lt;br /&gt;
2.When you connect the BITSIbox, Windows should initiate the driver installation process (if you haven't used the computer with an BITSIbox board before).&lt;br /&gt;
&lt;br /&gt;
3.On Windows Vista/7, the driver should be automatically downloaded and installed.&lt;br /&gt;
&lt;br /&gt;
4.On Windows XP, the Add New Hardware wizard will open:&lt;br /&gt;
&lt;br /&gt;
*When asked&amp;amp;nbsp;'''Can Windows connect to Windows Update to search for software?'''&amp;amp;nbsp;select&amp;amp;nbsp;'''No, not this time'''. Click next.&lt;br /&gt;
*Select&amp;amp;nbsp;'''Install from a list or specified location (Advanced)'''&amp;amp;nbsp;and click next.&lt;br /&gt;
*Make sure that&amp;amp;nbsp;'''Search for the best driver in these locations'''&amp;amp;nbsp;is checked; uncheck&amp;amp;nbsp;'''Search removable media'''; check&amp;amp;nbsp;'''Include this location in the search'''&amp;amp;nbsp;and browse to the&amp;amp;nbsp;'''c:/beheer/arduino/drivers '''directory.&lt;br /&gt;
*The wizard will search for the driver and then tell you that a &amp;quot;USB Serial Converter&amp;quot; was found. Click finish.&lt;br /&gt;
*The new hardware wizard will appear again. Go through the same steps and select the same options and location to search. This time, a &amp;quot;USB Serial Port&amp;quot; will be found.&lt;br /&gt;
&lt;br /&gt;
'''How to Check the Com Port settings(important!)'''&lt;br /&gt;
&lt;br /&gt;
*From the Start menu, open the '''Control Panel'''.&lt;br /&gt;
&lt;br /&gt;
*From the control panel, open the '''System window'''.&lt;br /&gt;
&lt;br /&gt;
*From the system properties window, go to the '''Hardware tab''' and click the '''Device Manager''' button.&lt;br /&gt;
&lt;br /&gt;
*From the Device Manager window, click '''Ports (Com&amp;amp;LPT).''' You should now be able to see which Com Port the USB adapter is assigned to.&lt;br /&gt;
&lt;br /&gt;
*If the Com Port is 10 or higher, you will have to change it to a lower port.&lt;br /&gt;
&lt;br /&gt;
*From the Device Manager window, click on '''USB Serial Port (Com#).''' Click the '''Port Settings tab''' of the USB Serial Port Properties window, and then click the '''Advanced''' button.&lt;br /&gt;
&lt;br /&gt;
*In the Advanced Settings window, use the scroll input to select a '''Com Port''' (select 10 or lower). Change '''Receive (bytes)''' and '''Transmit (bytes)''' to 64. Change the '''Latency Timer''' to 1.&lt;br /&gt;
&lt;br /&gt;
*Click the OK button.&lt;br /&gt;
&lt;br /&gt;
Always connect the usb device to the same port and your settings will be remembered.&lt;br /&gt;
&lt;br /&gt;
== TSG ButtonBox hardware 2013 ==&lt;br /&gt;
&lt;br /&gt;
Find the hardware design here&amp;amp;nbsp;[[Buttonbox 2013 Hardware|Buttonbox_2013_Hardware]]&lt;br /&gt;
&lt;br /&gt;
== TSG ButtonBox software 2013 ==&lt;br /&gt;
&lt;br /&gt;
Find the code here [[Media:BITSI_tempalte2013_duemilanove.zip]]&lt;br /&gt;
&lt;br /&gt;
== Presentation Settings ==&lt;br /&gt;
&lt;br /&gt;
The experiment files needs a few settings for the device to work:&lt;br /&gt;
* In the settings tab:  port -&amp;gt; input port -&amp;gt; 1 must be the device that identifies itself as &amp;quot;Arduino Uno&amp;quot; in the device manager. Note that the port must have a number not higher than 10 (COM1-COM10). Use re-enumerate if it is higher.&lt;br /&gt;
* Rate must be set 115200, Parity to None, Data Bits to 8 and Stop Bits to 1, Uncheck FIFO Interrupt.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[File:Buttonbox1.png]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Buttonbox in Python and PsychoPy ==&lt;br /&gt;
&lt;br /&gt;
Example using the buttonbox in Python:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
# import the rusocsci.buttonbox module&lt;br /&gt;
from rusocsci import buttonbox &lt;br /&gt;
&lt;br /&gt;
# make a buttonbox&lt;br /&gt;
bb = buttonbox.Buttonbox()&lt;br /&gt;
&lt;br /&gt;
# wait for a single button press&lt;br /&gt;
b = bb.waitButtons()&lt;br /&gt;
&lt;br /&gt;
# print the button pressed&lt;br /&gt;
print(&amp;quot;b: {}&amp;quot;.format(b)) &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example using the Buttonbox in PsychoPy:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
# import psychopy and rusocsci&lt;br /&gt;
from psychopy import core, visual &lt;br /&gt;
from rusocsci import buttonbox&lt;br /&gt;
&lt;br /&gt;
## Setup Section&lt;br /&gt;
win = visual.Window(monitor=&amp;quot;testMonitor&amp;quot;)&lt;br /&gt;
bb = buttonbox.Buttonbox()&lt;br /&gt;
text = visual.TextStim(win, &amp;quot;Press a button on the buttonbox&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
## Experiment Section&lt;br /&gt;
# show text&lt;br /&gt;
text.draw()&lt;br /&gt;
win.flip()&lt;br /&gt;
# wait for response&lt;br /&gt;
b = bb.waitButtons()&lt;br /&gt;
# show response&lt;br /&gt;
text.setText(&amp;quot;you pressed: {}&amp;quot;.format(b))&lt;br /&gt;
text.draw()&lt;br /&gt;
win.flip()&lt;br /&gt;
core.wait(5)&lt;br /&gt;
&lt;br /&gt;
## Cleanup Section&lt;br /&gt;
core.quit() &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Matlab Settings ==&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 ===================================================================================================&lt;br /&gt;
 function handle = serial_buttonbox_common(cmd,varargin)&lt;br /&gt;
 % to initialize connection:&lt;br /&gt;
 % handle = serial_buttonbox('open',se)&lt;br /&gt;
 % settings (se):&lt;br /&gt;
 % define settings as a structure, i.e.:&lt;br /&gt;
 % se.Device = 'COM1';&lt;br /&gt;
 % se.BaudRate = 115200;&lt;br /&gt;
 % se.DataBits = 8;&lt;br /&gt;
 % se.StopBits = 1;&lt;br /&gt;
 % se.Parity = 0;&lt;br /&gt;
 % se.PTBPath = 'c:\MyToolboxes\PsychToolbox'&lt;br /&gt;
 %&lt;br /&gt;
 % to close the connection:&lt;br /&gt;
 % serial_buttonbox('close',handle);&lt;br /&gt;
 &lt;br /&gt;
 persistent old_hdl&lt;br /&gt;
 &lt;br /&gt;
 % set defaults&lt;br /&gt;
 se.Device = 'COM1';&lt;br /&gt;
 se.BaudRate = 115200;&lt;br /&gt;
 se.DataBits = 8;&lt;br /&gt;
 se.StopBits = 1;&lt;br /&gt;
 se.Parity = 0;&lt;br /&gt;
 se.PTBPath = 'c:\Pgrogram Files\PsychToolbox';&lt;br /&gt;
 &lt;br /&gt;
 if nargin &amp;lt; 1&lt;br /&gt;
 cmd = 'open';&lt;br /&gt;
 end&lt;br /&gt;
 if nargin &amp;gt; 1&lt;br /&gt;
 % user overwrites default settings&lt;br /&gt;
 flds = fields(varargin{1});&lt;br /&gt;
 for n = 1 : numel(flds)&lt;br /&gt;
 se.(flds{n}) = varargin{1}.(flds{n});&lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 switch cmd&lt;br /&gt;
 case 'open'&lt;br /&gt;
 addpath(genpath(se.PTBPath));&lt;br /&gt;
 % get handle to serial device&lt;br /&gt;
 handle = open_buttonbox(se.Device);&lt;br /&gt;
 return&lt;br /&gt;
 case 'close'&lt;br /&gt;
 handle = varargin{1};&lt;br /&gt;
 IOPort('close',handle);&lt;br /&gt;
 return&lt;br /&gt;
 case 'run'&lt;br /&gt;
 % read incoming data&lt;br /&gt;
 if isempty(old_hdl)&lt;br /&gt;
 help serial_buttonbox_common&lt;br /&gt;
 error('Buttonbox not yet initialized');&lt;br /&gt;
 end&lt;br /&gt;
 handle = old_hdl;&lt;br /&gt;
 otherwise&lt;br /&gt;
 fprintf('Unknown option %s\n',cmd);&lt;br /&gt;
 return&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 % only gets here when cmd = 'run'&lt;br /&gt;
 while 1 &lt;br /&gt;
 % start polling for characters (indicating start of scan)&lt;br /&gt;
 navailable = IOPort('BytesAvailable', handle);&lt;br /&gt;
 if navailable&lt;br /&gt;
 data = [];&lt;br /&gt;
 while navailable&lt;br /&gt;
 % read incoming data&lt;br /&gt;
 [newdata, ~, err] = IOPort('Read', handle, 0, navailable);&lt;br /&gt;
 if ~isempty(err), disp(err); end&lt;br /&gt;
 data = [data newdata];&lt;br /&gt;
 %pause(0.001); % if possible just add a small pause to not claim entire core&lt;br /&gt;
 navailable = IOPort('BytesAvailable', handle);&lt;br /&gt;
 end&lt;br /&gt;
 if numel(data)&amp;gt;1&lt;br /&gt;
 fprintf('\nReceived characters: %d\n',numel(data));&lt;br /&gt;
 end&lt;br /&gt;
 for n = 1 : numel(data)&lt;br /&gt;
 % disp(char(data(n)));&lt;br /&gt;
 fprintf('incoming: %d\t%s\n',data(n),char(data(n)));&lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 end %while 1&lt;br /&gt;
 &lt;br /&gt;
 function hdl = open_buttonbox(device)&lt;br /&gt;
 % open handle to serial device (mini buttonbox)&lt;br /&gt;
 try&lt;br /&gt;
 hdl = IOPort('OpenSerialPort',device,['BaudRate=' num2str(se.BaudRate)]);&lt;br /&gt;
 catch&lt;br /&gt;
 if ~isempty(old_hdl)&lt;br /&gt;
 IOPort('close',old_hdl);&lt;br /&gt;
 end&lt;br /&gt;
 hdl = IOPort('OpenSerialPort',device,['BaudRate=' num2str(se.BaudRate)]);&lt;br /&gt;
 end&lt;br /&gt;
 old_hdl = hdl;&lt;br /&gt;
 &lt;br /&gt;
 fprintf('Wait for device buttonbox....\n');&lt;br /&gt;
 tic&lt;br /&gt;
 while ~IOPort('BytesAvailable', hdl) &amp;amp;&amp;amp; toc&amp;lt;10&lt;br /&gt;
 % wait for welcome message device&lt;br /&gt;
 end&lt;br /&gt;
 pause(0.5);&lt;br /&gt;
 &lt;br /&gt;
 % clear buffer&lt;br /&gt;
 %IOPort('flush', hdl);&lt;br /&gt;
 IOPort('purge', hdl);&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 end&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>131.174.202.225</name></author>
	</entry>
	<entry>
		<id>http://tsgdoc.socsci.ru.nl/index.php?title=ButtonBox&amp;diff=338</id>
		<title>ButtonBox</title>
		<link rel="alternate" type="text/html" href="http://tsgdoc.socsci.ru.nl/index.php?title=ButtonBox&amp;diff=338"/>
		<updated>2014-04-30T08:14:55Z</updated>

		<summary type="html">&lt;p&gt;131.174.202.225: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== General ==&lt;br /&gt;
&lt;br /&gt;
The buttonbox is used for time accurate(1ms) button press registration. We use it to register buttonpresses, soundkey, voicekey signals and to send tone onset, analog output, triggers with the BITSI protocol. It is suitable for Behavioral, EEG, MEG, and fMRI experiments.&amp;amp;nbsp;The buttonbox is connected to a computer with a usb connection.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[File:foto 1small.jpg|200px|Image: 200 pixels]]&lt;br /&gt;
| [[File:foto 2 small.jpg|200px|Image: 200 pixels]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The output connector has two binary eight bit ports: input and output. The two ports can be used for responses (input) and stimulus triggers (output). Two 8 bits analog outputs and three 8 bits analog inputs. The output connector has a sound and voicekey which triggers when a amplitude reaches a threshold. By using the serial port, the BITSI can be used platform independently: it works on Windows, Linux and Mac OSX. Most programming environments and stimulus packages support serial communication.&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
== BITSI Protocol ==&lt;br /&gt;
&lt;br /&gt;
BITSI stands for Bits to Serial Interface. Because the BITSI is designed to interface both in- and output signals, the 'protocol' is asymmetric: the input and output protocols differ.&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;'''Input'''&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The input port can be used to interface eight buttons maximally. Button presses are translated to serial output characters/bytes according to the following table:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;0&amp;quot; width=&amp;quot;462&amp;quot; style=&amp;quot;width:462px;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
'''Signal / Button'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
'''ASCII''' (rising / falling)&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
'''Code''' (rising / falling)&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
1&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
A / a&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
65 / 97&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
2&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
B / b&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
66 / 98&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
3&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
C / c&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
67 / 99&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
4&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
D / d&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
68 / 100&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
5&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
E / e&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
69 / 101&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
6&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
F / f&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
70 / 102&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
7&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
G / g&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
71 / 103&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
8&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
H / h&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
72 / 104&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
SoundKey&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
S / s&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
83 / 115&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
VoiceKey&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
V / v&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
86 / 118&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This means that when signal 1 gets /activated?, a capital A will be sent to the serial port. A lowercase 'a' will be sent when the signal is deactivated?. Mechanical buttons can be connected directly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;'''Output'''&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output knows two protocols: BITSI simple or BITSI extended. To enter a certain protocol two buttons have to be pressed when the BITSIbox is powered. Press button H and A for simple mode and H and B for extended mode.&lt;br /&gt;
&lt;br /&gt;
If no button is pressed when powered it boots the last known protocol. In the simple protocol every byte sent to the BITSI over the serial port, is represented at the 8 bit output.&lt;br /&gt;
&lt;br /&gt;
The '''extended''' protocol uses two bytes?, this combination can access two analog outputs and a tone generator. The first byte selects the output. The second byte determines the value written to this output.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;0&amp;quot; width=&amp;quot;434&amp;quot; style=&amp;quot;width:434px;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
'''Function'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
'''Byte 1 (ASCII / code)'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
'''Byte 2'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Marker out&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
M / 77&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
Marker value&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Analog out 1&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
Y / 89&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
Analog output value&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Analog out 2&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
Z / 90&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
Analog output value&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Tone&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
T / 84&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
Start tone&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Detect Sound&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
D&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
S / 83&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Detect Voice&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
D /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
V / 83&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Calibrate Sound&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
C /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
S&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Calibrate Voice&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
C /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
V&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Analog in 1&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
A /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
1&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Analog in 2&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
A /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
2&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Analog in 3&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
A /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
3&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Analog in 4&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
A /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
4&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
LEDs off&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
L /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
X&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
LEDs input&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
L /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
I&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
LEDs output&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
L /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
O&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;'''Trigger port settings'''&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Connector.png|300x300px|Connector.png]]&lt;br /&gt;
&lt;br /&gt;
The 25 pins female connector has 8 inputs and 8 outputs, respectively 1-8 are inputs and 9-16 are outputs. Three analog input with an analog to digital convertor of 12 bit, pins 17,18,20 and 21. Two analog outputs with an digital to analog convertor of 12 bits on pins 22 and 23.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;'''Serial port settings'''&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our hardware design allows to be connected to the computers USB and emulates a serial [[Port]].&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;0&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
'''Baudrate'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:69px;&amp;quot; | &lt;br /&gt;
115200&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
'''Parity'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:69px;&amp;quot; | &lt;br /&gt;
none&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
'''Data bits'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:69px;&amp;quot; | &lt;br /&gt;
8&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
'''Stop bits'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:69px;&amp;quot; | &lt;br /&gt;
1&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
'''Flow control'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:69px;&amp;quot; | &lt;br /&gt;
none&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== USB-Com port settings ==&lt;br /&gt;
&lt;br /&gt;
1.Connect the BITSIbox to your computer using the USB cable.&lt;br /&gt;
&lt;br /&gt;
2.When you connect the BITSIbox, Windows should initiate the driver installation process (if you haven't used the computer with an BITSIbox board before).&lt;br /&gt;
&lt;br /&gt;
3.On Windows Vista/7, the driver should be automatically downloaded and installed.&lt;br /&gt;
&lt;br /&gt;
4.On Windows XP, the Add New Hardware wizard will open:&lt;br /&gt;
&lt;br /&gt;
*When asked&amp;amp;nbsp;'''Can Windows connect to Windows Update to search for software?'''&amp;amp;nbsp;select&amp;amp;nbsp;'''No, not this time'''. Click next.&lt;br /&gt;
*Select&amp;amp;nbsp;'''Install from a list or specified location (Advanced)'''&amp;amp;nbsp;and click next.&lt;br /&gt;
*Make sure that&amp;amp;nbsp;'''Search for the best driver in these locations'''&amp;amp;nbsp;is checked; uncheck&amp;amp;nbsp;'''Search removable media'''; check&amp;amp;nbsp;'''Include this location in the search'''&amp;amp;nbsp;and browse to the&amp;amp;nbsp;'''c:/beheer/arduino/drivers '''directory.&lt;br /&gt;
*The wizard will search for the driver and then tell you that a &amp;quot;USB Serial Converter&amp;quot; was found. Click finish.&lt;br /&gt;
*The new hardware wizard will appear again. Go through the same steps and select the same options and location to search. This time, a &amp;quot;USB Serial Port&amp;quot; will be found.&lt;br /&gt;
&lt;br /&gt;
'''How to Check the Com Port settings(important!)'''&lt;br /&gt;
&lt;br /&gt;
*From the Start menu, open the '''Control Panel'''.&lt;br /&gt;
&lt;br /&gt;
*From the control panel, open the '''System window'''.&lt;br /&gt;
&lt;br /&gt;
*From the system properties window, go to the '''Hardware tab''' and click the '''Device Manager''' button.&lt;br /&gt;
&lt;br /&gt;
*From the Device Manager window, click '''Ports (Com&amp;amp;LPT).''' You should now be able to see which Com Port the USB adapter is assigned to.&lt;br /&gt;
&lt;br /&gt;
*If the Com Port is 10 or higher, you will have to change it to a lower port.&lt;br /&gt;
&lt;br /&gt;
*From the Device Manager window, click on '''USB Serial Port (Com#).''' Click the '''Port Settings tab''' of the USB Serial Port Properties window, and then click the '''Advanced''' button.&lt;br /&gt;
&lt;br /&gt;
*In the Advanced Settings window, use the scroll input to select a '''Com Port''' (select 10 or lower). Change '''Receive (bytes)''' and '''Transmit (bytes)''' to 64. Change the '''Latency Timer''' to 1.&lt;br /&gt;
&lt;br /&gt;
*Click the OK button.&lt;br /&gt;
&lt;br /&gt;
Always connect the usb device to the same port and your settings will be remembered.&lt;br /&gt;
&lt;br /&gt;
== TSG ButtonBox hardware 2013 ==&lt;br /&gt;
&lt;br /&gt;
Find the hardware design here&amp;amp;nbsp;[[Buttonbox 2013 Hardware|Buttonbox_2013_Hardware]]&lt;br /&gt;
&lt;br /&gt;
== TSG ButtonBox software 2013 ==&lt;br /&gt;
&lt;br /&gt;
Find the code here [[Media:BITSI_tempalte2013_duemilanove.zip]]&lt;br /&gt;
&lt;br /&gt;
== Presentation Settings ==&lt;br /&gt;
&lt;br /&gt;
The experiment files needs a few settings for the device to work:&lt;br /&gt;
* In the settings tab:  port -&amp;gt; input port -&amp;gt; 1 must be the device that identifies itself as &amp;quot;Arduino Uno&amp;quot; in the device manager. Note that the port must have a number not higher than 10 (COM1-COM10). Use re-enumerate if it is higher.&lt;br /&gt;
* Rate must be set 115200, Parity to None, Data Bits to 8 and Stop Bits to 1, Uncheck FIFO Interrupt.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[File:Buttonbox1.png]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Buttonbox in Python and PsychoPy ==&lt;br /&gt;
&lt;br /&gt;
Example using the buttonbox in Python:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 #!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
 # import the rusocsci.buttonbox module&lt;br /&gt;
 from rusocsci import buttonbox &lt;br /&gt;
&lt;br /&gt;
 # make a buttonbox&lt;br /&gt;
 bb = buttonbox.Buttonbox()&lt;br /&gt;
&lt;br /&gt;
 # wait for a single button press&lt;br /&gt;
 b = bb.waitButtons()&lt;br /&gt;
&lt;br /&gt;
 # print the button pressed&lt;br /&gt;
 print(&amp;quot;b: {}&amp;quot;.format(b)) &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example using the Buttonbox in PsychoPy:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 #!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
 # import psychopy and rusocsci&lt;br /&gt;
 from psychopy import core, visual &lt;br /&gt;
 from rusocsci import buttonbox&lt;br /&gt;
&lt;br /&gt;
 ## Setup Section&lt;br /&gt;
 win = visual.Window(monitor=&amp;quot;testMonitor&amp;quot;)&lt;br /&gt;
 bb = buttonbox.Buttonbox()&lt;br /&gt;
 text = visual.TextStim(win, &amp;quot;Press a button on the buttonbox&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 ## Experiment Section&lt;br /&gt;
 # show text&lt;br /&gt;
 text.draw()&lt;br /&gt;
 win.flip()&lt;br /&gt;
 # wait for response&lt;br /&gt;
 b = bb.waitButtons()&lt;br /&gt;
 # show response&lt;br /&gt;
 text.setText(&amp;quot;you pressed: {}&amp;quot;.format(b))&lt;br /&gt;
 text.draw()&lt;br /&gt;
 win.flip()&lt;br /&gt;
 core.wait(5)&lt;br /&gt;
&lt;br /&gt;
 ## Cleanup Section&lt;br /&gt;
 core.quit() &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Matlab Settings ==&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 ===================================================================================================&lt;br /&gt;
 function handle = serial_buttonbox_common(cmd,varargin)&lt;br /&gt;
 % to initialize connection:&lt;br /&gt;
 % handle = serial_buttonbox('open',se)&lt;br /&gt;
 % settings (se):&lt;br /&gt;
 % define settings as a structure, i.e.:&lt;br /&gt;
 % se.Device = 'COM1';&lt;br /&gt;
 % se.BaudRate = 115200;&lt;br /&gt;
 % se.DataBits = 8;&lt;br /&gt;
 % se.StopBits = 1;&lt;br /&gt;
 % se.Parity = 0;&lt;br /&gt;
 % se.PTBPath = 'c:\MyToolboxes\PsychToolbox'&lt;br /&gt;
 %&lt;br /&gt;
 % to close the connection:&lt;br /&gt;
 % serial_buttonbox('close',handle);&lt;br /&gt;
 &lt;br /&gt;
 persistent old_hdl&lt;br /&gt;
 &lt;br /&gt;
 % set defaults&lt;br /&gt;
 se.Device = 'COM1';&lt;br /&gt;
 se.BaudRate = 115200;&lt;br /&gt;
 se.DataBits = 8;&lt;br /&gt;
 se.StopBits = 1;&lt;br /&gt;
 se.Parity = 0;&lt;br /&gt;
 se.PTBPath = 'c:\Pgrogram Files\PsychToolbox';&lt;br /&gt;
 &lt;br /&gt;
 if nargin &amp;lt; 1&lt;br /&gt;
 cmd = 'open';&lt;br /&gt;
 end&lt;br /&gt;
 if nargin &amp;gt; 1&lt;br /&gt;
 % user overwrites default settings&lt;br /&gt;
 flds = fields(varargin{1});&lt;br /&gt;
 for n = 1 : numel(flds)&lt;br /&gt;
 se.(flds{n}) = varargin{1}.(flds{n});&lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 switch cmd&lt;br /&gt;
 case 'open'&lt;br /&gt;
 addpath(genpath(se.PTBPath));&lt;br /&gt;
 % get handle to serial device&lt;br /&gt;
 handle = open_buttonbox(se.Device);&lt;br /&gt;
 return&lt;br /&gt;
 case 'close'&lt;br /&gt;
 handle = varargin{1};&lt;br /&gt;
 IOPort('close',handle);&lt;br /&gt;
 return&lt;br /&gt;
 case 'run'&lt;br /&gt;
 % read incoming data&lt;br /&gt;
 if isempty(old_hdl)&lt;br /&gt;
 help serial_buttonbox_common&lt;br /&gt;
 error('Buttonbox not yet initialized');&lt;br /&gt;
 end&lt;br /&gt;
 handle = old_hdl;&lt;br /&gt;
 otherwise&lt;br /&gt;
 fprintf('Unknown option %s\n',cmd);&lt;br /&gt;
 return&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 % only gets here when cmd = 'run'&lt;br /&gt;
 while 1 &lt;br /&gt;
 % start polling for characters (indicating start of scan)&lt;br /&gt;
 navailable = IOPort('BytesAvailable', handle);&lt;br /&gt;
 if navailable&lt;br /&gt;
 data = [];&lt;br /&gt;
 while navailable&lt;br /&gt;
 % read incoming data&lt;br /&gt;
 [newdata, ~, err] = IOPort('Read', handle, 0, navailable);&lt;br /&gt;
 if ~isempty(err), disp(err); end&lt;br /&gt;
 data = [data newdata];&lt;br /&gt;
 %pause(0.001); % if possible just add a small pause to not claim entire core&lt;br /&gt;
 navailable = IOPort('BytesAvailable', handle);&lt;br /&gt;
 end&lt;br /&gt;
 if numel(data)&amp;gt;1&lt;br /&gt;
 fprintf('\nReceived characters: %d\n',numel(data));&lt;br /&gt;
 end&lt;br /&gt;
 for n = 1 : numel(data)&lt;br /&gt;
 % disp(char(data(n)));&lt;br /&gt;
 fprintf('incoming: %d\t%s\n',data(n),char(data(n)));&lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 end %while 1&lt;br /&gt;
 &lt;br /&gt;
 function hdl = open_buttonbox(device)&lt;br /&gt;
 % open handle to serial device (mini buttonbox)&lt;br /&gt;
 try&lt;br /&gt;
 hdl = IOPort('OpenSerialPort',device,['BaudRate=' num2str(se.BaudRate)]);&lt;br /&gt;
 catch&lt;br /&gt;
 if ~isempty(old_hdl)&lt;br /&gt;
 IOPort('close',old_hdl);&lt;br /&gt;
 end&lt;br /&gt;
 hdl = IOPort('OpenSerialPort',device,['BaudRate=' num2str(se.BaudRate)]);&lt;br /&gt;
 end&lt;br /&gt;
 old_hdl = hdl;&lt;br /&gt;
 &lt;br /&gt;
 fprintf('Wait for device buttonbox....\n');&lt;br /&gt;
 tic&lt;br /&gt;
 while ~IOPort('BytesAvailable', hdl) &amp;amp;&amp;amp; toc&amp;lt;10&lt;br /&gt;
 % wait for welcome message device&lt;br /&gt;
 end&lt;br /&gt;
 pause(0.5);&lt;br /&gt;
 &lt;br /&gt;
 % clear buffer&lt;br /&gt;
 %IOPort('flush', hdl);&lt;br /&gt;
 IOPort('purge', hdl);&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 end&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>131.174.202.225</name></author>
	</entry>
	<entry>
		<id>http://tsgdoc.socsci.ru.nl/index.php?title=ButtonBox&amp;diff=337</id>
		<title>ButtonBox</title>
		<link rel="alternate" type="text/html" href="http://tsgdoc.socsci.ru.nl/index.php?title=ButtonBox&amp;diff=337"/>
		<updated>2014-04-30T08:11:03Z</updated>

		<summary type="html">&lt;p&gt;131.174.202.225: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== General ==&lt;br /&gt;
&lt;br /&gt;
The buttonbox is used for time accurate(1ms) button press registration. We use it to register buttonpresses, soundkey, voicekey signals and to send tone onset, analog output, triggers with the BITSI protocol. It is suitable for Behavioral, EEG, MEG, and fMRI experiments.&amp;amp;nbsp;The buttonbox is connected to a computer with a usb connection.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[File:foto 1small.jpg|200px|Image: 200 pixels]]&lt;br /&gt;
| [[File:foto 2 small.jpg|200px|Image: 200 pixels]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The output connector has two binary eight bit ports: input and output. The two ports can be used for responses (input) and stimulus triggers (output). Two 8 bits analog outputs and three 8 bits analog inputs. The output connector has a sound and voicekey which triggers when a amplitude reaches a threshold. By using the serial port, the BITSI can be used platform independently: it works on Windows, Linux and Mac OSX. Most programming environments and stimulus packages support serial communication.&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
== BITSI Protocol ==&lt;br /&gt;
&lt;br /&gt;
BITSI stands for Bits to Serial Interface. Because the BITSI is designed to interface both in- and output signals, the 'protocol' is asymmetric: the input and output protocols differ.&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;'''Input'''&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The input port can be used to interface eight buttons maximally. Button presses are translated to serial output characters/bytes according to the following table:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;0&amp;quot; width=&amp;quot;462&amp;quot; style=&amp;quot;width:462px;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
'''Signal / Button'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
'''ASCII''' (rising / falling)&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
'''Code''' (rising / falling)&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
1&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
A / a&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
65 / 97&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
2&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
B / b&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
66 / 98&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
3&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
C / c&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
67 / 99&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
4&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
D / d&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
68 / 100&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
5&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
E / e&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
69 / 101&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
6&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
F / f&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
70 / 102&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
7&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
G / g&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
71 / 103&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
8&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
H / h&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
72 / 104&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
SoundKey&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
S / s&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
83 / 115&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
VoiceKey&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
V / v&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
86 / 118&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This means that when signal 1 gets /activated?, a capital A will be sent to the serial port. A lowercase 'a' will be sent when the signal is deactivated?. Mechanical buttons can be connected directly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;'''Output'''&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output knows two protocols: BITSI simple or BITSI extended. To enter a certain protocol two buttons have to be pressed when the BITSIbox is powered. Press button H and A for simple mode and H and B for extended mode.&lt;br /&gt;
&lt;br /&gt;
If no button is pressed when powered it boots the last known protocol. In the simple protocol every byte sent to the BITSI over the serial port, is represented at the 8 bit output.&lt;br /&gt;
&lt;br /&gt;
The '''extended''' protocol uses two bytes?, this combination can access two analog outputs and a tone generator. The first byte selects the output. The second byte determines the value written to this output.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;0&amp;quot; width=&amp;quot;434&amp;quot; style=&amp;quot;width:434px;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
'''Function'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
'''Byte 1 (ASCII / code)'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
'''Byte 2'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Marker out&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
M / 77&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
Marker value&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Analog out 1&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
Y / 89&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
Analog output value&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Analog out 2&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
Z / 90&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
Analog output value&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Tone&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
T / 84&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
Start tone&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Detect Sound&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
D&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
S / 83&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Detect Voice&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
D /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
V / 83&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Calibrate Sound&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
C /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
S&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Calibrate Voice&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
C /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
V&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Analog in 1&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
A /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
1&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Analog in 2&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
A /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
2&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Analog in 3&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
A /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
3&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Analog in 4&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
A /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
4&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
LEDs off&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
L /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
X&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
LEDs input&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
L /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
I&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
LEDs output&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
L /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
O&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;'''Trigger port settings'''&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Connector.png|300x300px|Connector.png]]&lt;br /&gt;
&lt;br /&gt;
The 25 pins female connector has 8 inputs and 8 outputs, respectively 1-8 are inputs and 9-16 are outputs. Three analog input with an analog to digital convertor of 12 bit, pins 17,18,20 and 21. Two analog outputs with an digital to analog convertor of 12 bits on pins 22 and 23.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;'''Serial port settings'''&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our hardware design allows to be connected to the computers USB and emulates a serial [[Port]].&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;0&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
'''Baudrate'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:69px;&amp;quot; | &lt;br /&gt;
115200&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
'''Parity'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:69px;&amp;quot; | &lt;br /&gt;
none&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
'''Data bits'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:69px;&amp;quot; | &lt;br /&gt;
8&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
'''Stop bits'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:69px;&amp;quot; | &lt;br /&gt;
1&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
'''Flow control'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:69px;&amp;quot; | &lt;br /&gt;
none&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== USB-Com port settings ==&lt;br /&gt;
&lt;br /&gt;
1.Connect the BITSIbox to your computer using the USB cable.&lt;br /&gt;
&lt;br /&gt;
2.When you connect the BITSIbox, Windows should initiate the driver installation process (if you haven't used the computer with an BITSIbox board before).&lt;br /&gt;
&lt;br /&gt;
3.On Windows Vista/7, the driver should be automatically downloaded and installed.&lt;br /&gt;
&lt;br /&gt;
4.On Windows XP, the Add New Hardware wizard will open:&lt;br /&gt;
&lt;br /&gt;
*When asked&amp;amp;nbsp;'''Can Windows connect to Windows Update to search for software?'''&amp;amp;nbsp;select&amp;amp;nbsp;'''No, not this time'''. Click next.&lt;br /&gt;
*Select&amp;amp;nbsp;'''Install from a list or specified location (Advanced)'''&amp;amp;nbsp;and click next.&lt;br /&gt;
*Make sure that&amp;amp;nbsp;'''Search for the best driver in these locations'''&amp;amp;nbsp;is checked; uncheck&amp;amp;nbsp;'''Search removable media'''; check&amp;amp;nbsp;'''Include this location in the search'''&amp;amp;nbsp;and browse to the&amp;amp;nbsp;'''c:/beheer/arduino/drivers '''directory.&lt;br /&gt;
*The wizard will search for the driver and then tell you that a &amp;quot;USB Serial Converter&amp;quot; was found. Click finish.&lt;br /&gt;
*The new hardware wizard will appear again. Go through the same steps and select the same options and location to search. This time, a &amp;quot;USB Serial Port&amp;quot; will be found.&lt;br /&gt;
&lt;br /&gt;
'''How to Check the Com Port settings(important!)'''&lt;br /&gt;
&lt;br /&gt;
*From the Start menu, open the '''Control Panel'''.&lt;br /&gt;
&lt;br /&gt;
*From the control panel, open the '''System window'''.&lt;br /&gt;
&lt;br /&gt;
*From the system properties window, go to the '''Hardware tab''' and click the '''Device Manager''' button.&lt;br /&gt;
&lt;br /&gt;
*From the Device Manager window, click '''Ports (Com&amp;amp;LPT).''' You should now be able to see which Com Port the USB adapter is assigned to.&lt;br /&gt;
&lt;br /&gt;
*If the Com Port is 10 or higher, you will have to change it to a lower port.&lt;br /&gt;
&lt;br /&gt;
*From the Device Manager window, click on '''USB Serial Port (Com#).''' Click the '''Port Settings tab''' of the USB Serial Port Properties window, and then click the '''Advanced''' button.&lt;br /&gt;
&lt;br /&gt;
*In the Advanced Settings window, use the scroll input to select a '''Com Port''' (select 10 or lower). Change '''Receive (bytes)''' and '''Transmit (bytes)''' to 64. Change the '''Latency Timer''' to 1.&lt;br /&gt;
&lt;br /&gt;
*Click the OK button.&lt;br /&gt;
&lt;br /&gt;
Always connect the usb device to the same port and your settings will be remembered.&lt;br /&gt;
&lt;br /&gt;
== TSG ButtonBox hardware 2013 ==&lt;br /&gt;
&lt;br /&gt;
Find the hardware design here&amp;amp;nbsp;[[Buttonbox 2013 Hardware|Buttonbox_2013_Hardware]]&lt;br /&gt;
&lt;br /&gt;
== TSG ButtonBox software 2013 ==&lt;br /&gt;
&lt;br /&gt;
Find the code here [[Media:BITSI_tempalte2013_duemilanove.zip]]&lt;br /&gt;
&lt;br /&gt;
== Presentation Settings ==&lt;br /&gt;
&lt;br /&gt;
The experiment files needs a few settings for the device to work:&lt;br /&gt;
* In the settings tab:  port -&amp;gt; input port -&amp;gt; 1 must be the device that identifies itself as &amp;quot;Arduino Uno&amp;quot; in the device manager. Note that the port must have a number not higher than 10 (COM1-COM10). Use re-enumerate if it is higher.&lt;br /&gt;
* Rate must be set 115200, Parity to None, Data Bits to 8 and Stop Bits to 1, Uncheck FIFO Interrupt.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[File:Buttonbox1.png]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Buttonbox in Python and PsychoPy ==&lt;br /&gt;
Example using the buttonbox in Python: &amp;lt;nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 #!/usr/bin/env python&lt;br /&gt;
 #import the rusocsci.buttonbox module&lt;br /&gt;
&lt;br /&gt;
 from rusocsci import buttonbox import logging, time&lt;br /&gt;
 #make a buttonbox&lt;br /&gt;
 bb = buttonbox.Buttonbox()&lt;br /&gt;
 #wait for a single button press&lt;br /&gt;
 b = bb.waitButtons()&lt;br /&gt;
 #print the button pressed&lt;br /&gt;
 print(&amp;quot;b: {}&amp;quot;.format(b)) &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using the Buttonbox in PsychoPy: &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 #!/usr/bin/env python&lt;br /&gt;
 #import psychopy and rusocsci&lt;br /&gt;
 from psychopy import core, visual from rusocsci import buttonbox&lt;br /&gt;
&lt;br /&gt;
 ##Setup Section&lt;br /&gt;
 win = visual.Window(monitor=&amp;quot;testMonitor&amp;quot;) bb = buttonbox.Buttonbox() text = visual.TextStim(win, &amp;quot;Press a button on the buttonbox&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 ##Experiment Section&lt;br /&gt;
 #show text&lt;br /&gt;
 text.draw() win.flip()&lt;br /&gt;
 #wait for response&lt;br /&gt;
 b = bb.waitButtons()&lt;br /&gt;
 #show response&lt;br /&gt;
 text.setText(&amp;quot;you pressed: {}&amp;quot;.format(b)) text.draw() win.flip() core.wait(5)&lt;br /&gt;
&lt;br /&gt;
 ##Cleanup Section&lt;br /&gt;
 core.quit() &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Matlab Settings ==&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 ===================================================================================================&lt;br /&gt;
 function handle = serial_buttonbox_common(cmd,varargin)&lt;br /&gt;
 % to initialize connection:&lt;br /&gt;
 % handle = serial_buttonbox('open',se)&lt;br /&gt;
 % settings (se):&lt;br /&gt;
 % define settings as a structure, i.e.:&lt;br /&gt;
 % se.Device = 'COM1';&lt;br /&gt;
 % se.BaudRate = 115200;&lt;br /&gt;
 % se.DataBits = 8;&lt;br /&gt;
 % se.StopBits = 1;&lt;br /&gt;
 % se.Parity = 0;&lt;br /&gt;
 % se.PTBPath = 'c:\MyToolboxes\PsychToolbox'&lt;br /&gt;
 %&lt;br /&gt;
 % to close the connection:&lt;br /&gt;
 % serial_buttonbox('close',handle);&lt;br /&gt;
 &lt;br /&gt;
 persistent old_hdl&lt;br /&gt;
 &lt;br /&gt;
 % set defaults&lt;br /&gt;
 se.Device = 'COM1';&lt;br /&gt;
 se.BaudRate = 115200;&lt;br /&gt;
 se.DataBits = 8;&lt;br /&gt;
 se.StopBits = 1;&lt;br /&gt;
 se.Parity = 0;&lt;br /&gt;
 se.PTBPath = 'c:\Pgrogram Files\PsychToolbox';&lt;br /&gt;
 &lt;br /&gt;
 if nargin &amp;lt; 1&lt;br /&gt;
 cmd = 'open';&lt;br /&gt;
 end&lt;br /&gt;
 if nargin &amp;gt; 1&lt;br /&gt;
 % user overwrites default settings&lt;br /&gt;
 flds = fields(varargin{1});&lt;br /&gt;
 for n = 1 : numel(flds)&lt;br /&gt;
 se.(flds{n}) = varargin{1}.(flds{n});&lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 switch cmd&lt;br /&gt;
 case 'open'&lt;br /&gt;
 addpath(genpath(se.PTBPath));&lt;br /&gt;
 % get handle to serial device&lt;br /&gt;
 handle = open_buttonbox(se.Device);&lt;br /&gt;
 return&lt;br /&gt;
 case 'close'&lt;br /&gt;
 handle = varargin{1};&lt;br /&gt;
 IOPort('close',handle);&lt;br /&gt;
 return&lt;br /&gt;
 case 'run'&lt;br /&gt;
 % read incoming data&lt;br /&gt;
 if isempty(old_hdl)&lt;br /&gt;
 help serial_buttonbox_common&lt;br /&gt;
 error('Buttonbox not yet initialized');&lt;br /&gt;
 end&lt;br /&gt;
 handle = old_hdl;&lt;br /&gt;
 otherwise&lt;br /&gt;
 fprintf('Unknown option %s\n',cmd);&lt;br /&gt;
 return&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 % only gets here when cmd = 'run'&lt;br /&gt;
 while 1 &lt;br /&gt;
 % start polling for characters (indicating start of scan)&lt;br /&gt;
 navailable = IOPort('BytesAvailable', handle);&lt;br /&gt;
 if navailable&lt;br /&gt;
 data = [];&lt;br /&gt;
 while navailable&lt;br /&gt;
 % read incoming data&lt;br /&gt;
 [newdata, ~, err] = IOPort('Read', handle, 0, navailable);&lt;br /&gt;
 if ~isempty(err), disp(err); end&lt;br /&gt;
 data = [data newdata];&lt;br /&gt;
 %pause(0.001); % if possible just add a small pause to not claim entire core&lt;br /&gt;
 navailable = IOPort('BytesAvailable', handle);&lt;br /&gt;
 end&lt;br /&gt;
 if numel(data)&amp;gt;1&lt;br /&gt;
 fprintf('\nReceived characters: %d\n',numel(data));&lt;br /&gt;
 end&lt;br /&gt;
 for n = 1 : numel(data)&lt;br /&gt;
 % disp(char(data(n)));&lt;br /&gt;
 fprintf('incoming: %d\t%s\n',data(n),char(data(n)));&lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 end %while 1&lt;br /&gt;
 &lt;br /&gt;
 function hdl = open_buttonbox(device)&lt;br /&gt;
 % open handle to serial device (mini buttonbox)&lt;br /&gt;
 try&lt;br /&gt;
 hdl = IOPort('OpenSerialPort',device,['BaudRate=' num2str(se.BaudRate)]);&lt;br /&gt;
 catch&lt;br /&gt;
 if ~isempty(old_hdl)&lt;br /&gt;
 IOPort('close',old_hdl);&lt;br /&gt;
 end&lt;br /&gt;
 hdl = IOPort('OpenSerialPort',device,['BaudRate=' num2str(se.BaudRate)]);&lt;br /&gt;
 end&lt;br /&gt;
 old_hdl = hdl;&lt;br /&gt;
 &lt;br /&gt;
 fprintf('Wait for device buttonbox....\n');&lt;br /&gt;
 tic&lt;br /&gt;
 while ~IOPort('BytesAvailable', hdl) &amp;amp;&amp;amp; toc&amp;lt;10&lt;br /&gt;
 % wait for welcome message device&lt;br /&gt;
 end&lt;br /&gt;
 pause(0.5);&lt;br /&gt;
 &lt;br /&gt;
 % clear buffer&lt;br /&gt;
 %IOPort('flush', hdl);&lt;br /&gt;
 IOPort('purge', hdl);&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 end&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>131.174.202.225</name></author>
	</entry>
	<entry>
		<id>http://tsgdoc.socsci.ru.nl/index.php?title=ButtonBox&amp;diff=336</id>
		<title>ButtonBox</title>
		<link rel="alternate" type="text/html" href="http://tsgdoc.socsci.ru.nl/index.php?title=ButtonBox&amp;diff=336"/>
		<updated>2014-04-30T08:07:15Z</updated>

		<summary type="html">&lt;p&gt;131.174.202.225: nowiki -&amp;gt; source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== General ==&lt;br /&gt;
&lt;br /&gt;
The buttonbox is used for time accurate(1ms) button press registration. We use it to register buttonpresses, soundkey, voicekey signals and to send tone onset, analog output, triggers with the BITSI protocol. It is suitable for Behavioral, EEG, MEG, and fMRI experiments.&amp;amp;nbsp;The buttonbox is connected to a computer with a usb connection.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[File:foto 1small.jpg|200px|Image: 200 pixels]]&lt;br /&gt;
| [[File:foto 2 small.jpg|200px|Image: 200 pixels]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The output connector has two binary eight bit ports: input and output. The two ports can be used for responses (input) and stimulus triggers (output). Two 8 bits analog outputs and three 8 bits analog inputs. The output connector has a sound and voicekey which triggers when a amplitude reaches a threshold. By using the serial port, the BITSI can be used platform independently: it works on Windows, Linux and Mac OSX. Most programming environments and stimulus packages support serial communication.&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
== BITSI Protocol ==&lt;br /&gt;
&lt;br /&gt;
BITSI stands for Bits to Serial Interface. Because the BITSI is designed to interface both in- and output signals, the 'protocol' is asymmetric: the input and output protocols differ.&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;'''Input'''&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The input port can be used to interface eight buttons maximally. Button presses are translated to serial output characters/bytes according to the following table:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;0&amp;quot; width=&amp;quot;462&amp;quot; style=&amp;quot;width:462px;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
'''Signal / Button'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
'''ASCII''' (rising / falling)&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
'''Code''' (rising / falling)&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
1&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
A / a&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
65 / 97&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
2&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
B / b&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
66 / 98&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
3&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
C / c&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
67 / 99&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
4&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
D / d&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
68 / 100&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
5&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
E / e&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
69 / 101&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
6&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
F / f&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
70 / 102&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
7&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
G / g&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
71 / 103&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
8&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
H / h&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
72 / 104&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
SoundKey&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
S / s&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
83 / 115&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
VoiceKey&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
V / v&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
86 / 118&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This means that when signal 1 gets /activated?, a capital A will be sent to the serial port. A lowercase 'a' will be sent when the signal is deactivated?. Mechanical buttons can be connected directly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;'''Output'''&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output knows two protocols: BITSI simple or BITSI extended. To enter a certain protocol two buttons have to be pressed when the BITSIbox is powered. Press button H and A for simple mode and H and B for extended mode.&lt;br /&gt;
&lt;br /&gt;
If no button is pressed when powered it boots the last known protocol. In the simple protocol every byte sent to the BITSI over the serial port, is represented at the 8 bit output.&lt;br /&gt;
&lt;br /&gt;
The '''extended''' protocol uses two bytes?, this combination can access two analog outputs and a tone generator. The first byte selects the output. The second byte determines the value written to this output.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;0&amp;quot; width=&amp;quot;434&amp;quot; style=&amp;quot;width:434px;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
'''Function'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
'''Byte 1 (ASCII / code)'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
'''Byte 2'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Marker out&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
M / 77&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
Marker value&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Analog out 1&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
Y / 89&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
Analog output value&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Analog out 2&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
Z / 90&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
Analog output value&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Tone&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
T / 84&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
Start tone&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Detect Sound&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
D&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
S / 83&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Detect Voice&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
D /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
V / 83&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Calibrate Sound&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
C /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
S&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Calibrate Voice&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
C /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
V&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Analog in 1&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
A /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
1&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Analog in 2&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
A /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
2&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Analog in 3&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
A /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
3&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Analog in 4&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
A /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
4&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
LEDs off&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
L /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
X&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
LEDs input&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
L /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
I&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
LEDs output&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
L /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
O&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;'''Trigger port settings'''&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Connector.png|300x300px|Connector.png]]&lt;br /&gt;
&lt;br /&gt;
The 25 pins female connector has 8 inputs and 8 outputs, respectively 1-8 are inputs and 9-16 are outputs. Three analog input with an analog to digital convertor of 12 bit, pins 17,18,20 and 21. Two analog outputs with an digital to analog convertor of 12 bits on pins 22 and 23.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;'''Serial port settings'''&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our hardware design allows to be connected to the computers USB and emulates a serial [[Port]].&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;0&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
'''Baudrate'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:69px;&amp;quot; | &lt;br /&gt;
115200&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
'''Parity'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:69px;&amp;quot; | &lt;br /&gt;
none&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
'''Data bits'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:69px;&amp;quot; | &lt;br /&gt;
8&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
'''Stop bits'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:69px;&amp;quot; | &lt;br /&gt;
1&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
'''Flow control'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:69px;&amp;quot; | &lt;br /&gt;
none&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== USB-Com port settings ==&lt;br /&gt;
&lt;br /&gt;
1.Connect the BITSIbox to your computer using the USB cable.&lt;br /&gt;
&lt;br /&gt;
2.When you connect the BITSIbox, Windows should initiate the driver installation process (if you haven't used the computer with an BITSIbox board before).&lt;br /&gt;
&lt;br /&gt;
3.On Windows Vista/7, the driver should be automatically downloaded and installed.&lt;br /&gt;
&lt;br /&gt;
4.On Windows XP, the Add New Hardware wizard will open:&lt;br /&gt;
&lt;br /&gt;
*When asked&amp;amp;nbsp;'''Can Windows connect to Windows Update to search for software?'''&amp;amp;nbsp;select&amp;amp;nbsp;'''No, not this time'''. Click next.&lt;br /&gt;
*Select&amp;amp;nbsp;'''Install from a list or specified location (Advanced)'''&amp;amp;nbsp;and click next.&lt;br /&gt;
*Make sure that&amp;amp;nbsp;'''Search for the best driver in these locations'''&amp;amp;nbsp;is checked; uncheck&amp;amp;nbsp;'''Search removable media'''; check&amp;amp;nbsp;'''Include this location in the search'''&amp;amp;nbsp;and browse to the&amp;amp;nbsp;'''c:/beheer/arduino/drivers '''directory.&lt;br /&gt;
*The wizard will search for the driver and then tell you that a &amp;quot;USB Serial Converter&amp;quot; was found. Click finish.&lt;br /&gt;
*The new hardware wizard will appear again. Go through the same steps and select the same options and location to search. This time, a &amp;quot;USB Serial Port&amp;quot; will be found.&lt;br /&gt;
&lt;br /&gt;
'''How to Check the Com Port settings(important!)'''&lt;br /&gt;
&lt;br /&gt;
*From the Start menu, open the '''Control Panel'''.&lt;br /&gt;
&lt;br /&gt;
*From the control panel, open the '''System window'''.&lt;br /&gt;
&lt;br /&gt;
*From the system properties window, go to the '''Hardware tab''' and click the '''Device Manager''' button.&lt;br /&gt;
&lt;br /&gt;
*From the Device Manager window, click '''Ports (Com&amp;amp;LPT).''' You should now be able to see which Com Port the USB adapter is assigned to.&lt;br /&gt;
&lt;br /&gt;
*If the Com Port is 10 or higher, you will have to change it to a lower port.&lt;br /&gt;
&lt;br /&gt;
*From the Device Manager window, click on '''USB Serial Port (Com#).''' Click the '''Port Settings tab''' of the USB Serial Port Properties window, and then click the '''Advanced''' button.&lt;br /&gt;
&lt;br /&gt;
*In the Advanced Settings window, use the scroll input to select a '''Com Port''' (select 10 or lower). Change '''Receive (bytes)''' and '''Transmit (bytes)''' to 64. Change the '''Latency Timer''' to 1.&lt;br /&gt;
&lt;br /&gt;
*Click the OK button.&lt;br /&gt;
&lt;br /&gt;
Always connect the usb device to the same port and your settings will be remembered.&lt;br /&gt;
&lt;br /&gt;
== TSG ButtonBox hardware 2013 ==&lt;br /&gt;
&lt;br /&gt;
Find the hardware design here&amp;amp;nbsp;[[Buttonbox 2013 Hardware|Buttonbox_2013_Hardware]]&lt;br /&gt;
&lt;br /&gt;
== TSG ButtonBox software 2013 ==&lt;br /&gt;
&lt;br /&gt;
Find the code here [[Media:BITSI_tempalte2013_duemilanove.zip]]&lt;br /&gt;
&lt;br /&gt;
== Presentation Settings ==&lt;br /&gt;
&lt;br /&gt;
The experiment files needs a few settings for the device to work:&lt;br /&gt;
* In the settings tab:  port -&amp;gt; input port -&amp;gt; 1 must be the device that identifies itself as &amp;quot;Arduino Uno&amp;quot; in the device manager. Note that the port must have a number not higher than 10 (COM1-COM10). Use re-enumerate if it is higher.&lt;br /&gt;
* Rate must be set 115200, Parity to None, Data Bits to 8 and Stop Bits to 1, Uncheck FIFO Interrupt.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[File:Buttonbox1.png]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Buttonbox in Python and PsychoPy ==&lt;br /&gt;
&lt;br /&gt;
Example using the buttonbox in Python: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
# import the rusocsci.buttonbox module&lt;br /&gt;
from rusocsci import buttonbox import logging, time&lt;br /&gt;
&lt;br /&gt;
# make a buttonbox&lt;br /&gt;
bb = buttonbox.Buttonbox()&lt;br /&gt;
&lt;br /&gt;
# wait for a single button press&lt;br /&gt;
b = bb.waitButtons() &lt;br /&gt;
&lt;br /&gt;
# print the button pressed&lt;br /&gt;
print(&amp;quot;b: {}&amp;quot;.format(b))&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using the Buttonbox in PsychoPy:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
# import psychopy and rusocsci&lt;br /&gt;
from psychopy import core, visual&lt;br /&gt;
from rusocsci import buttonbox&lt;br /&gt;
&lt;br /&gt;
## Setup Section&lt;br /&gt;
win = visual.Window(monitor=&amp;quot;testMonitor&amp;quot;) &lt;br /&gt;
bb = buttonbox.Buttonbox()&lt;br /&gt;
text = visual.TextStim(win, &amp;quot;Press a button on the buttonbox&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
## Experiment Section&lt;br /&gt;
# show text&lt;br /&gt;
text.draw()&lt;br /&gt;
win.flip()&lt;br /&gt;
# wait for response&lt;br /&gt;
b = bb.waitButtons() &lt;br /&gt;
# show response&lt;br /&gt;
text.setText(&amp;quot;you pressed: {}&amp;quot;.format(b))&lt;br /&gt;
text.draw()&lt;br /&gt;
win.flip()&lt;br /&gt;
core.wait(5)&lt;br /&gt;
&lt;br /&gt;
##Cleanup Section&lt;br /&gt;
core.quit()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
== Matlab Settings ==&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 ===================================================================================================&lt;br /&gt;
 function handle = serial_buttonbox_common(cmd,varargin)&lt;br /&gt;
 % to initialize connection:&lt;br /&gt;
 % handle = serial_buttonbox('open',se)&lt;br /&gt;
 % settings (se):&lt;br /&gt;
 % define settings as a structure, i.e.:&lt;br /&gt;
 % se.Device = 'COM1';&lt;br /&gt;
 % se.BaudRate = 115200;&lt;br /&gt;
 % se.DataBits = 8;&lt;br /&gt;
 % se.StopBits = 1;&lt;br /&gt;
 % se.Parity = 0;&lt;br /&gt;
 % se.PTBPath = 'c:\MyToolboxes\PsychToolbox'&lt;br /&gt;
 %&lt;br /&gt;
 % to close the connection:&lt;br /&gt;
 % serial_buttonbox('close',handle);&lt;br /&gt;
 &lt;br /&gt;
 persistent old_hdl&lt;br /&gt;
 &lt;br /&gt;
 % set defaults&lt;br /&gt;
 se.Device = 'COM1';&lt;br /&gt;
 se.BaudRate = 115200;&lt;br /&gt;
 se.DataBits = 8;&lt;br /&gt;
 se.StopBits = 1;&lt;br /&gt;
 se.Parity = 0;&lt;br /&gt;
 se.PTBPath = 'c:\Pgrogram Files\PsychToolbox';&lt;br /&gt;
 &lt;br /&gt;
 if nargin &amp;lt; 1&lt;br /&gt;
 cmd = 'open';&lt;br /&gt;
 end&lt;br /&gt;
 if nargin &amp;gt; 1&lt;br /&gt;
 % user overwrites default settings&lt;br /&gt;
 flds = fields(varargin{1});&lt;br /&gt;
 for n = 1 : numel(flds)&lt;br /&gt;
 se.(flds{n}) = varargin{1}.(flds{n});&lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 switch cmd&lt;br /&gt;
 case 'open'&lt;br /&gt;
 addpath(genpath(se.PTBPath));&lt;br /&gt;
 % get handle to serial device&lt;br /&gt;
 handle = open_buttonbox(se.Device);&lt;br /&gt;
 return&lt;br /&gt;
 case 'close'&lt;br /&gt;
 handle = varargin{1};&lt;br /&gt;
 IOPort('close',handle);&lt;br /&gt;
 return&lt;br /&gt;
 case 'run'&lt;br /&gt;
 % read incoming data&lt;br /&gt;
 if isempty(old_hdl)&lt;br /&gt;
 help serial_buttonbox_common&lt;br /&gt;
 error('Buttonbox not yet initialized');&lt;br /&gt;
 end&lt;br /&gt;
 handle = old_hdl;&lt;br /&gt;
 otherwise&lt;br /&gt;
 fprintf('Unknown option %s\n',cmd);&lt;br /&gt;
 return&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 % only gets here when cmd = 'run'&lt;br /&gt;
 while 1 &lt;br /&gt;
 % start polling for characters (indicating start of scan)&lt;br /&gt;
 navailable = IOPort('BytesAvailable', handle);&lt;br /&gt;
 if navailable&lt;br /&gt;
 data = [];&lt;br /&gt;
 while navailable&lt;br /&gt;
 % read incoming data&lt;br /&gt;
 [newdata, ~, err] = IOPort('Read', handle, 0, navailable);&lt;br /&gt;
 if ~isempty(err), disp(err); end&lt;br /&gt;
 data = [data newdata];&lt;br /&gt;
 %pause(0.001); % if possible just add a small pause to not claim entire core&lt;br /&gt;
 navailable = IOPort('BytesAvailable', handle);&lt;br /&gt;
 end&lt;br /&gt;
 if numel(data)&amp;gt;1&lt;br /&gt;
 fprintf('\nReceived characters: %d\n',numel(data));&lt;br /&gt;
 end&lt;br /&gt;
 for n = 1 : numel(data)&lt;br /&gt;
 % disp(char(data(n)));&lt;br /&gt;
 fprintf('incoming: %d\t%s\n',data(n),char(data(n)));&lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 end %while 1&lt;br /&gt;
 &lt;br /&gt;
 function hdl = open_buttonbox(device)&lt;br /&gt;
 % open handle to serial device (mini buttonbox)&lt;br /&gt;
 try&lt;br /&gt;
 hdl = IOPort('OpenSerialPort',device,['BaudRate=' num2str(se.BaudRate)]);&lt;br /&gt;
 catch&lt;br /&gt;
 if ~isempty(old_hdl)&lt;br /&gt;
 IOPort('close',old_hdl);&lt;br /&gt;
 end&lt;br /&gt;
 hdl = IOPort('OpenSerialPort',device,['BaudRate=' num2str(se.BaudRate)]);&lt;br /&gt;
 end&lt;br /&gt;
 old_hdl = hdl;&lt;br /&gt;
 &lt;br /&gt;
 fprintf('Wait for device buttonbox....\n');&lt;br /&gt;
 tic&lt;br /&gt;
 while ~IOPort('BytesAvailable', hdl) &amp;amp;&amp;amp; toc&amp;lt;10&lt;br /&gt;
 % wait for welcome message device&lt;br /&gt;
 end&lt;br /&gt;
 pause(0.5);&lt;br /&gt;
 &lt;br /&gt;
 % clear buffer&lt;br /&gt;
 %IOPort('flush', hdl);&lt;br /&gt;
 IOPort('purge', hdl);&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 end&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>131.174.202.225</name></author>
	</entry>
	<entry>
		<id>http://tsgdoc.socsci.ru.nl/index.php?title=ButtonBox&amp;diff=334</id>
		<title>ButtonBox</title>
		<link rel="alternate" type="text/html" href="http://tsgdoc.socsci.ru.nl/index.php?title=ButtonBox&amp;diff=334"/>
		<updated>2014-04-30T08:05:11Z</updated>

		<summary type="html">&lt;p&gt;131.174.202.225: improved examples&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== General ==&lt;br /&gt;
&lt;br /&gt;
The buttonbox is used for time accurate(1ms) button press registration. We use it to register buttonpresses, soundkey, voicekey signals and to send tone onset, analog output, triggers with the BITSI protocol. It is suitable for Behavioral, EEG, MEG, and fMRI experiments.&amp;amp;nbsp;The buttonbox is connected to a computer with a usb connection.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[File:foto 1small.jpg|200px|Image: 200 pixels]]&lt;br /&gt;
| [[File:foto 2 small.jpg|200px|Image: 200 pixels]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The output connector has two binary eight bit ports: input and output. The two ports can be used for responses (input) and stimulus triggers (output). Two 8 bits analog outputs and three 8 bits analog inputs. The output connector has a sound and voicekey which triggers when a amplitude reaches a threshold. By using the serial port, the BITSI can be used platform independently: it works on Windows, Linux and Mac OSX. Most programming environments and stimulus packages support serial communication.&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
== BITSI Protocol ==&lt;br /&gt;
&lt;br /&gt;
BITSI stands for Bits to Serial Interface. Because the BITSI is designed to interface both in- and output signals, the 'protocol' is asymmetric: the input and output protocols differ.&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;'''Input'''&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The input port can be used to interface eight buttons maximally. Button presses are translated to serial output characters/bytes according to the following table:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;0&amp;quot; width=&amp;quot;462&amp;quot; style=&amp;quot;width:462px;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
'''Signal / Button'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
'''ASCII''' (rising / falling)&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
'''Code''' (rising / falling)&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
1&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
A / a&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
65 / 97&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
2&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
B / b&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
66 / 98&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
3&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
C / c&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
67 / 99&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
4&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
D / d&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
68 / 100&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
5&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
E / e&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
69 / 101&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
6&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
F / f&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
70 / 102&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
7&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
G / g&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
71 / 103&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
8&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
H / h&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
72 / 104&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
SoundKey&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
S / s&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
83 / 115&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:113px;height:22px;&amp;quot; | &lt;br /&gt;
VoiceKey&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:170px;height:22px;&amp;quot; | &lt;br /&gt;
V / v&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:180px;height:22px;&amp;quot; | &lt;br /&gt;
86 / 118&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This means that when signal 1 gets /activated?, a capital A will be sent to the serial port. A lowercase 'a' will be sent when the signal is deactivated?. Mechanical buttons can be connected directly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;'''Output'''&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output knows two protocols: BITSI simple or BITSI extended. To enter a certain protocol two buttons have to be pressed when the BITSIbox is powered. Press button H and A for simple mode and H and B for extended mode.&lt;br /&gt;
&lt;br /&gt;
If no button is pressed when powered it boots the last known protocol. In the simple protocol every byte sent to the BITSI over the serial port, is represented at the 8 bit output.&lt;br /&gt;
&lt;br /&gt;
The '''extended''' protocol uses two bytes?, this combination can access two analog outputs and a tone generator. The first byte selects the output. The second byte determines the value written to this output.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;0&amp;quot; width=&amp;quot;434&amp;quot; style=&amp;quot;width:434px;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
'''Function'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
'''Byte 1 (ASCII / code)'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
'''Byte 2'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Marker out&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
M / 77&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
Marker value&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Analog out 1&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
Y / 89&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
Analog output value&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Analog out 2&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
Z / 90&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
Analog output value&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Tone&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
T / 84&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
Start tone&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Detect Sound&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
D&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
S / 83&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Detect Voice&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
D /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
V / 83&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Calibrate Sound&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
C /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
S&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Calibrate Voice&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
C /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
V&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Analog in 1&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
A /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
1&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Analog in 2&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
A /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
2&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Analog in 3&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
A /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
3&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
Analog in 4&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
A /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
4&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
LEDs off&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
L /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
X&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
LEDs input&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
L /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
I&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:122px;height:22px;&amp;quot; | &lt;br /&gt;
LEDs output&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:161px;height:22px;&amp;quot; | &lt;br /&gt;
L /&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:151px;height:22px;&amp;quot; | &lt;br /&gt;
O&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;'''Trigger port settings'''&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Connector.png|300x300px|Connector.png]]&lt;br /&gt;
&lt;br /&gt;
The 25 pins female connector has 8 inputs and 8 outputs, respectively 1-8 are inputs and 9-16 are outputs. Three analog input with an analog to digital convertor of 12 bit, pins 17,18,20 and 21. Two analog outputs with an digital to analog convertor of 12 bits on pins 22 and 23.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;'''Serial port settings'''&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our hardware design allows to be connected to the computers USB and emulates a serial [[Port]].&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;0&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
'''Baudrate'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:69px;&amp;quot; | &lt;br /&gt;
115200&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
'''Parity'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:69px;&amp;quot; | &lt;br /&gt;
none&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
'''Data bits'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:69px;&amp;quot; | &lt;br /&gt;
8&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
'''Stop bits'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:69px;&amp;quot; | &lt;br /&gt;
1&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
'''Flow control'''&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width:69px;&amp;quot; | &lt;br /&gt;
none&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== USB-Com port settings ==&lt;br /&gt;
&lt;br /&gt;
1.Connect the BITSIbox to your computer using the USB cable.&lt;br /&gt;
&lt;br /&gt;
2.When you connect the BITSIbox, Windows should initiate the driver installation process (if you haven't used the computer with an BITSIbox board before).&lt;br /&gt;
&lt;br /&gt;
3.On Windows Vista/7, the driver should be automatically downloaded and installed.&lt;br /&gt;
&lt;br /&gt;
4.On Windows XP, the Add New Hardware wizard will open:&lt;br /&gt;
&lt;br /&gt;
*When asked&amp;amp;nbsp;'''Can Windows connect to Windows Update to search for software?'''&amp;amp;nbsp;select&amp;amp;nbsp;'''No, not this time'''. Click next.&lt;br /&gt;
*Select&amp;amp;nbsp;'''Install from a list or specified location (Advanced)'''&amp;amp;nbsp;and click next.&lt;br /&gt;
*Make sure that&amp;amp;nbsp;'''Search for the best driver in these locations'''&amp;amp;nbsp;is checked; uncheck&amp;amp;nbsp;'''Search removable media'''; check&amp;amp;nbsp;'''Include this location in the search'''&amp;amp;nbsp;and browse to the&amp;amp;nbsp;'''c:/beheer/arduino/drivers '''directory.&lt;br /&gt;
*The wizard will search for the driver and then tell you that a &amp;quot;USB Serial Converter&amp;quot; was found. Click finish.&lt;br /&gt;
*The new hardware wizard will appear again. Go through the same steps and select the same options and location to search. This time, a &amp;quot;USB Serial Port&amp;quot; will be found.&lt;br /&gt;
&lt;br /&gt;
'''How to Check the Com Port settings(important!)'''&lt;br /&gt;
&lt;br /&gt;
*From the Start menu, open the '''Control Panel'''.&lt;br /&gt;
&lt;br /&gt;
*From the control panel, open the '''System window'''.&lt;br /&gt;
&lt;br /&gt;
*From the system properties window, go to the '''Hardware tab''' and click the '''Device Manager''' button.&lt;br /&gt;
&lt;br /&gt;
*From the Device Manager window, click '''Ports (Com&amp;amp;LPT).''' You should now be able to see which Com Port the USB adapter is assigned to.&lt;br /&gt;
&lt;br /&gt;
*If the Com Port is 10 or higher, you will have to change it to a lower port.&lt;br /&gt;
&lt;br /&gt;
*From the Device Manager window, click on '''USB Serial Port (Com#).''' Click the '''Port Settings tab''' of the USB Serial Port Properties window, and then click the '''Advanced''' button.&lt;br /&gt;
&lt;br /&gt;
*In the Advanced Settings window, use the scroll input to select a '''Com Port''' (select 10 or lower). Change '''Receive (bytes)''' and '''Transmit (bytes)''' to 64. Change the '''Latency Timer''' to 1.&lt;br /&gt;
&lt;br /&gt;
*Click the OK button.&lt;br /&gt;
&lt;br /&gt;
Always connect the usb device to the same port and your settings will be remembered.&lt;br /&gt;
&lt;br /&gt;
== TSG ButtonBox hardware 2013 ==&lt;br /&gt;
&lt;br /&gt;
Find the hardware design here&amp;amp;nbsp;[[Buttonbox 2013 Hardware|Buttonbox_2013_Hardware]]&lt;br /&gt;
&lt;br /&gt;
== TSG ButtonBox software 2013 ==&lt;br /&gt;
&lt;br /&gt;
Find the code here [[Media:BITSI_tempalte2013_duemilanove.zip]]&lt;br /&gt;
&lt;br /&gt;
== Presentation Settings ==&lt;br /&gt;
&lt;br /&gt;
The experiment files needs a few settings for the device to work:&lt;br /&gt;
* In the settings tab:  port -&amp;gt; input port -&amp;gt; 1 must be the device that identifies itself as &amp;quot;Arduino Uno&amp;quot; in the device manager. Note that the port must have a number not higher than 10 (COM1-COM10). Use re-enumerate if it is higher.&lt;br /&gt;
* Rate must be set 115200, Parity to None, Data Bits to 8 and Stop Bits to 1, Uncheck FIFO Interrupt.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[File:Buttonbox1.png]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Buttonbox in Python and PsychoPy ==&lt;br /&gt;
Example using the buttonbox in Python:&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
# import the rusocsci.buttonbox module&lt;br /&gt;
from rusocsci import buttonbox import logging, time&lt;br /&gt;
&lt;br /&gt;
# make a buttonbox&lt;br /&gt;
bb = buttonbox.Buttonbox()&lt;br /&gt;
&lt;br /&gt;
# wait for a single button press&lt;br /&gt;
b = bb.waitButtons() &lt;br /&gt;
&lt;br /&gt;
# print the button pressed&lt;br /&gt;
print(&amp;quot;b: {}&amp;quot;.format(b))&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using the Buttonbox in PsychoPy&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
# import psychopy and rusocsci&lt;br /&gt;
from psychopy import core, visual&lt;br /&gt;
from rusocsci import buttonbox&lt;br /&gt;
&lt;br /&gt;
## Setup Section&lt;br /&gt;
win = visual.Window(monitor=&amp;quot;testMonitor&amp;quot;) &lt;br /&gt;
bb = buttonbox.Buttonbox()&lt;br /&gt;
text = visual.TextStim(win, &amp;quot;Press a button on the buttonbox&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
## Experiment Section&lt;br /&gt;
# show text&lt;br /&gt;
text.draw()&lt;br /&gt;
win.flip()&lt;br /&gt;
# wait for response&lt;br /&gt;
b = bb.waitButtons() &lt;br /&gt;
# show response&lt;br /&gt;
text.setText(&amp;quot;you pressed: {}&amp;quot;.format(b))&lt;br /&gt;
text.draw()&lt;br /&gt;
win.flip()&lt;br /&gt;
core.wait(5)&lt;br /&gt;
&lt;br /&gt;
##Cleanup Section&lt;br /&gt;
core.quit()&lt;br /&gt;
&lt;br /&gt;
== Matlab Settings ==&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 ===================================================================================================&lt;br /&gt;
 function handle = serial_buttonbox_common(cmd,varargin)&lt;br /&gt;
 % to initialize connection:&lt;br /&gt;
 % handle = serial_buttonbox('open',se)&lt;br /&gt;
 %    settings (se):&lt;br /&gt;
 %       define settings as a structure, i.e.:&lt;br /&gt;
 %       se.Device    = 'COM1';&lt;br /&gt;
 %       se.BaudRate  = 115200;&lt;br /&gt;
 %       se.DataBits  = 8;&lt;br /&gt;
 %       se.StopBits  = 1;&lt;br /&gt;
 %       se.Parity    = 0;&lt;br /&gt;
 %       se.PTBPath   = 'c:\MyToolboxes\PsychToolbox'&lt;br /&gt;
 %&lt;br /&gt;
 % to close the connection:&lt;br /&gt;
 % serial_buttonbox('close',handle);&lt;br /&gt;
 &lt;br /&gt;
 persistent old_hdl&lt;br /&gt;
 &lt;br /&gt;
 % set defaults&lt;br /&gt;
 se.Device    = 'COM1';&lt;br /&gt;
 se.BaudRate  = 115200;&lt;br /&gt;
 se.DataBits  = 8;&lt;br /&gt;
 se.StopBits  = 1;&lt;br /&gt;
 se.Parity    = 0;&lt;br /&gt;
 se.PTBPath   = 'c:\Pgrogram Files\PsychToolbox';&lt;br /&gt;
 &lt;br /&gt;
 if nargin &amp;lt; 1&lt;br /&gt;
    cmd = 'open';&lt;br /&gt;
 end&lt;br /&gt;
 if nargin &amp;gt; 1&lt;br /&gt;
    % user overwrites default settings&lt;br /&gt;
    flds = fields(varargin{1});&lt;br /&gt;
    for n = 1 : numel(flds)&lt;br /&gt;
       se.(flds{n}) = varargin{1}.(flds{n});&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 switch cmd&lt;br /&gt;
    case 'open'&lt;br /&gt;
       addpath(genpath(se.PTBPath));&lt;br /&gt;
       % get handle to serial device&lt;br /&gt;
       handle = open_buttonbox(se.Device);&lt;br /&gt;
       return&lt;br /&gt;
    case 'close'&lt;br /&gt;
       handle = varargin{1};&lt;br /&gt;
       IOPort('close',handle);&lt;br /&gt;
       return&lt;br /&gt;
    case 'run'&lt;br /&gt;
       % read incoming data&lt;br /&gt;
       if isempty(old_hdl)&lt;br /&gt;
          help serial_buttonbox_common&lt;br /&gt;
          error('Buttonbox not yet initialized');&lt;br /&gt;
       end&lt;br /&gt;
       handle = old_hdl;&lt;br /&gt;
    otherwise&lt;br /&gt;
       fprintf('Unknown option %s\n',cmd);&lt;br /&gt;
       return&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 % only gets here when cmd = 'run'&lt;br /&gt;
 while 1  &lt;br /&gt;
    % start polling for characters (indicating start of scan)&lt;br /&gt;
    navailable = IOPort('BytesAvailable', handle);&lt;br /&gt;
    if navailable&lt;br /&gt;
       data = [];&lt;br /&gt;
       while navailable&lt;br /&gt;
          % read incoming data&lt;br /&gt;
          [newdata, ~, err] = IOPort('Read', handle, 0, navailable);&lt;br /&gt;
          if ~isempty(err), disp(err); end&lt;br /&gt;
          data = [data newdata];&lt;br /&gt;
          %pause(0.001); % if possible just add a small pause to not claim entire core&lt;br /&gt;
          navailable = IOPort('BytesAvailable', handle);&lt;br /&gt;
       end&lt;br /&gt;
       if numel(data)&amp;gt;1&lt;br /&gt;
          fprintf('\nReceived characters: %d\n',numel(data));&lt;br /&gt;
       end&lt;br /&gt;
       for n = 1 : numel(data)&lt;br /&gt;
 %        disp(char(data(n)));&lt;br /&gt;
          fprintf('incoming: %d\t%s\n',data(n),char(data(n)));&lt;br /&gt;
       end&lt;br /&gt;
    end&lt;br /&gt;
   &lt;br /&gt;
   &lt;br /&gt;
 end %while 1&lt;br /&gt;
 &lt;br /&gt;
    function hdl = open_buttonbox(device)&lt;br /&gt;
       % open handle to serial device (mini buttonbox)&lt;br /&gt;
       try&lt;br /&gt;
          hdl = IOPort('OpenSerialPort',device,['BaudRate=' num2str(se.BaudRate)]);&lt;br /&gt;
       catch&lt;br /&gt;
          if ~isempty(old_hdl)&lt;br /&gt;
             IOPort('close',old_hdl);&lt;br /&gt;
          end&lt;br /&gt;
          hdl = IOPort('OpenSerialPort',device,['BaudRate=' num2str(se.BaudRate)]);&lt;br /&gt;
       end&lt;br /&gt;
       old_hdl = hdl;&lt;br /&gt;
      &lt;br /&gt;
       fprintf('Wait for device buttonbox....\n');&lt;br /&gt;
       tic&lt;br /&gt;
       while ~IOPort('BytesAvailable', hdl) &amp;amp;&amp;amp; toc&amp;lt;10&lt;br /&gt;
          % wait for welcome message device&lt;br /&gt;
       end&lt;br /&gt;
       pause(0.5);&lt;br /&gt;
 &lt;br /&gt;
       % clear buffer&lt;br /&gt;
       %IOPort('flush', hdl);&lt;br /&gt;
       IOPort('purge', hdl);&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
 end&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>131.174.202.225</name></author>
	</entry>
</feed>