Acquiring Data from Sensors and
Instruments Using MATLAB
Chirag Patel
Application Engineer – Control Systems
MathWorks
© 2011 The MathWorks, Inc.1
Agenda
Why acquire data with MATLAB?
Overview of data access options from MATLAB
Analyzing audio data
– Demo: Analyzing the frequency spectrum of live audio signal
Working with Sensors
– Demo: Acquiring data from a thermocouple
– Demo: Acquiring data from an IEPE accelerometer
– Demo: Acquiring data from a Bluetooth sensor
Acquiring data from stand alone instruments
– Demo: Acquiring data from an oscilloscope
Summary
Q&A
2
Technical Computing Workflow
Access Explore & Discover Share
Automate
3
MATLAB Connects to Your Hardware
Data Acquisition Toolbox
Plug in data acquisition boards and modules
Instrument Control Toolbox
Instruments and RS-232 devices
Image Acquisition Toolbox™
Image capture devices
Vehicle Network Toolbox
CAN bus interface devices
MATLAB
Interfaces for communicating with
everything
4
Data Acquisition Toolbox™:
Supported Hardware
Agilent Technologies
Keithley
– ISA, PCI, PCMCIA
Measurement Computing Corporation
– USB, PC/104, ISA, PCMCIA, Parallel port
National Instruments
– Hardware supported by NI-DAQ, NI-DAQmx drivers over AT, PCI, PCI Express, FireWire,
PXI, SCXI, PCMCIA, parallel port, USB, CompactDAQ
Any Windows compatible sound cards (AI, AO)
IOtech
– DaqBoard, DaqBook, DaqLab, DaqScan, Personal Daq/3000, and WaveBook Series
Data Translation
– All USB and PCI boards
CONTEC
– Various boards through CONTEC ML-DAQ adaptor
Advantech
For a complete list, visit www.mathworks.com/products/daq/supportedio.html
5
Demo: Acquiring and analyzing data from
sound cards
Windows sound card
Frequency Analysis
Live Data
Graphical User
Interface
6
Analyzing sensor data from MATLAB
Physical Sensor /
Hardware
Quantity Transducer
Voltage
Data
Measurement Types
Temperature
Pressure
Flow
Acceleration Computer
Rotation
Strain
…
7
Using Sensors and actuators from MATLAB
Common Sensor Types Common Tasks:
– Thermocouple, RTD, thermistor Browse connected
– Strain Gauge
DAQ hardware
– Accelerometer Set up Acquisition
Parameters
– Photodiode
Collect data in
– Flow Rate Sensor
foreground or
– Liquid Level sensor background
– Pressure Sensor Analyze and visualize
the data
Process Control Uses
– 4 to 20 mA transmitters and receivers
– Feedback Loop to control a process variable (temperature)
8
Data Acquisition Toolbox
What kind of hardware can I use?
– Supports for a variety of data acquisition
boards and USB modules
Key Features
– Support for analog input, analog output,
counters, timers, and digital I/O
– Direct access to voltage, current, IEPE
accelerometer, and thermocouple
measurements
– Live acquisition of measured data directly into
MATLAB or Simulink
– Hardware and software triggers for control of
data acquisition
– Device-independent software interface
9
What’s new in R2011b for
Data Acquisition Toolbox?
Two interfaces to connect to DAQ hardware
– Legacy interface
– Session-based interface (NI-only)
Support the following on most NI hardware
– IEPE accelerometer measurements
– Bridge-based sensors measurements
– Thermocouple and RTD measurements
– Counter/Timer operations
10
Acquiring data from thermocouples
No data conversion
Collect data in units of
choice
Background or Foreground
Acquisition
11
Working with IEPE sensors
Industry Standard for accelerometers
– Integrated Electronics Piezo Electric (IEPE)
– Converts charge output to voltage
Requires constant current source
– NI IEPE DAQ hardware supplies the current on same wire as
the sensor output
12
Acquiring IEPE accelerometer data
13
Acquiring data from a Bluetooth temperature
sensor
– Communication with Wireless
Bluetooth Temperature Sensor
– Retrieve data
– Plot result
14
Key Capabilities & Benefits (DAT)
Capabilities Benefits
Connect to a wide variety of DAQ Freedom to choose the hardware that is right for
hardware using a common set of the task
commands Easier to maintain code and leverage previously
written code fro new projects with different hardware
Access to hardware capable of Simplifies measurement test setup since the
specialized measurements such as signal conditioning is in the hardware
IEPE accelerometer, thermocouple Connect the sensor and acquire the data in the
and Bridge desired engineering units (g, degrees K etc.) without
conversions or lookup tables
Access to counter/timer Full access to the capability of the DAQ card
measurements Simplifies applications involving counting, pulse width
and frequency measurements
Enables live analysis of acquired Simplified background data acquisition
data Analyze data as you collect it. Reduce collection of
bad data
15
Instrument Control Toolbox
What are the key features of Instrument Control Toolbox?
– IVI, VXIplug&play, and native MATLAB instrument driver support
– GPIB and VISA (GPIB, GPIB-VXI, VXI, USB, TCP/IP, and serial)
support
– TCP/IP, UDP, and Bluetooth serial protocol support
– Interactive tool for identifying, configuring, and communicating with
instruments
– Simulink® blocks for sending and receiving live data between
instruments and Simulink models
– Functions for reading and writing binary and ASCII data to and from
instruments
– Synchronous and asynchronous (blocking and nonblocking) read-
and-write operations
16
Instrument Control Toolbox:
Supported Hardware
Instruments from Agilent, Anritsu, LeCroy, Rohde & Schwarz,
Tabor, Tektronix, and others
Instruments and devices supporting common communication
protocols (GPIB, VISA, TCP/IP, UDP, and serial, Bluetooth)
Serial devices – Any device with a RS-232, RS-422, or RS-485
interface (EEGs, gas chronometers, mass spectrometers, etc.)
Instruments using industry-standard instrument drivers
(IVI, VXIplug&play, LXI)
For a complete list, visit http://www.mathworks.com/products/instrument/hardware/index.html 17
Acquiring Data Using the Test and Measurement
Tool
Features:
Export directly to Figure
Window
Export to MATLAB
workspace
18
Test and Measurement Tool Features
Features:
View driver properties
View driver functions
Create device objects
Create interface objects
View connected
hardware
19
Session Log
Features:
Automatically creates
MATLAB code from
activity within the tool
Comments the code
Can be saved for use
in application
20
What’s new in R2011b for
Instrument Control Toolbox
Bluetooth support
– Serial Port Profile (SPP)
Quick Control Oscilloscope
– Quick Control Oscilloscope objects
– Based on IVI driver technology, but no knowledge required for end
user
21
Key Capabilities & Benefits (ICT)
Capabilities Benefits
Control and acquire data from Verify designs and build test systems
instruments using IVI, Instrument Control Toolbox and MATLAB as a platform
VXIplug&play and MATLAB for design verification. Develop models in MATLAB or
instrument drivers Simulink and test them with data generated or
collected from test equipment. Verify that prototypes
meets specs and build larger test systems.
Connect to instruments and Easily connect to hardware without leaving
devices over GPIB, TCP/IP, VISA, MATLAB
USB and Serial and Bluetooth Analyzing data, visualizing data and developing
custom measurements all in the single environment
saves time.
Connect to remote software Enables analysis of data collected from a remote
applications using TCP/IP source
22
Summary
Acquire Data from sensors and Instruments
– Data Acquisition Toolbox
– Instrument Control Toolbox
– Image Acquisition Toolbox
– Vehicle Network Toolbox
Without leaving MATLAB you can acquire, analyze and
visualize your data
Acquiring and analyzing data from the same environment
saves time and enables live analysis of data
23
Resources
Data sheets, user stories, demos, technical literature, documentation
– www.mathworks.com/products
View this and other archived webinars
– www.mathworks.com/products/daq
View more data acquisition demos
– http://www.mathworks.com/products/daq/demos.html
View more instrument control demos
– http://www.mathworks.com/products/instrument/demos.html
View supported hardware
– Data Acquisition Toolbox
– Instrument Control Toolbox
– Image Acquisition Toolbox
– Vehicle Network Toolbox
24