Sie sind auf Seite 1von 2

DATA ACQUISITION

The data acquisition session consists of all the steps you are likely to take when acquiring or outputting data. These steps are: 1. Create a device object -- You create a device object using the analoginput, analogoutput, or digitalio creation function. Device objects are the basic toolbox elements you use to access your hardware device. 2. Add channels or lines -- After a device object is created, you must add channels or lines to it. Channels are added to analog input and analog output objects, while lines are added to digital I/O objects. Channels and lines are the basic hardware device elements with which you acquire or output data. 3. Configure properties -- To establish the device object behavior, you assign values to properties using the set function or dot notation. You can configure many of the properties at any time. However, some properties are configurable only when the device object is not running. Conversely, depending on your hardware settings and the requirements of your application, you might be able to accept the default property values and skip this step. 4. Acquire or output data -- To acquire or output data, you must execute the device object with the start function. While the device object is running, it behaves according to the previously configured or default property values. After data is acquired, you must extract it from the engine with the getdata function. Before you can output data, you must queue it in the engine with the putdata function. 5. Clean up -- When you no longer need the device object, you should remove it from memory using the delete function, and remove it from the MATLAB workspace using the clear command. Example: The Data Acquisition Session. This example illustrates the basic steps you take during a data acquisition session using an analog input object. Create a device object -- Create the analog input object AI for a nidaq card. AI = analoginput('nidaq',1); Add channels -- Add two channels to AI. addchannel(AI,0:1); % addchannel(AI,0:7); % CH0 y CH1 % CH0 a CH7

Configure property values -- Configure the sampling rate to 11.025 kHz and define a 2 second acquisition. set(AI,'SampleRate',11025)

set(AI,'SamplesPerTrigger',22050) Acquire data -- Start AI and extract all the data from the engine. Before start is issued, you might want to begin inputting data from a microphone or a CD player. start(AI) data = getdata(AI); Plot the data and label the figure axes. plot(data) xlabel('Samples') ylabel('Signal (Volts)') Clean up -- When you no longer need AI, you should remove it from memory and from the MATLAB workspace. delete(AI) clear AI

Das könnte Ihnen auch gefallen