This chapter contains functions you can use to establish and control interactions and communication between different hardware devices. Devices can easily be controlled by using the bIO function or more fine grained using the feeding and punishment functions, when they have been specified correctly in myHardwareSetup.
This chapter contains functions you can use to establish and control interactions and communication between different hardware devices. Devices can easily be controlled by using the [bIO](/Device-interface#bio) function or more fine grained using the [feeding](/Device-interface#feeding-animal) and [punishment](/Device-interface#punishment-animal) functions, when they have been specified correctly in [myHardwareSetup](/Initialization#myhardwaresetup).
[[_TOC_]]
## bIO
function: out = bIO(pinNr, status, parEv)
function: out = [bIO(pinNr, status, parEv)](https://gitlab.ruhr-uni-bochum.de/ikn/OTBR/-/blob/master/IO/Interface3/bIO.m)
**Description**
Use this function to control single outputs/pins of supported hardware. In many cases the use of other functions like feeder, punishment or startExperiment is more useful and fine-grained. The bIO function can be used to turn on or turn off specific pins, which is helpful for programming or debugging an experiment in the office and for simulation of an experiment on your keyboard. To feature different hardware interactions change the option 2 in the function myHardwareSetup.m. Most frequently used hardware devices are implemented in the bIO function but it is not universal.
Use this function to control single outputs/pins of supported hardware. In many cases the use of other functions like [feeder](/Device-interface#feeding-animal), [punishment](/Device-interface#punishment-animal) or [startExperiment](/Initialization#startexperiment) is more useful and fine-grained. The [bIO](https://gitlab.ruhr-uni-bochum.de/ikn/OTBR/-/blob/master/IO/Interface3/bIO.m) function can be used to turn on or turn off specific pins, which is helpful for programming or debugging an experiment in the office and for simulation of an experiment on your keyboard. To feature different hardware interactions change the option 2 in the function [myHardwareSetup.m](https://gitlab.ruhr-uni-bochum.de/ikn/OTBR/-/blob/master/myHardwareSetup.m). Most frequently used hardware devices are implemented in the [bIO](https://gitlab.ruhr-uni-bochum.de/ikn/OTBR/-/blob/master/IO/Interface3/bIO.m) function but it is not universal.
The general functionality of bIO.m is as follows: bIO can be used with one argument, the number of an input-pin defined in myHardwareSetup. In this case it will read from this pin.
The general functionality of [bIO.m](https://gitlab.ruhr-uni-bochum.de/ikn/OTBR/-/blob/master/IO/Interface3/bIO.m) is as follows: [bIO](https://gitlab.ruhr-uni-bochum.de/ikn/OTBR/-/blob/master/IO/Interface3/bIO.m) can be used with one argument, the number of an input-pin defined in [myHardwareSetup](/Initialization#myhardwaresetup). In this case it will read from this pin.
It can be used with two arguments, an output-pin defined in myHardwareSetup and a status (0/1). In this case it will switch this pin on/off.
It can be used with two arguments, an output-pin defined in [myHardwareSetup](/Initialization#myhardwaresetup) and a status (0/1). In this case it will switch this pin on/off.
A third argument can be used to send an event-code, for example for electrophysiology. Event-codes are especially useful for precisely timed extra information such as trial descriptions. This will work only with the parallel port interface. For further information see how-to section 2.4. Event-codes. Please contact us if you have any more questions: biopsytoolbox@ruhr-uni-bochum.de.
A third argument can be used to send an [event-code](/How-tos#event-codes), for example for electrophysiology. [Event-codes](/How-tos#event-codes) are especially useful for precisely timed extra information such as trial descriptions. This will work only with the parallel port interface. For further information see how-to [section 2.4. Event-codes](/How-tos#event-codes). Please contact us if you have any more questions: biopsytoolbox@ruhr-uni-bochum.de.
**Inputs**
~~~
...
...
@@ -33,7 +33,7 @@ A third argument can be used to send an event-code, for example for electrophysi
~~~
**Examples**
~~~
~~~matlab
1.bIO(1)
% displays status of pin 1
...
...
@@ -61,16 +61,16 @@ A third argument can be used to send an event-code, for example for electrophysi
function: result = [feeding(time,varargin)](https://gitlab.ruhr-uni-bochum.de/ikn/OTBR/-/blob/master/IO/feeding.m)
**Description**
This is a helper function that is useful as a reward after a task was successfully finished. This function uses the feeder specified in myHardwareSetup to feed the animal and clears the screen automatically. More than one feeder is supported, but they have to be specified. During feeding the behavioral responses of the animal are recorded and available in the output variable.
This is a helper function that is useful as a reward after a task was successfully finished. This function uses the feeder specified in [myHardwareSetup](/Initialization#myhardwaresetup) to feed the animal and clears the screen automatically. More than one feeder is supported, but they have to be specified. During feeding the behavioral responses of the animal are recorded and available in the output variable.
In addition feeding turns on the feeding light if defined in myHardwareSetup.m. The optional argument 'noLight' avoids the feeding light.
In addition feeding turns on the feeding light if defined in [myHardwareSetup.m](https://gitlab.ruhr-uni-bochum.de/ikn/OTBR/-/blob/master/myHardwareSetup.m). The optional argument 'noLight' avoids the feeding light.
**Inputs**
~~~
...
...
@@ -79,16 +79,16 @@ In addition feeding turns on the feeding light if defined in myHardwareSetup.m.
**Inputs-optional**
~~~
varargin ‘feeder’ Defines a specific feeder to use for feeding (followed by feeder number).
varargin 'feeder' Defines a specific feeder to use for feeding (followed by feeder number).
Useful if more than one feeder is available.
The number that is used as argument is the index that
points to the pin number, given in section 3 of myHardwareSetup.
‘dontClear’ keeps the content on the screen.
'dontClear' keeps the content on the screen.
‘noLight’ ignores the feeding light if available.
'noLight' ignores the feeding light if available.
‘lightdur’ duration of the feeding light (useful if feeding is set to amount in myHardwareSetup)
'lightdur' duration of the feeding light (useful if feeding is set to amount in myHardwareSetup)
~~~
**Outputs**
...
...
@@ -97,7 +97,7 @@ In addition feeding turns on the feeding light if defined in myHardwareSetup.m.
~~~
**Examples**
~~~
~~~matlab
1.result=feeding(time,varargin)
2.result=feeding(5);
...
...
@@ -119,17 +119,17 @@ In addition feeding turns on the feeding light if defined in myHardwareSetup.m.
function: result = [punishment(time, varargin)](https://gitlab.ruhr-uni-bochum.de/ikn/OTBR/-/blob/master/IO/punishment.m)
**Description**
Use this function for punishment if a task wasn't successfully finished. During punishment the answers of the animal are recorded and available in the output variable. This function uses three options for punishment implicitly (all are defined in myHardwareSetup/ myParadigmSetup):
Use this function for punishment if a task wasn't successfully finished. During punishment the answers of the animal are recorded and available in the output variable. This function uses three options for punishment implicitly (all are defined in [myHardwareSetup](/Initialization#myhardwaresetup)/ [myParadigmSetup](/Initialization#myparadigmsetup)):
1. if specified in section (3) in myHardwareSetup a device is used
2. if specified in section (6) in myParadigmSetup a stimulus is presented
1. if specified in section (3) in [myHardwareSetup](https://gitlab.ruhr-uni-bochum.de/ikn/OTBR/-/blob/master/myHardwareSetup.m) a device is used
2. if specified in section (6) in [myParadigmSetup](https://gitlab.ruhr-uni-bochum.de/ikn/OTBR/-/blob/master/myParadigmSetup.m) a stimulus is presented
3. if nothing of the above is specified the houselight will be turned off as punishment
The screen is cleared, but can be kept by using an optional input argument (not if a punishment stimulus is shown!).
...
...
@@ -141,7 +141,7 @@ The screen is cleared, but can be kept by using an optional input argument (not
**Inputs-optional**
~~~
varargin ‘dontclear’ keeps the content on the screen.
varargin 'dontclear' keeps the content on the screen.
~~~
**Outputs**
...
...
@@ -150,7 +150,7 @@ The screen is cleared, but can be kept by using an optional input argument (not
~~~
**Examples**
~~~
~~~matlab
1.result=punishment(2);
% punishment for two seconds
...
...
@@ -160,20 +160,20 @@ The screen is cleared, but can be kept by using an optional input argument (not
Initializes network communication to Network-IO device. Call this function before using functions that need network interfaces. Usually this function is called internally by the bIO function and does not need to be called manually!
Initializes network communication to Network-IO device. Call this function before using functions that need network interfaces. Usually this function is called internally by the [bIO](/Device-interface#bio) function and does not need to be called manually!
Use this function to close the network connection to the network IO device. Usually this function is called internally by the stopExperiment function and does not need to be called manually.
Use this function to close the network connection to the network IO device. Usually this function is called internally by the [stopExperiment](/Initialization#stopexperiment) function and does not need to be called manually.