Introduction to NI LabVIEW and Related SDR HW Devices USRP

advertisement
1
Introduction to NI LabVIEW
and Related SDR HW Devices
USRP, VST and FlexRIO
Sudharsan Srinivasan
Department of Electronics and Communication Engineering
Tampere University of Technology
Department of Electronics and Communication Engg
Sudharsan Srinivasan
20.10.2014
2
Contents
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
LabVIEW
LabVIEW project
Various components of VI
Data flow
Parallelism
How to get Help in LabVIEW
Basic Debugging
Error handling
Data types
Documenting code
Structures in LabVIEW
Working with matrices
Interfacing
Graphs and plots
Design patterns
USRP
RFVST
FlexRIO
References
Department of Electronics and Communication Engg
Sudharsan Srinivasan
20.10.201
3
LabVIEW
•
•
•
•
•
•
•
LabVIEW is a graphical programming language by NI
Based on the dataflow programming model
Programs in labVIEW are called Virtual Instruments (VI’s)
VI’s get thier name because they imitate real world instruments.
Nearly all the LabVIEW components available can be grouped into
3 broad categories Acquire, Analyse and Present
VI’s use Front Panel to interact with users.
Block diagrams in LabVIEW are the graphical source code.
Department of Electronics and Communication Engg
Sudharsan Srinivasan
20.10.201
4
LabVIEW Project
•
•
•
LabVIEW project is a type of file
used to group together both
labview and non-LabVIEW files.
• Best means of organising and
tracking files
• Used for creating build
specification and deploy on
targets
• Creats a .lvproj filewhich
contains references to files
within
Remember that project is not a
folder on drive and deleting a
.lvproj file doesnot delet files it
refers to.
Creating a project
Demo!
Department of Electronics and Communication Engg
Sudharsan Srinivasan
5
Project explorer
•
•
•
•
•
Used to open a existing project
Has two tabs
• Items page-diplays
LabVIEW project items as
they exist in project tree.
• Files page- displays project
item that have a
corresponding filename on
disk.
By default My computer as the
target
Dependencies include items
need for VI’s target
Build Specification used for
source distribution ( stand
alone app or other types ).
Demo!
Department of Electronics and Communication Engg
Sudharsan Srinivasan
Files & Folders
6
• After opening a project, adding
files is easy
•
•
My computer >> Add >>File (or)
Project >> add to project >> file
• Folders in labview
•
Virtual folder- Files can be in
multiple locations on your disk but
still can be put into same folder
•
•
•
To add virtual folder
RightClick the target ( My Computer)>>
new >>virtual folder
Auto-populating folder- using this
type of folder labView continously
monitors the files and ensures that
the changes made in folder are
reflected to labview.
•
•
MYComputer >>ADD >> Folder(Autopopulating) (or)
Project >> Addto Project>> folder(Autopop)
Department of Electronics and Communication Engg
Sudharsan Srinivasan
20.10.201
Files & Folders (2)
7
• Snap-shot folder – Shows the
content of the actual folder at
the time of creation
•
•
MYComputer >>ADD >> Folder(snapshot)
(or)
Project >> Addto Project>>
folder(snapshot)
• Auto-populating folder is only
visible on the Items page
• We can view disk content but
cannot perform disk
operationson the autopopulation folders
• To perform disk operations use
the files page.
Department of Electronics and Communication Engg
Sudharsan Srinivasan
20.10.201
Various components of VI (1/5)
8
• Front Panel- user interface
module for the VI
•
Control Palette
•
•
•
View >> control Palette
Rightclick blank area on VI and Control
palette will appear
Search used for searching various
blocks or components of the VI.
• Block Diagram is the place
where we write our code
•
•
View >> Function Palette
Rightclick blank area on VI and
Functionpalette will appear
• Front Panel= UI, Blockdiagram=
code. Ctrl-E to switch BD to FP.
• Objects of block diagram
•
Terminals,SubVI,Functions,Structures & Wires
Department of Electronics and Communication Engg
Sudharsan Srinivasan
20.10.201
9
Various components of VI (2/5)
Front panel example
Front Panel
Toolbar
Icon
Boolean
Control
Graph
Legend
Waveform
Graph
Scale
Legend
Plot
Legend
Department of Electronics and Communication Engg
Sudharsan Srinivasan
20.10.201
Front panel toolbar
1
0
Listed from left to right as seen in LabVIEW
• Run button- To run VI once . Alternatively , Ctrl-R
• Run continously- To run VI continously ( similar to infinte loop)
• Abort-Abort a running program.
•
•
•
•
•
•
Note! Its not a good idea to abort VI in between execution
especially when acquiring data from external source as abort
execution may leave the VI in unknown state.
Pause- Pause execution of VI
Align objects- algin VI objects along different axis
Distribute objects- Distribute VI objects in front panel
Resize- Resize VI objects
Reorder- Reorder VI objects
Department of Electronics and Communication Engg
Sudharsan Srinivasan
11
Various components of VI (3/5)
Block diagram example
Block
Diagram
Toolbar
Divide
Function
SubVI
Graph
Terminal
Wire
Data
While Loop
Structure
Numeric
Constant
Timing
Function
Boolean Control
Terminal
Department of Electronics and Communication Engg
Sudharsan Srinivasan
Block diagram toolbar
Listed from left to right as seen in Labview
• Run, Run continously, abort , Pause functions are similar to
frontpanel tool bar
• Highlight Execution – used to watch our code execute
• Retain wire values – to save the wire values at each point in the
flow of execution.
• Step into, stepover and step out – Helpful debugging buttons
• Cleanup button- reroute and clean up the layout
Department of Electronics and Communication Engg
Sudharsan Srinivasan
12
Various components of VI (4/5)
13
• Nodes – objects with input and /or output that perform operations
when a VI runs
• Compareable to statements , operators function and subroutines in
text- based programming
• Sub-VI – VI’s inside VI’s
• When we double click a sub-VI it will openup and we can then
view the Front panel or the Block Diagram
• Icon for the SubVI is displayed in the upper right corner of the
window
• Express VI – are different from other VI’s as they are configured using
dialog boxes.
• DEMO!
• Simulate sinusoidal signal with gaussian noise.
Department of Electronics and Communication Engg
Sudharsan Srinivasan
Various components of VI (5/5)
•
•
•
14
Wires- used to connect the block diagrams
Different types of wires are there in LabVIEW based on data types
Different data types have different thickness, color, and styles
• Boolean- green
• String- Pink
• Numeric – Blue (integer) or Orange ( other numeric data)
• Broken wires – Black dotted line with a red cross mark
• Ctrl-B can be used to delete broken wires
• Ctrl-U to clean up diagram(i.e. make it more readable)
• As always ctrl-z is to undo
Department of Electronics and Communication Engg
Sudharsan Srinivasan
Tools Palette
•
Tools palette is used for
selecting tools
• Accessible from both front
panel and block diagram
windows.
• View >>Tools palette.
• Most useful mode is
automatic tools selection
• Most used tool is the
operating control toolindicated by a hand
• Positioning tool –To move
objects, indicated by arrow
• Labeling tool- double click
on the canvas to create a
free label
Department of Electronics and Communication Engg
Sudharsan Srinivasan
15
Tools palette
16
• Labeling tool works in both automatic mode selection and
manual mode.
• While in manual mode, labeling tool can be used to modify
labels and captions
• Wiring tool – used for making connections between VI objects.
• Rest of the tools are not selected in automatic mode and
must be selected manually
• Object shortcut tool- used to access the object shortcut menu
• Scroll tool – scroll without scroll bar
• Break point tool and probe tool are used in debugging
• Color copy- copying color from one object to the other.
Department of Electronics and Communication Engg
Sudharsan Srinivasan
20.10.201
17
Data flow
•
•
•
•
•
•
•
Data flow is the order in which code is executed
Two rules of dataflow
• Nodes execute when they receive all thier needed data
• When a node executes, it passes on the output data to next
node.
Using these rules LabVIEW executes programs/VI from node to node
as data flows
Different from control flow based languages like C,C++ etc…
In control flow sequential order of instructions determine the order
of program
It is always a good idea in LabVIEW to make the program in such a
ways that they execute from left to right.
Generally, in LabVIEW inputs are on the left side and outputs or on
the rightside of the object
Department of Electronics and Communication Engg
Sudharsan Srinivasan
18
Parallelism
• If we have simultaneously two
different functions they
essentially execute in parallel
• The order of execution is
typically random in nature.
• To enforce order in program we
use sequence structures like
while and for loops etc…
Demo!
Department of Electronics and Communication Engg
Sudharsan Srinivasan
How to get Help in LabVIEW (1/2)
19
Three different options available
Help!!
• Labview help - Gives information
about LabVIEW programming
concepts, step-by-step instructions
for using Lab VIEW and information
on VI’s functions , menus , palettes
and tools
• short cut key for LabVIEW help is
Ctrl + ?
• Context help – available from help
menu>> show context help or the ?
Sign in the block diagramwindow.
• short cut key Ctrl +H
Department of Electronics and Communication Engg
Sudharsan Srinivasan
20.10.201
How to get Help in LabVIEW(2/2)
• For Nodes the bold names (
inputs) shown in the context
help must be connected
• To get the wire data types
hover around the wire (after
clicking the context help)
• NI example finder- Helps to
find examples.
•
•
20
Context Help!
Help>> Find examples
Examples can also be searched
using the search tab
Department of Electronics and Communication Engg
Sudharsan Srinivasan
20.10.201
Basic Debugging (1/2)
• Broken VI- VI which cannot be
run.Any component might be
broken in the VI or wires
connected improperly.
•
21
Errors & debugging
Ctrl-B- check broken wires
• The error list window is used to
display the list of errors
•
•
View>>Error list (or)
Ctrl-l to display error list window
• Warnings do not prevent VI from
running.
• Tips for Debugging
•
•
To see the warnings put a tick mark
on the show warnings box.
Triple click a wire to checkthe
connection and to fix it
Department of Electronics and Communication Engg
Sudharsan Srinivasan
20.10.201
Basic Debugging (2/2)
•
22
Tips for debugging (cont’d…)
•
VI’s and functions pass default values through optional inuputs
when they are left unwired. Care is needed in such situations
•
For example a boolean input may be set to true if left unwired.
•
There might be hidden objects and nodes ,check for this .
•
•
•
Use VI hierachy from view to find unexpected subVI’s
Use execution highlighting+ single stepping to check the
execution flow
When single stepping the nodes that blink are the ones that are
ready to be executed.
Department of Electronics and Communication Engg
Sudharsan Srinivasan
20.10.201
Error handling (1/3)
•
•
•
LabVIEW uses error cluster for error handling.
Error in and error out in express VI’s are examples of error clusters
Error clusture is a data structure that has 3 different pieces of data
•
•
•
•
Status- boolean value. Reports True if error occurs.
Code -32 bit signed integer that identifies the error numerically. It is
zero when there is no error. It is a warning if the value is non-zero while
status is false.
Source – string which gives explanation of where the error occured
When error occurs right-click the error and click explanation for
more detailed information about error.
•
•
23
Show error on the error list window can be used for pointing out the
exact location of the error.
In LabVIEW, error also follows the dataflow model, just as error
flows through a VI, so can error information.
Department of Electronics and Communication Engg
Sudharsan Srinivasan
Error handling (2/3)
•
LabVIEW has two modes of error
handling
•
•
•
•
•
Error handling
Automatic
Manual error handling
By default, VI or a subVI is set to
automatic error handling
This means that LabVIEW will
suspend execution while the error
occurs in that portion of the code,
highlight the error portion and
display the error dialog box
To deactivate automatic error
handling go to
•
File>> Viproperties >>category (Pull
down menu>>execution & uncheck
enable automatic error handling
Department of Electronics and Communication Engg
Sudharsan Srinivasan
24
Error Handling ( 3/3)
25
• Manual error handling makes use of the error in and error out
terminal to allow errors to flow
• If we use manual error handling we may still want to inform user of
problems
• Use LabVIEW error handling VI’s and functions on the dialog & user
interface palette to manage errors
• For example one might use simple error handler.
Department of Electronics and Communication Engg
Sudharsan Srinivasan
20.10.201
26
Error Handling
Error Cluster
Status (Boolean)
- Code (Integer)
- Source (String)
Department of Electronics and Communication Engg
Sudharsan Srinivasan
27
Data types
•
•
•
•
Numeric, Enum, boolean,
strings and dynamic data.
Representation of a control
can be changed by right
clicking and selecting
representations.
Different types of numeric
data, broadly classified as
floating point and fixed point
data in labview
Floating point
•
•
•
Represented by orange color
Total no of bits used to
represent the number can vary
Three most important types,
Single , double and extended
precision numbers.
Department of Electronics and Communication Engg
Sudharsan Srinivasan
28
Datatypes
• Floating point data contd..
•
•
•
•
•
•
•
•
DBL- double precision 64 bit IEEE format.
DBL is default numeric object & used for most situations
SGL- Single precision 32 –bit IEEE format
Used when memory saving is important.
When using SGL make sure that there is no overflow
EXT- Extended precision uses 128 bits format
Data stored in disk using LabVIEW in extended precision is
platform dependent .
Use only when necessary –performance may be affected
• Fixed point data
•
•
Uses fixed no of binary digits to represent numerics
Totalt number of bits to be used can be configured
Department of Electronics and Communication Engg
Sudharsan Srinivasan
20.10.201
29
Data types
• Specify the range and the precision of fixed pt number
• While representing ration numbers in fixed point rep
resentation the denominator must be a power of 2.
• Specify the encoding , wordlength, and the integer
wordlength of when the bit size is fixed.
• Encoding – signed or unsigned
• Wordlength- total no of bits in the bit string that LabVIEW
uses to represent all possible fixed pt data (Max=64).
• Integer word length- number of integer bits in the bit string
that LabVIEW uses to represent all possible values in fixed
point data.
• Complex numbers are concatenated versions of floating point
numbers => CSG, CDB, CXT.
Department of Electronics and Communication Engg
Sudharsan Srinivasan
30
Data types
•
•
Coercion of data -When wires of
different representation types are
input to a function , the function return
an output in a larger or wider format.
Boolean- the usual true or false
values, uses 8 bits .
•
•
•
•
•
•
FALSE = all zeros , TRUE =all ones.
Various mechanical actions can be associated
with the boolean switch.
Strings – series of displayable or non
displayable ASCII characters.
Enums- combination of datatypes.
Dynamic datatypes- used to store
information generated or acquired by
an express VI.
Represented as a dark blue terminal.
Department of Electronics and Communication Engg
Sudharsan Srinivasan
Documenting code
•
•
•
•
•
•
•
•
31
From maintainability prespective, documenting code is important
In LabVIEW, tip strips, descriptions and VI properties are used for
documenting.
Tip Strip –brief description that appears whwn the cursor is moved
over indicators and controls.
Descriptions provide additional information about specific controls
and indicators.
Description appears in the context Help window when cursor is
moved over the object.
To add tip strip and descriptions, right click the control or indicator
and select Description and Tip.
Documentation component of the VI properties dialog box can also
be used to create Videscriptions and to link VI’s to HTMLLfiles or
compiled help files.
Right-click VI Icon, select VI Properties or File>>VIProperties then
select Documentation from categoriesdrop-down menu.
Department of Electronics and Communication Engg
Sudharsan Srinivasan
Structures in LabVIEW
While Loop
• Stops executing only if the
value at the conditional
terminal meets the
condition.
• Must execute at least once.
• Tunnels automatically
output the last value.
For Loop
• Executes a set number of
times unless a conditional
terminal is added.
• Can execute zero times.
• Tunnels automatically
output an array of data.
Department of Electronics and Communication Engg
Sudharsan Srinivasan
32
33
Timining a VI
• Most often control is needed on the frequency or timing of
loop iterations.
• In general, processor need time to complete tasks before
responding to user interface. therfore timing the loop is
essential.
• Wait function- make the VI wait/sleep for set amount of time.
• Wait uses millisecond clock of the OS.
• Wait has two flavours
•
•
wait until next ms –waits for milisecond counter to reach a
multiple of the amount specified.
Wait(ms) waits untill the millisecond counter counts to an
amount equal to input specified.
Department of Electronics and Communication Engg
Sudharsan Srinivasan
20.10.201
Feedback node
34
• In loops, it is often needed that the data from previous
iteration be accessed to enable this feedback nodes are used.
• Shift register can be used , similar to static variable in textbased programming language.
• Used to pass data from iteration in the past to the next
iteration.
Department of Electronics and Communication Engg
Sudharsan Srinivasan
35
Case structures
•
•
•
Similar to switch and if-else
conditional statements.
Selector terminaldata types
can be
• Boolean
• True case and False Case
• Error Cluster
• Error Case and No Error
Case
• Integer, string, or enum
• Structure can have any
number of cases.
• Include a Default
diagram to avoid listing
every possible input
value.
Department of Electronics and Communication Engg
Sudharsan Srinivasan
Working with matrices
•
•
•
Arrays/ vectors created by
draging a array shell to the
front panel and dragging a
data object or element such as
boolean, numeric, string, path
… into the array shell.
Array constants can also be
created from the Functions
palette.
To add dimensions to array
right-click the index display
and select add dimension from
the shortcut.
36
Example
Department of Electronics and Communication Engg
Sudharsan Srinivasan
20.10.201
Array functions
37
• Functions to manipulate array s found in the array palette.
• Array size – returns the size of array
• Intialize array- creates a n-dimensional array in which the
elements can be intialized to a defined value.
• Array subset- returns a portion of the array at indes and
containing length.
• Build array-concatenates multiple arrays or appends elements
to a n-dimensional array.
• Index array- return the element or subarray of a ndimensional array at index.
Department of Electronics and Communication Engg
Sudharsan Srinivasan
20.10.201
Interfacing matlab
• Generating a NxN complex random matrix using math script
Department of Electronics and Communication Engg
Sudharsan Srinivasan
38
39
Formula node
Department of Electronics and Communication Engg
Sudharsan Srinivasan
Graphs and plots
Department of Electronics and Communication Engg
Sudharsan Srinivasan
40
Design Patterns – State machine,
Diagram
Furnace
Example:
State Transition Diagram
Department of Electronics and Communication Engg
Sudharsan Srinivasan
41
Design Patterns - State Machines,
Infrastructure
• A state machine consists of a set of states and a transition function that
maps to the next state.
• Each state can lead to one or multiple states or end the process flow.
While Loop
Type-Defined
Enum
Case Structure
Shift Register
Department of Electronics and Communication Engg
Sudharsan Srinivasan
42
Design Patterns – Producer/Consumer,
Queue Operations
Use the Queue Operations functions to
create and use a queue for communicating data between:
•
Different sections of a VI.
•
Different VIs.
Department of Electronics and Communication Engg
Sudharsan Srinivasan
43
Design Patterns - Producer/Consumer
Department of Electronics and Communication Engg
Sudharsan Srinivasan
44
NI Platforms for
RF/Communications
45
NI Platforms
Graphical System Design Platform
USRP for
LabVIEW
NI RF VSG,
VSA
Host
Embedded, PC
NI FlexRIO
NI RF 6 GHz
P2P
FPGA
RIO
Department of Electronics and Communication Engg
Sudharsan Srinivasan
VST
46
USRP
Generic hardware platform for Software defined Radio
Department of Electronics and Communication Engg
Sudharsan Srinivasan
USRP components
Department of Electronics and Communication Engg
Sudharsan Srinivasan
47
USRP parameters &
configuration.
Department of Electronics and Communication Engg
Sudharsan Srinivasan
48
USRP parameter config
Department of Electronics and Communication Engg
Sudharsan Srinivasan
49
Using USRP
Department of Electronics and Communication Engg
Sudharsan Srinivasan
50
51
USRP
• Use the USRP manual available in the link below to connect
USRP to LabVIew/ computer.
http://digital.ni.com/manuals.nsf/websearch/79DAA8196B17
689286257A8E005C4295
• The NI-USRP nodes can be found in the following location
ExpressVI>>output>>instrument drivers>>NI-USRP
Department of Electronics and Communication Engg
Sudharsan Srinivasan
What is PXI?
52
PXI = PCI eXtensions for Instrumentation
PC-based platform optimized
for test, measurement, and
control
Advanced timing and
synchronization features
PCI electrical-bus with the
rugged, modular, Eurocard
mechanical packaging of
CompactPCI
Open specification governed by
the PXI Systems Alliance (PXISA)
Department of Electronics and Communication Engg
Sudharsan Srinivasan
53
RF Vector Signal Transceiver
Flexible approach to RF instrumentation
Vector signal analyzer and generator
User-programmable with LabVIEW FPGA
65 MHz to 6 GHz frequency range
80 MHz instantaneous bandwidth (3 dB)
24 channels of high-speed digital I/O
Department of Electronics and Communication Engg
Sudharsan Srinivasan
Soft Front Panel – NI RFSA and RFSG
Department of Electronics and Communication Engg
Sudharsan Srinivasan
54
Typical VST block diagram
Department of Electronics and Communication Engg
Sudharsan Srinivasan
55
56
NI FlexRIO System Architecture
PXI/PXIe
NI FlexRIO Adapter Module NI FlexRIO FPGA Module
PXI Platform
• Interchangeable I/O
• Analog or digital
• NI FlexRIO Adapter
Module Development Kit
(MDK)
• Synchronization
•
Clocking/triggers
• Power/cooling
• Data streaming
• Virtex-5 FPGA
• 132 digital I/O lines
• Up to 512 MB of DRAM
Department of Electronics and Communication Engg
Sudharsan Srinivasan
Platform for
Real-Time Communications Algorithm
Development
57
NI FlexRIO SDR Bundle
NI 5791 RF Transceiver
Adapter Module for
FlexRIO
200MHz-4.4GHz
NI 7965R FlexRIO
FPGA Module for
PXIe
Embedded
LabVIEW RT
Controller
PXIe Chassis
Department of Electronics and Communication Engg
Sudharsan Srinivasan
58
NI 5791 Baseband Transceiver FAM
• Tunable RF transceiver (TX & RX with shared LO)
• 200 MHz to 4.4 GHz frequency range
• 100 MHz instantaneous bandwidth 16 bits
• LO input and output for MIMO synchronization
• 12 bidirectional general-purpose digital I/O channels
• System design based on LabVIEW with included DSP libraries
NI 5791
Department of Electronics and Communication Engg
Sudharsan Srinivasan
References and Some additional
info !
59
• NI SW available for TUT students
•
https://swdist.tut.fi/Software/NI_Software/
• Getting started with LabVIEW
•
http://digital.ni.com/manuals.nsf/websearch/4ECC47F63A6C58B
686257B7A0070104B
• LabVIEW fundamentals
•
http://digital.ni.com/manuals.nsf/websearch/579AAD073776AD
D68625705700830345
• Various other LabVIEW trainings
•
https://decibel.ni.com/content/docs/DOC-13978
• LabVIEW Cheat sheet
•
http://www.ni.com/pdf/manuals/373353c.pdf
Department of Electronics and Communication Engg
Sudharsan Srinivasan
References
60
1. LabVIEW reference manual
http://www.ni.com/pdf/manuals/321526b.pdf
2. Training material from various LabVIEW trainings.
3. LabVIEW support website http://www.ni.com/support/
4. NI USRP 2920 specification
http://digital.ni.com/manuals.nsf/websearch/73F8A3CDDDE
A7E9B862579CE00719238
Department of Electronics and Communication Engg
Sudharsan Srinivasan
Download