| Data Acquisition Toolbox | Search  Help Desk |
The Data Acquisition Session
The data acquisition session encompasses all actions you must take to perform the necessary tasks for your data acquisition application. A typical data acquisition session consists of these steps:.The device object is created and linked to a specific hardware device.
.Channels or lines are added to the device object, and property values are set to establish the desired behavior.
.The device object is started and it runs according to the previously set properties. At this time you can preview data, acquire data from an A/D subsystem, or send data to a D/A subsystem.
.The object is no longer needed and is deleted.
Initialization: Create the analog input object AI for a sound card. The installed adaptors and hardware ID's are found with daqhwinfo.
AI = analoginput('winsound');
%AI = analoginput('nidaq',1);
Configuration: Add two channels to AI, define a two second acquisition, and assign values for the basic setup properties. The actual sampling rate is retrieved since it may be set to a value that differs from the specified value.
Execution: Startaddchannel(AI, 1:2);%addchannel(AI, 0:1);duration = 2;set(AI, 'TriggerType', 'Immediate');set(AI, 'SampleRate', 8000);ActualRate = get(AI, 'SampleRate');set(AI, 'SamplesPerTrigger', duration*ActualRate);
AI, wait until AI stops running, and extract all data from the engine. Before start is issued, you may want to begin inputting data for a microphone or a CD player.
Termination: Plot the data and deletestart(AI)data = getdata(AI);
AI.
plot(data)
xlabel('Samples')
ylabel('Signal (volts)')
title('daqdoc2\_1')
delete(AI)
Initialization, configuration, execution, and termination are discussed in more detail below.