You are on page 1of 33

Hardware Connectivity with MATLAB

and Simulink

By Coorous Mohtadi
Academic Technical Evangelist

© 2012 The MathWorks, Inc.1


Key Points

 Instrument Control & Data Acqusition


– Data Direct to MATLAB and Simulink
– Test Automation

 Run on Target Hardware


– Tethered solution with MATLAB no code generation
– Code Generation with Simulink
– Enhance Project-Based learning

 Rapid Prototyping for Real-Time Control and Signal


Processing
– xPC Target Turnkey

2
MATLAB Capabilities for Technical Computing

Explore

Communicate Share

3 3
Instrument Control Toolbox
Control and communicate with scientific instruments

 Integrate instruments into


MATLAB applications and
Simulink® models
 Interactive tool for detecting and
controlling instruments
 Automatic code generation for
faster and easier implementation
 Support for IVI, VXIplug&play,
and MATLAB instrument drivers
 Support for common
communication protocols

4 4
Instrument Control Toolbox:
Supported Instrument Manufacturers, Standards, and Protocols

 Agilent
 Anritsu
 LeCroy
 Rohde & Schwarz
 Tektronix
 Others
 Standards such as IVI, VXIplug&play, LXI
 Protocols such as GPIB, VISA, TCP/IP, UDP

 Serial devices – Any device with a RS-232, RS-422, or


RS-485 interface (EEGs, mass spectrometers, etc.)
For a full support listing, visit: www.mathworks.com/products/instrument
5 5
Live Demonstration

 Configure an instrument in MATLAB


 Acquire measurements from the instrument using a
MATLAB acquisition tool without writing MATLAB code
 Analyze and visualize results using MATLAB analysis tools

6 6
Instrument Control Toolbox:
Communication Protocols
GPIB Boards
Agilent Technologies Capital Equipment Corporation (CEC)
CONTEC IOTech
Keithley Measurement Computing
National Instruments ICS Electronics

VISA Interface (includes Serial, GPIB, VXI, GPIB-VXI, TCP/IP, USB)


Agilent National Instruments
Rohde & Schwarz Tektronix

Network Protocols
TCP/IP and UDP

Serial Port (core functionality in MATLAB)


RS-232, RS-422, RS-485
Expanded capability with Instrument Control Toolbox

For a full listing, visit: www.mathworks.com/products/instrument

7 7
Instrument Control Toolbox:
Instrument Drivers

 Industry-standard instrument drivers


– Interchangeable Virtual Instrument (IVI™) drivers
– VXIplug&play™ drivers

 Several hundred supported instruments


– Drivers available through the instrument vendor

 Instrument drivers do not require knowledge of low-level


commands
fwrite(obj, ‘TRIG:MAI:EDGE:SLO RIS’);

set(obj, ‘TriggerSlope’, ‘Rising’);

8 8
Instrument Control Toolbox:
Instrument Drivers

MATLAB Instrument
Vendor Instrument
Driver
Driver
(IVI or VXIplug&play)

 Automatically create MATLAB instrument driver for vendor’s


driver
 Customize MATLAB driver to extend or enhance vendor’s driver
 Create custom MATLAB driver for any instrument
 MATLAB instrument drivers available at:
www.mathworks.com/products/instrument/drivers
9 9
Benefits of using MATLAB with
Instrument Control Toolbox

1. Use MATLAB as your single software environment for data


acquisition, data analysis, and application development
– Saves time transferring data
– Only maintain one software tool (product upgrades, training,
maintenance costs, etc.)

2. MATLAB and Instrument Control Toolbox are hardware neutral


– You are not tied to one hardware manufacturer
– Mix hardware from multiple manufacturers today
– Easily switch hardware tomorrow

3. MATLAB is widely used


– Over 1,000,000 users
– Technical personnel available with MATLAB experience

10 10
Using Instrument Control Toolbox
with Simulink

 Control and acquire data from


instruments and serial devices
such as RS-232 directly into
Simulink

 Also supports communication


with remote applications using
TCP/IP and UDP

11 11
Data Acquisition Toolbox
Acquire and output data from data acquisition boards

 Immediately analyze live or


acquired data in MATLAB and
Simulink
 Configure hardware without
leaving MATLAB
 Incorporate custom analysis into
PC-based digital oscilloscope
 Ability to do “one-shot” or
continuous acquisition
 Support multiple data acquisition
devices and vendors

12 12
Live Demonstration

 Acquire data directly from


data acquisition hardware
into MATLAB
 Analyze results in
visualization environment
 Create using MATLAB code
 Automatically generate
HTML report to share
results

13 13
Data Acquisition Toolbox:
Supported Hardware

 Agilent (Acqiris)  Keithley


 ADLINK  Measurement Computing (MCC)
 Advantech  National Instruments
 CONTEC  Ono Sokki
 Data Translation  United Electronic Industries
 g.tec  VXI Technology
 IOTech

 Any PC compatible sound card


 Parallel Port

For a full support listing, visit: www.mathworks.com/products/daq

14 14
Benefits of using MATLAB with
Data Acquisition Toolbox

1. Use MATLAB as your single software environment for data


acquisition, data analysis, and application development
– Saves time transferring data
– Only maintain one software tool (product upgrades, training,
maintenance costs, etc.)

2. MATLAB and Data Acquisition Toolbox are hardware neutral


– You are not tied to one hardware manufacturer
– Mix hardware from multiple manufacturers today
– Easily switch hardware tomorrow

3. MATLAB is widely used


– Over 1,000,000 users
– Technical personnel available with MATLAB experience

15 15
Using Data Acquisition Toolbox
with Simulink

 Acquire live or measured data


directly into Simulink® models from
data acquisition devices
 Directly evaluate your Simulink
algorithms against real-world data

16 16
MATLAB and Simulink Acquisition Toolboxes

Data Acquisition Toolbox


Plug-in data acquisition devices

Instrument Control Toolbox


Electronic and
scientific instrumentation

Image Acquisition Toolbox


Image capture devices

MATLAB
Interfaces for communicating
with everything
17 17
Key Points

 Instrument Control & Data Acqusition


– Data Direct to MATLAB and Simulink
– Test Automation

 Run on Target Hardware


– Tethered solution with MATLAB no code generation
– Code Generation with Simulink
– Enhance Project-Based learning

 Rapid Prototyping for Real-Time Control and Signal


Processing
– xPC Target Turnkey

18
Simulink Support for Target Hardware

Run Simulink models on


low-cost target hardware

 With just a click, your model moves


from Simulink onto hardware

 Supported target hardware


– Arduino® Uno and Mega 2560
– LEGO® MINDSTORMS® NXT
– BeagleBoard

 Available in Student Version

19
Supported Hardware
Arduino Uno and Mega 2560
 Highly popular, very low-cost electronics
prototyping platform
 Cost: £30 (Uno), £65 (Mega)

BeagleBoard
 Low-cost single-board embedded computer
designed for audio, video, and digital signal
processing
 Cost: £150

LEGO MINDSTORMS NXT


 Widely available robotics platform with motors
and broad selection of sensors/actuators
 Designed for easy assembly by beginners
 No engineering background required
 Cost: £300
20
Project-Based Learning with Simulink
Model-Based Design Tracking Application

 Rotate a camera to track an object

21
Project-Based Learning with Simulink
HW Description

Camera connected
Via USB to Simulink

DC Motor

Arduino Board
Controlling the
Motor Position Passive Carrier Board
to connect to the input / output
22
Project-Based Learning with Simulink
Video Image Tracking Application

Locate Object /
Acquire Image Position
Correction
Position
Simulink Model on Laptop Demand sent via
USB to Arduino

Receive New
Position
Demand

Arduino HW – Running C Automatically


generated from Model
23
Project-Based Modelling and Simulation

System Design

Image Processing
Algorithm

Physical Model

Control Design
State Diagram

24
Hardware for Project-Based Learning

Visit www.mathworks.com/academia/hardware-resources/ 25
Key Points

 Instrument Control & Data Acqusition


– Data Direct to MATLAB and Simulink
– Test Automation

 Run on Target Hardware


– Tethered solution with MATLAB no code generation
– Code Generation with Simulink
– Enhance Project-Based learning

 Rapid Prototyping for Real-Time Control and Signal


Processing
– xPC Target Turnkey

26
From Simulation to Real-Time Testing
 Models designed in Simulink and Stateflow

 You want to run, test, and prove your Simulink design with your hardware
under test at its normal operating frequency, speed, or timing.

 But how can you do this testing in real-time?

27
Real-Time Testing using xPC Target
 xPC Target™ enables you to execute Simulink® and
Stateflow® models on a target computer …
 … for rapid control prototyping, hardware-in-the-loop (HIL)
simulation, and other real-time testing applications.

28
xPC Target
 Easy real-time execution for Simulink and Stateflow
models makes it simple to test models with real
hardware in the real-world.
 blocks are configurable within the Simulink model
 early verification of your designs in the lab

 Tools for interactive real-time monitoring, parameter


tuning, and data logging
 control the real-time simulation from the Simulink model
 offline data analysis in MATLAB for a seamless toolchain

 Support for numerous I/O modules, communication


protocols and data buses:
 analog I/O, digital I/O, pulse train generation & capture, and
shared memory
 serial, UDP/IP, CAN, J1939, ARINC 429, and MIL-STD-1553
 also supports all xPC Target Turnkey configurations 29
What is xPC Target Turnkey?
 Complete real-time testing solution
 Combines xPC Target (software) with a real-time target
machine and IO modules (hardware)
 Optimized for Simulink and xPC Target

xPC Target Turnkey

30
xPC Target Turnkey
Portfolio of real-time target machines and IO modules
 Assembled to meet your computational, IO connectivity and
environment requirements
 Various form factors for desktop, lab, field or in-vehicle use

31
FPGA Programming for xPC Target

Programming FPGA boards for xPC Target Turnkey real-time target machines using Simulink HDL
Coder Workflow Advisor.

 Execute high-speed algorithms on an FPGA connected to a model


running in real time with xPC Target. (FPGA’s are clocked at 33MHz)
 Automatically program the FPGA without needing to know HDL code
- ideal for functional testing and verification.
 Quick reconfiguration of FPGA IO promotes a flexible real-time
testing environment.
 Compatible with both new and existing xPC Target Turnkey systems.

32
Key Points

 Instrument Control & Data Acqusition


– Data Direct to MATLAB and Simulink
– Test Automation

 Run on Target Hardware


– Tethered solution with MATLAB no code generation
– Code Generation with Simulink
– Enhance Project-Based learning

 Rapid Prototyping for Real-Time Control and Signal


Processing
– xPC Target Turnkey

33

You might also like