## Manual Setup

Design of experiments and Matlab programs for the sound-localization setups at the department of Biophysics, Donders Institute for Brain, Cognition and Behaviour.

UNDER CONSTRUCTION

# Setup

This experimental setup is custom-designed to precisely control the presentation of auditory and visual stimuli. Experimental parameters are set by the PC and fed trial by trial to a stand-alone microcontroller (custom made). The PC also transfers the sound WAV files (16 bits) to the real-time processor (TDT3 RP2.1; Tucker-Davis Technology), which generates the audio signal (48.828125 kHz sampling rate. This device ensures millisecond timing precision for data acquisition and stimulus selection. The speakers and LEDs are selected via an I2C bus (Philips) that is instructed by the microcontroller (LPC2109). LED and speaker specifications and tests can be found here and here.

# LOW-LEVEL

## Microcontroller

The Fart1.hex-program should be in the micro-controller's RAM. This is by default so, and you do not need to do anything.

In matlab, at the start of an experiment, the micro-controller needs to be initialized, like this:


pa_micro_globals; % initialize global constants for the microcontroller
timeout    = 100;
[com, msg]  = pa_micro_rs232(115200,timeout); % initialize COM
[info, msg] = pa_micro_cmd(com, cmdInfo, ''); % initialize micro-controller


pa_micro_cmd is used to control the microcontoller, important for determing which LEDs and speakers are turned on and off. ActiveX commands for the TDT system are used to play sounds and record data.

Dick loves to code with 'global constants', but this does not make sense in Matlab. Is it possible to remove these, or are there C-dependencies?

## TuckerDavisTechnology

Also the ActiveXcontrols for the TDT system need to be initialized at the start of an experiment, like this:

	circuitRP2 = 'C:\RPvsDX\soundlocalization.rco'; % the rco-circuit
[zBus err(1)]	= ZBUS(1); % number of racks
[RP2_1 err(2)]	= RP2(1,circuitRP2); % Real-time processor


Is there a default RCO?

There are several matlab-routines to initialize the TDT system modules:

• ZBUS
• RP2
• RA16
• PA5
• RA8GA

## Hoop

The motor that rotates the hoop also needs to be initialized (do you see a pattern?).

	hoop = pa_motor_init; % start your engines!	hoop = pa_motor_home(hoop); % home the hoop to 0


# Stimulus presentation

For every trial you need to:

• position the hoop
• start data acquisition
• present auditory or visual stimuli
• end the trial (by ending data acquisition or visual stimulus presentation

## Hoop

The hoop is rotated with the command:.

	hoop = pa_motor_pos(hoop,30); % move 30 deg to the right


## Data acquisition

Data acquisition (with the RA16) starts with

	%% start Acq
zBus.zBusTrigB(0,1,4); %% start acquisition


Does this depend on the physical connections or RCO? What about data acquisition with RP2 e.g. for HRTF

Usually, a stimulus is then presented, after which you wait until data acquisition is stopped:

%% Continue Acq
wait = true;
while wait
end
%% stop data acquisition
zBus.zBusTrigB(0,2,4);


The data should then be read and stored.

%% Initialization
Fs			= RA16_1.ReadTagV('Freq',0,1); % Sample frequency (Hz) of RA16 module
nChan 		= 8;
data 		= struct([]);
for ii = 1:nChan
data(ii).channel = RA16_1.ReadTagVEX(['Data_' num2str(ii)], 0, Nsample, 'F32', 'F64', 1);
end


This should then be stored in a file (with the default fwrite techniques in Matlab, or ideally with HDF5 access techniques).

## Sound

To play sounds (with RP2), you have to:

• write the sound-data to the RP2
• set the sound level (with DA channel 2)
• play the sound (by triggering the zBus)
• keep on playing
• stop the sound
%% Initialization
snd = randn(10000,1); % example
maxSamples	= length(snd);
stimSnd1	= 10;
%% Write data
RP2_1.WriteTagV('WavData', 0, snd(1:maxSamples));
%% Speaker on
RP2_1.SetTagVal('Level',level); % Set speaker level
arg		= sprintf('%d;%d;1',speaker,stimSnd1); % micro argument, 1 - speaker on
micro_cmd(com,cmdSpeaker,arg); % give command to microcontroller
%% Play sound
zBus.zBusTrigA(0,0,0); % start sound
busy 		= RP2_1.GetTagVal('Play'); % check sound playing
while busy
busy 	= RP2_1.GetTagVal('Play');
end % end sound
%%	Stop sound playing
RP2_1.SetTagVal('Level',0); % set level to 0
arg		= sprintf('%d;%d;0',speaker,stimSnd1); % 0 - speaker off
micro_cmd(com,cmdSpeaker,arg); % give command to microcontroller


## LED

LEDs can be turned on and off with the pa_micro_cmd command.

%% Start trial by showing LED
str		= sprintf('%d;%d;%d;%d;%d',stimLed,0,hoopled,255,1);
pa_micro_cmd(com,cmdStim,str);
str		= sprintf('%d;%d;%d;%d;%d',stimSky,0,1,255,1);
pa_micro_cmd(com,cmdStim,str);

%% End trial by extinguishing LED
str = sprintf('%d;%d;%d;%d;%d',stimLed,0,hoopled,0,0);
pa_micro_cmd(com,cmdStim,str);
str = sprintf('%d;%d;%d;%d;%d',stimSky,0,1,0,0);
pa_micro_cmd(com,cmdStim,str);



Which commands can be given to the pa_micro_cmd? The same as in the exp-file?

What else do we want? What kind of graphical user interface? Do we still want the exp-file/cfg-file system?

Reward? Online stimulus presentation? This was possible, but I am not sure which commands can be used.