1 / 15

4. Achiziţia datelor in MATLAB

4. Achiziţia datelor in MATLAB. 4. Achiziţia datelor in MATLAB. 4. Achiziţia datelor in MATLAB. 4. Achiziţia datelor in MATLAB. Data Acquisition Toolbox consta din urmatoarele elemente componente: M-files : comenzi MATLAB pt. comunicarea cu hardware

Download Presentation

4. Achiziţia datelor in MATLAB

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 4. Achiziţiadatelor in MATLAB

  2. 4. Achiziţiadatelor in MATLAB

  3. 4. Achiziţiadatelor in MATLAB

  4. 4. Achiziţiadatelor in MATLAB • Data Acquisition Toolbox consta din urmatoarele elemente componente: • M-files: comenzi MATLAB pt. comunicarea cu hardware • Data acquisition engine: functii pt. achizitia de date, buffering si management • Adaptor: DLL pentru interactiunea cu hardware

  5. 4. Achiziţiadatelor in MATLAB

  6. 4. Achiziţiadatelor in MATLAB

  7. 4. Achiziţiadatelor in MATLAB

  8. 4. Achiziţiadatelor in MATLAB 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. AI = analoginput('winsound'); %AI = analoginput('nidaq','Dev1'); %AI = analoginput('mcc',1); • 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. addchannel(AI,1:2); %addchannel(AI,0:1); % For NI and MCC • 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. set(AI,'SampleRate',11025) set(AI,'SamplesPerTrigger',22050)

  9. 4. Achiziţiadatelor in MATLAB • 5 Start acquisition or output of data — To acquire or output data, you must execute the device object with the start function. Acquisition and output occurs in the background, while MATLAB continues executing. You can execute other MATLAB commands while the acquisition is occurring, and then wait for the acquisition or output to complete. start(AI) • 6 Wait for the acquisition or output to complete — You can continue working in MATLAB while the toolbox is acquiring or outputting data. (For more information, see Chapter 5, “Doing More with Analog Input”.) However, in many cases, you simply want to wait for the acquisition or output to complete before continuing. Use the wait function to pause MATLAB until the acquisition is complete. wait(AI,3); • 7 Extract your acquired data (analog input only) — After data is acquired, you must extract it from the engine with the getdata function. data = getdata(AI); Plot the data and label the figure axes. plot(data) xlabel('Samples') ylabel('Signal (Volts)') • 8 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. delete(AI) clear AI

  10. 4. Achiziţiadatelor in MATLAB • 1 Create a device object — Create the analog input object ai for a sound card. ai = analoginput('winsound'); • 2 Add channels — Add two hardware channels to ai. addchannel(ai,1:2); • 3 Configure property values — Configure the sampling rate to 44.1 kHz and collect 1 second of data (44,100 samples) for each channel. set(ai,'SampleRate',44100) set(ai,'SamplesPerTrigger',44100) • 4 Acquire data — Start the acquisition. When all the data is acquired, ai automatically stops executing. start(ai) wait(ai,2) data = getdata(ai); plot(data) • 5 Clean up—When you no longer need ai, you should remove it from memory and from the MATLAB workspace. delete(ai) clear ai

  11. 4. Achiziţiadatelor in MATLAB • 1 Create a device object — Create the analog output object ao for a sound card. ao = analogoutput('winsound'); • 2 Add channels — Add two hardware channels to ao. addchannel(ao,1:2); • 3 Configure property values — Configure the sampling rate to 44.1 kHz for each channel. set(ao,'SampleRate',44100) • 4 Output data — Create 1 second of output data, and queue the data in the engine for eventual output to the analog output subsystem. You must queue one column of data for each hardware channel added. data = sin(linspace(0,2*pi*500,44100)'); putdata(ao,[data data]) • Start the output. When all the data is output, ao automatically stops executing. start(ao) • 5 Clean up — When you no longer need ao, you should remove it from memory and from the MATLAB workspace. delete(ao) clear ao

  12. 4. Achiziţiadatelor in MATLAB • 1 Create a device object — Create the digital I/O object dio for a National Instruments PCI-6024E board with hardware ID 1. dio = digitalio('nidaq','Dev1'); • 2 Add lines — Add eight hardware lines to dio, and configure them for output. addline(dio,0:7,'out'); • 3 Read and write values — Create an array of output values, and write the values to the digital I/O subsystem. Note that reading and writing digital I/O line values typically does not require that you configure specific property values. pval = [1 1 1 1 0 1 0 1]; putvalue(dio,pval) gval = getvalue(dio); • 4 Clean up — When you no longer need dio, you should remove it from memory and from the MATLAB workspace. delete(dio) clear dio

  13. 4. Achiziţiadatelor in MATLAB • ver • help daq • help daqdemos • demo toolbox ‘Data Acquisition’ • daqhwinfo • out.InstalledAdaptors • out.ObjectConstructorName(:) • daqhelp analoginput ai = analoginput('winsound'); out = daqhwinfo(ai) AIinfo = propinfo(ai); out = daqhelp(ai,'BitsPerSample'); AIinfo.TriggerType set(ai) get(ai)

  14. 4. Achiziţiadatelor in MATLAB

  15. 4. Achiziţiadatelor in MATLAB

More Related