logo资料库

NI USB-2009 in MATLAB.pdf

第1页 / 共30页
第2页 / 共30页
第3页 / 共30页
第4页 / 共30页
第5页 / 共30页
第6页 / 共30页
第7页 / 共30页
第8页 / 共30页
资料共30页,剩余部分请下载后查看
1 Introduction
1.1 MATLAB
1.2 Simulink
1.2.1 Data Acquisition Toolbox
1.3 USB-6008 DAQ Device
1.4 NI DAQmx driver
2 Data Acquisition
2.1 Introduction
2.1.1 Physical input/output signals
2.1.2 DAQ device/hardware
2.1.3 Driver software
2.1.4 Your software application
2.2 MAX – Measurement and Automation Explorer
2.3 DAQ in MATLAB
2.3.1 NI-DAQmx
3 Data Acquisition Toolbox
3.1 Getting Help
4 My First DAQ App
4.1 Introduction
4.2 Legacy Interface
4.2.1 Simple DAQ Application
4.2.2 Source Code
4.3 Session-based Interface
4.3.1 Summing up
5 DAQ in Simulink
5.1 Analog In
5.2 Analog Out
6 Control Application
6.1 Introduction
6.2 Low-pass Filter
6.3 PI Controller
6.4 Process Model
Telemark University College Department of Electrical Engineering, Information Technology and Cybernetics DAQ in MATLAB HANS-PETTER HALVORSEN, 2012.09.11 Faculty of Technology, Postboks 203, Kjølnes ring 56, N-3901 Porsgrunn, Norway. Tel: +47 35 57 50 00 Fax: +47 35 57 54 01
Table of Contents 1 Introduction .................................................................................................................................... 4 1.1 MATLAB ................................................................................................................................... 4 1.2 Simulink ................................................................................................................................... 5 1.2.1 Data Acquisition Toolbox ................................................................................................. 6 1.3 USB-6008 DAQ Device ............................................................................................................. 6 1.4 NI DAQmx driver ...................................................................................................................... 7 2 Data Acquisition .............................................................................................................................. 8 2.1 Introduction ............................................................................................................................. 8 2.1.1 Physical input/output signals .......................................................................................... 8 2.1.2 DAQ device/hardware ..................................................................................................... 9 2.1.3 Driver software .............................................................................................................. 10 2.1.4 Your software application ............................................................................................. 10 2.2 MAX – Measurement and Automation Explorer ................................................................... 10 2.3 DAQ in MATLAB ..................................................................................................................... 12 2.3.1 NI-DAQmx ...................................................................................................................... 12 3 Data Acquisition Toolbox .............................................................................................................. 13 3.1 Getting Help .......................................................................................................................... 14 4 My First DAQ App ......................................................................................................................... 15 4.1 Introduction ........................................................................................................................... 15 4.2 Legacy Interface .................................................................................................................... 15 4.2.1 Simple DAQ Application ................................................................................................ 16 4.2.2 Source Code ................................................................................................................... 17 2
3 Table of Contents 4.3 Session-based Interface......................................................................................................... 18 4.3.1 Summing up ................................................................................................................... 19 5 DAQ in Simulink ............................................................................................................................ 21 5.1 Analog In ................................................................................................................................ 21 5.2 Analog Out ............................................................................................................................. 23 6 Control Application ....................................................................................................................... 26 6.1 Introduction ........................................................................................................................... 26 6.2 Low-pass Filter ....................................................................................................................... 27 6.3 PI Controller ........................................................................................................................... 27 6.4 Process Model ....................................................................................................................... 29 Tutorial: Data Acquisition in MATLAB
1 Introduction In this Tutorial we will learn how to create DAQ (Data Acquisition) applications in MATLAB and Simulink. We will use a USB-6008 DAQ device from National Instruments as an example. In order to use DAQ devices from National Instruments in MATLAB/Simulink we need to install the NI-DAQmx driver provided by National Instruments. In addition we need the Data Acquisition Toolbox for MATLAB/Simulink. 1.1 MATLAB MATLAB is a tool for technical computing, computation and visualization in an integrated environment, e.g.,  Math and computation  Algorithm development  Data acquisition  Modeling, simulation, and prototyping  Data analysis, exploration, and visualization  Scientific and engineering graphics  Application development, including graphical user interface building MATLAB is developed by The MathWorks. MATLAB is a short-term for MATrix LABoratory. MATLAB is in use world-wide by researchers and universities. For more information, see www.mathworks.com Below we see the MATLAB Environment: 4
5 Introduction MATLAB has the following windows:  Command Window  Command History  Workspace  Current Directory The Command window is the main window. Use the Command Window to enter variables and to run functions and M-files scripts (more about m-files later). Watch the following “Getting Started with MATLAB” video: http://www.mathworks.com/demos/matlab/getting-started-with-matlab-video-tutorial.html 1.2 Simulink Simulink, developed by The MathWorks, is a commercial tool for modeling, simulating and analyzing dynamic systems. Its primary interface is a graphical block diagramming tool and a customizable set of block libraries. It offers tight integration with the rest of the MATLAB environment and can either drive MATLAB or be scripted from it. Simulink is widely used in control theory and digital signal processing for simulation and design. Basic information about Simulink can be found here: Watch the video Getting Started with Simulink by The MathWorks. Tutorial: Data Acquisition in MATLAB
6 Introduction Read the “Introduction to Simulink” document. You will need to know these topics when doing the rest of the tasks in this Lab Work. The Tutorial is available from: http://home.hit.no/~hansha/. I also recommend the following Video: “Simulink Quickie!”. Try to keep up and create the Simulink Block diagram while watching the video. 1.2.1 Data Acquisition Toolbox Data Acquisition Toolbox software provides a complete set of tools for analog input, analog output, and digital I/O from a variety of PC-compatible data acquisition hardware. The toolbox lets you configure your external hardware devices, read data into MATLAB and Simulink environments for immediate analysis, and send out data. Data Acquisition Toolbox also supports Simulink with blocks that enable you to incorporate live data or hardware configuration directly into Simulink models. You can then verify and validate your model against live, measured data as part of the system development process. We will use the Data Acquisition Toolbox in order to write and read data to and from a USB-6008 DAQ device from National Instruments. 1.3 USB-6008 DAQ Device NI USB-6008 is a simple and low-cost multifunction I/O device from National Instruments. The device has the following specifications:  8 analog inputs (12-bit, 10 kS/s) Tutorial: Data Acquisition in MATLAB
7 Introduction  2 analog outputs (12-bit, 150 S/s)  12 digital I/O  USB connection, No extra power-supply neeeded  Compatible with LabVIEW, LabWindows/CVI, and Measurement Studio for Visual Studio .NET  NI-DAQmx driver software The NI USB-6008 is well suited for education purposes due to its small size and easy USB connection. Note! The 64-bit version of Data Acquisition Toolbox supports National Instruments devices that can be used with the “session-based interface” (more about this later). For other supported NI data acquisition devices, you must use the 32-bit version of Data Acquisition Toolbox and MATLAB. The 32-bit versions of Data Acquisition Toolbox and MATLAB can be installed on a 64-bit Windows OS. 1.4 NI DAQmx driver You need to install the DAQmx driver in order to use it in MATLAB. Tutorial: Data Acquisition in MATLAB
2 Data Acquisition 2.1 Introduction The purpose of data acquisition is to measure an electrical or physical phenomenon such as voltage, current, temperature, pressure, or sound. PC-based data acquisition uses a combination of modular hardware, application software, and a computer to take measurements. While each data acquisition system is defined by its application requirements, every system shares a common goal of acquiring, analyzing, and presenting information. Data acquisition systems incorporate signals, sensors, actuators, signal conditioning, data acquisition devices, and application software. So summing up, Data Acquisition is the process of:  Acquiring signals from real-world phenomena  Digitizing the signals  Analyzing, presenting and saving the data The DAQ system has the following parts involved, see Figure: The parts are:  Physical input/output signals  DAQ device/hardware  Driver software  Your software application (Application software) 2.1.1 Physical input/output signals 8
分享到:
收藏