BioNB 442: Lab 4
Data Acquisition
Introduction.
You will connect Matlab to the outside world using the DAQ toolbox. You will
produce simple prototypes for an oscilloscope and signal generator.
Procedure:
- Download the simpleAI.m and simpleAO.m files from the DAQ
programming page. Notice that these programs use the computer sound port to connect to the outside world.
- The following code fragment detects a mouse-down event and draws a rubberband
box, then detects a mouse-up event and does a distance calculation. Play with
the code fragment by plotting some function then making measurements with
the mouse.
set(gcf,'WindowButtonDownFcn',...
['initialpt=get(gca,''currentpoint'');'...
'rect=rbbox;' ...
]);
set(gcf,'WindowButtonUpFcn',...
[...
'finalpt=get(gca,''currentpoint'');'...
'disp(finalpt(1,1)-initialpt(1,1));'...
]);
Assignment
- Modify simpleAI.m to include:
- a stop button (instead of just quitting after 50 times through the loop).
- two subplots, one for the waveform, one for the spectrum.
- a listbox interactor to choose a sample rate of 8.000 kHz, 11.025 kHz,
22.050 kHz, or 44.100 kHz.
- a listbox interactor to choose the duration of the sample collection
of .01, .02,.05, .1, or .2 seconds.
- a rubber-band box to measure the amplitude and time of the waveform
(and display them) after you press the stop button.
For testing, connect a wave generator (for instance daqfcngen
) to the sound input of the computer and
show that you can record the voltages produced by the generator. Verify that
a squarewave has a spectrum that drops off as 1/f. Use the multimedia control
panel to connect the computer's CD player to the sound input so you can look
at more complex signals. If you generate low frequencies of a few Hz, you will notice that square waves droop when viewed through the audio input. This is because the audio input on most PCs does not pass DC, or any low frequency. Estimate the cutoff frequency of the recording channel as 1/(2πτ)
where τ
is the time constant of dropoff of the square wave.
- Modify simpleAO.m to act like a physiological stimulator. It should:
- produce one pulse train every time you click a trigger button uicontrol.
- set three pulse train parameters with a slider or edit field:
- the number of pulses should vary from 1 to 10
- the pulse duration should vary from 1 mSec to 10 mSec.
- the pulse spacing should vary from 1 mSec to 10 mSec.
- the program should produce an error dialog if the spacing is less than
the duration.
For testing you will need to connect the sound output of the computer to an oscilloscope (for instance gPRIME
).
Your written lab report should include:
- A screen print of the GUI for 1 and 2 above.
- A commented listing for the modified simpleAI.m and simpleAO.m programs.
- Your estimate of the cutoff frequency of the recording channel.
July 2006 Copyright Cornell university