Usrp & Labview
Usrp & Labview
1
1.2 Benefits:
Data Types
Property Nodes
Sub VIs
Arrays
Array Functions
Cluster
Error Handling
2
Working with Projects using Project Explorer
Design Techniques
Shift Register
State Machine
Multiple Loops
User Interface
Plotting Data
Briefly explanations…
NI--‐DAQmx
3
2 START USING LABVIEW
LabVIEW programs are called Virtual Instruments, or VIs, because their appearance and
operation imitate physical instruments, such as oscilloscopes and multimeters. LabVIEW
contains a comprehensive set of tools for acquiring analyzing, displaying, and storing data, as
well as tools to help you troubleshoot your code.
When opening LabVIEW, you first come to the “Getting Started” window.
In order to create a new VI, select “Blank VI” or in order to create a new LabVIEW
project, select “Empty project”.
When you open a blank VI, an untitled front panel window appears. This window
displays the front panel and is one of the two LabVIEW windows you use to build a VI. The
other window contains the block diagram. The sections below describe the front panel and the
block diagram.
2.2 Front Panel:
When you have created a new VI or selected an existing VI, the Front Panel and the Block
Diagram for that specific VI will appear.
4
In LabVIEW, you build a user interface, or front panel, with controls and indicators.
Controls are knobs, push buttons, dials, and other input devices. Indicators are graphs, LEDs,
and other displays.
You build the front panel with controls and indicators, which are the interactive input
and output terminals of the VI, respectively. Controls are knobs, push buttons, dials, and other
input devices. Indicators are graphs, LEDs, and other displays. Controls simulate instrument
input devices and supply data to the block diagram of the VI. Indicators simulate instrument
output devices and display data the block diagram acquires or generates.
E.g., a “Numeric” can either be a “Numeric Control” or a “Numeric Indicator”, as seen
below.
If you select a “Numeric Control”, it can easy be changed to an “Numeric Indicator” by right
click on the object an select “Change to Indicator”
5
Or opposite, I you select a “Numeric Indicator”, it can easy be changed to an “Numeric
Control” by right click on the object an select “Change to Control”
The difference between a “Numeric Control” and a “Numeric Indicator” is that for a
“Numeric Control” you may enter a value, while the “Numeric Indicator” is read--‐only, i.e.,
you may only read the value, not change it.
The appearance is also slightly different, the “Numeric Control” has an increment and
an decrement button in front, while the “Numeric Indicator” has a darker background color in
order to indicate that its read--‐only.
After you build the user interface, you add code using VIs and structures to control the
front panel objects. The block diagram contains this code. In some ways, the block diagram
resembles a flowchart.
After you build the front panel, you add code using graphical representations of
functions to control the front panel objects. The block diagram contains this graphical source
code. Front panel objects appear as terminals, on the block diagram. Block diagram objects
6
include terminals, subVIs, functions, constants, structures, and wires, which transfer data
among other block diagram objects.
The Figure below shows a front panel and its corresponding block diagram with front
panel and block diagram components.
7
The different components are as follows:
Toolbar
Owned Label
Numeric Control
Free Label
Numeric Control Terminal
Knob Terminal
Numeric Constant
Multiply Function
Icon
Knob Control
Plot Legend
XY Graph
Wire Data Path
XY Graph Terminal
Bundle Function
SubVI
For Loop Structure
The Controls and Functions palettes contain sub palettes of objects you can use to
create a VI. When you click a sub palette icon, the entire palette changes to the sub palette
8
you selected. To use an object on the palettes, click the object and place it on the front panel
or block diagram. The Controls palette is available only on the front panel. The Controls
palette contains the controls and indicators you use to build the front panel.
The most used Sub Palettes are the Numeric Sub Palette, the Boolean Sub Palette and
the String & Path Sub Palette.
You may change the appearance and the contents of the Controls palette:
You may Pin the palette, so it is always visible, just click the little pin button in the
upper left corner of the palette:
If you want to change the content and appearance of the palette, click the “View” button.
Here you may change the way the palette should look.
If you click “Change Visible Categories…” you may change which Categories you
want to have visible.
9
2.4.1 Numeric Sub Palette
“Numerical Control” and “Numerical Indicator” are the most used objects in the numeric sub
palette.
10
2.4.2 Boolean Sub Palette
This palette has lots of different buttons you may use. OK, Cancel and Stop buttons are
useful.
11
2.6 Tools Palette
You can create, modify, and debug VIs using the tools located on the floating Tools
palette. The Tools palette is available on both the front panel and the block diagram. A tool is
a special operating mode of the mouse cursor. The cursor corresponds to the icon of the tool
selected in the Tools palette. Use the tools to operate and modify front panel and block
diagram objects.
12
The Tools palette is available from the View menu:
If you make sure “Automatic wiring” is disabled (I recommend you do so!) you
may use the Tab key on your keyboard in order to switch between the most common tools.
The most used tools are:
Use the Operating tool, shown at left, to change the values of a control or select the text
within a control. The Operating tool changes to the icon shown at left when it moves over a
text control, such as a numeric or string control.
Use the Positioning tool, shown at left, to select, move, or resize objects. The
Positioning tool changes to resizing handles when it moves over the edge of a resizable
object.
Use the Labeling tool, shown at left, to edit text and create free labels. The
Labeling tool changes to the following icon when you create free labels.
Use the Wiring tool, shown at left, to wire objects together on the block diagram.
2.7 Wiring
In order to create the logical flow between the object on the Block Diagram, you need
to use the Wiring tool in order to connect the different objects together.
Use the Wiring tool to wire objects together on the block diagram.
Available Keyboard Shortcuts when dealing with Wiring:
13
Ctrl--‐B is very useful. This short--‐cut removes all broken wires on the Block Diagram.
2.8 Toolbar
Below we see the LabVIEW Toolbar:
Click the Run button to run a VI. LabVIEW compiles the VI, if necessary. You can run a
VI if the Run button appears as a solid white arrow. The solid white arrow, shown above, also
indicates you can use the VI as a subVI if you create a connector pane for the VI.
While the VI runs, the Run button appears as shown at left if the VI is a top--‐level VI,
meaning it has no callers and therefore is not a subVI.
If the VI that is running is a subVI, the Run button appears as shown at left.
The Run button appears broken, shown at left, when the VI you are creating or editing
contains errors. If the Run button still appears broken after you nish wiring the block
diagram, the VI is broken and cannot run. Click this button to display the Error list window,
which lists all errors and warnings.
Click the Run Continuously button, shown at left, to run the VI until you abort or pause
execution. You also can click the button again to disable continuous running.
14
While the VI runs, the Abort Execution button, shown at left, appears. Click this button
to stop the VI immediately if there is no other way to stop the VI. If more than one running
top--‐level VI uses the VI, the button is dimmed.
Click the Pause button, shown at left, to pause a running VI. When you click the Pause
button, LabVIEW highlights on the block diagram the location where you paused execution, and
the Pause button appears red. Click the button again to continue running the VI.
2.9 Execution
In addition to the Toolbar buttons above the following Keyboard Shortcuts are available
when dealing with Execution:
15
The short--‐cut menu will be different for the different controls or objects.
2.11 Dataflow Programming
LabVIEW follows a dataflow model for running VIs. A block diagram node executes
when all its inputs are available. When a node completes execution, it supplies data to its
output terminals and passes the output data to the next node in the dataflow path.
Visual Basic, C++/C#, Java, and most other text--‐based programming languages
follow a control flow model of program execution. In control flow, the sequential order of
program elements determines the execution order of a program.
2.12 Help
The Context Help window (Ctrl +H) displays basic information about LabVIEW objects
when you move the cursor over each object. The Context Help window is visible by default.
To toggle display of the Context Help window, select Help--‐Show Context Help, press the
Ctrl--‐H keys, or click the Show Context Help Window button on the toolbar.
When you move the cursor over front panel and block diagram objects, the Context
Help window displays the icon for subVIs, functions, constants, controls, and indicators, with
wires attached to each terminal. When you move the cursor over dialog box options, the
Context Help window displays descriptions of those options. In the window, required
connections are bold, recommended connections are plain text, and optional connections are
dimmed or do not appear.
The Figure below shows an example of the Context Help window.
16
3 SUB VIS
This chapter explains the basic concepts of creating and using Sub VIs in LabVIEW.
When you place a VI on the block diagram, LabVIEW considers the VI to be a subVI.
When you double--‐click a subVI, its front panel and block diagram appear, rather than a
dialog box in which you can configure options. The front panel includes controls and
indicators. The block diagram includes wires, front panel icons, functions, possibly subVIs,
and other LabVIEW objects. The upper right corner of the front panel and block diagram
displays.
Below we see an example of a bad Block Diagram. This example does not make use
of the SubVI functionality in LabVIEW at all! This makes the Block diagram hard to read
and understand. The size of the diagram is also too large! The Block Diagram should always
fit into the screen. Both the Front Panel and the Block Diagram should fit into a screen
resolution of 1024x768.
With use of SubVIs, the example above could turn into, e.g.:
17
As you can see, much of the code in the Main VI have been replaced and put into SubVIs.
Another approach is to use a so--‐called State Machine principle (more about this in chapter
11 --‐ Design Techniques ).
18
You may select different Patterns, i.e., how many input and output connectors you need.
Make sure you select a Pattern with enough connectors even if you don’t need all the
connectors at the moment. I recommend that you standardize on the pattern in the Figure
above.
Select the Wire tool and click on the wanted connector, then click on the Control or
Indicator on the Front Panel you want to connect to this connector.
19
Below we see a block diagram with SubVIs icon appearance created with the Icon Editor.
20
Although this is quite easy to do this, I do not recommend that you use this
functionality to much. This is because you should create and use SubVIs from the first
moment you start creating your application and not afterwards when you find out that you
have been creating a messy code.
So you should structure and design your code with the use of SubVIs from the
beginning!
3.3 Using Sub VIs
Below we see an example of how to use SubVIs in a program (Top VI or SubVIs):
You may open a SubVI from the File menu, select a SubVI from the Functions palette
or use drag and drop in different ways, e.g., you may drag a VI from the File Explorer in
Windows directly into an existing VI you have already opened in LabVIEW.
21
4 CUSTOMIZE LABVIEW
LabVIEW has lots of possibilities for customizing the appearance and the use of the
LabVIEW environment. Select “Options…” from the Tools menu.
The default settings is not necessary the best, here are some recommendations for setting up
the LabVIEW environment.
Block Diagram
22
Disable “Enable auto wiring” option. This prevents LabVIEW from automatically connecting
adjacent blocks. Although it seems useful to have auto wiring enables, it is my experience
that the auto wiring is a little annoying since it tends to draw wires between blocks when you
do not want any wire.
Disable “Place front panel elements as icons” option. This causes LabVIEW to use
small terminal icons on the block diagram. If you, instead, activate this option, the terminal
icons are larger, with a mimic of the element as it appears at the front panel.
Category: Controls/Functions Palettes
In the Format list: select “Category (Icons and Text)”
Category: Alignment Grid
Turn off “Show Front Panel Grid” and “Show Block Diagram Grid”.
23
5 LOOPS AND STRUCTURES
This chapter explains the basic concepts of Loops and Structures in LabVIEW.
The different Loops and Structures available are located in the “Structures” sub palette in the
Functions palette on the Block Diagram.
5.1. Loops
These loops will be explained in detail below.
5.1.1 For Loop
A For Loop executes a sub diagram a set number of times. The Figure below shows an empty
For Loop in LabVIEW.
A For loop executes its sub diagram n times, where n is the value wired to the count (
) terminal. The iteration ( ) terminal provides the current loop iteration count, which
ranges from 0 to n--‐1.
After you create a For Loop, you can use shift registers to pass values from one
iteration to the next. If you wire an array to a For Loop, you can read and process every
24
element in that array by enabling auto--‐indexing. You also can enable auto--‐indexing by
configuring a For Loop to return an array of every value generated by the loop.
You can add a conditional terminal to configure a For Loop to stop when a Boolean
condition or an error occurs. A For Loop with a conditional terminal executes until the condition
occurs or until all iterations complete, whichever happens first. To add a conditional terminal to a
For Loop, right--‐click the For Loop border and select Conditional Terminal from the shortcut
menu. You must wire the conditional terminal and either wire the count terminal or auto--‐index
an input array for the loop to execute and for the VI to run.
To convert a For Loop to a While Loop, right--‐click the For Loop and select Replace
with While Loop from the shortcut menu.
5.1.2 While Loop
A While loop repeats the sub diagram inside it until the conditional terminal, an input
terminal, receives a particular Boolean value. The Boolean value depends on the continuation
behavior of the While Loop. Right--‐click the conditional terminal and select Stop if True or
Continue if True from the shortcut menu. You also can wire an error cluster to the
conditional terminal, right--‐click the terminal, and select Stop on Error or Continue while
Error from the shortcut menu. The While Loop always executes at least once.
Below we see an empty While loop:
After you create a While Loop, you can use shift registers to pass values from one
iteration to the next. If you wire an array to a While Loop, you can read and process every
element in that array by enabling auto--‐indexing.
In order to convert a While Loop into a For Loop, right--‐click the While Loop and
select “Replace with For Loop” from the shortcut menu. To convert a While Loop into a
Timed Loop, right--‐click the While Loop and select “Replace with Timed Loop” from the
shortcut menu.
5.2 Structures
5.2.1 Case Structure
The Case Structure has one or more sub diagrams, or cases, exactly one of which executes
when the structure executes. The value wired to the selector terminal determines which case
to execute and can be Boolean, string, integer, or enumerated type. You may right--‐click the
structure border to add or delete cases. Use the Labeling tool to enter value(s) in the case
selector label and configure the value(s) handled by each case.
Below we see an empty Case structure:
25
Below we see an example of a Case structure with 2 cases, a “True” case and a
“False” case. Depending of the Boolean input value, the Numeric1 and Numeric2 is either
Added or Subtracted.
Below we see an example where we use “Sequence Local”, i.e., we pass a value from one
sequence to the next.
26
5.2.3 Event Structure
An Event structure has one or more sub diagrams, or event cases, exactly one of
which executes when the structure executes. The Event structure waits until an event
happens, then executes the appropriate case to handle that event. Right--‐click the structure
border to add new event cases and configure which events to handle. Wire a value to the
Timeout terminal at the top left of the Event structure to specify the number of milliseconds
the Event structure should wait for an event to occur. The default is –1, indicating never to
time out.
27
6 TROUBLESHOOTING AND DEBUGGING
This chapter explains the basic concepts of troubleshooting and debugging in LabVIEW.
6.1 How to find errors
If a VI does not run, it is a broken, or “nonexecutable”, VI. The Run button often appears
broken, shown at left, when you create or edit a VI. If it is still broken when you finish wiring
the block diagram, the VI is broken and will not run. Generally, this means that a required
input is not wired, or a wire is broken.
Click the broken Run button to display the Error list window, which lists all the
errors. Double--‐click an error description to display the relevant block diagram or front panel
and highlight the object that contains the error.
6.2 Highlight Execution
View an animation of the execution of the block diagram by clicking the Highlight
Execution button. Execution highlighting shows the flow of data on the block diagram from
one node to another using bubbles that move along the wires. Note! Execution highlighting
greatly reduces the speed at which the VI runs.
6.3 Probes
Use the Probe tool to check intermediate values on a wire as a VI runs.
When execution pauses at a node because of single--‐stepping or a breakpoint, you
also can probe the wire that just executed to see the value that flowed through that wire. You
also can create a custom probe to specify which indicator you use to view the probed data.
For example, if you are viewing numeric data, you can choose to see that data in a chart
within the probe. To create a custom probe, right--‐click a wire and select Custom Probe--‐
New from the shortcut menu.
28
6.4 Breakpoints
Use the Breakpoint tool to place a breakpoint on a VI, node, or wire on the block
diagram and pause execution at that location. When you set a breakpoint on a wire, execution
pauses after data pass through the wire. Place a breakpoint on the block diagram workspace
to pause execution after all nodes on the block diagram execute. When a VI pauses at a
breakpoint, LabVIEW brings the block diagram to the front and uses a marquee to highlight
the node or wire that contains the breakpoint. LabVIEW highlights breakpoints with red
borders for nodes and block diagrams and red bullets for wires. When you move the cursor
over an existing breakpoint, the black area of the Breakpoint tool cursor appears white. Use
the Breakpoint tool to click an existing breakpoint to remove it.
You may also right--‐click on the wire in order to set a breakpoint or open the Breakpoint
Manager.
29
Breakpoint Manager is a tool for enable, disable and delete breakpoints.
30
7 WORKING WITH DATA
This chapter explains the basic concepts of creating and using Sub Vis in LabVIEW.
7.1 Arrays
Arrays are very powerful to use in LabVIEW. In all your applications you would
probably use both One--‐Dimensional Arrays and Two--‐Dimensional Arrays.
7.1.1 Auto--‐Indexing
LabVIEW uses a powerful mechanism called “Auto--‐indexing”.
For Example you may use a For loop to create Array data like this:
Or you may use an Array like this in order to automatically specify number of iterations:
31
All these functions are basic (but very useful) array functions you will probably be
using in all your applications and VIs.
7.2 Cluster
Clusters group data elements of mixed types, such as a bundle of wires, as in a
telephone cable, where each wire in the cable represents a different element of the cluster. A
cluster is similar to a record or a struct in text--‐based programming languages. Bundling
several data elements into clusters eliminates wire clutter on the block diagram and reduces
the number of connector pane terminals that subVIs need. The connector pane has, at most,
28 terminals. If a front panel contains more than 28 controls and indicators that you want to
use programmatically, group some of them into a cluster and assign the cluster to a terminal
on the connector pane. Like an array, a cluster is either a control or an indicator. A cluster
cannot contain a mixture of controls and indicators.
Although cluster and array elements are both ordered, you must unbundle all cluster
elements at once rather than index one element at a time. You also can use the “Unbundle By
Name” function to access specific cluster elements.
7.2.1 Cluster Order
You may sort the different elements in the cluster by right--‐click on the cluster
border and select “Reorder Controls in Cluster…”
32
7.2.2 Cluster Elements
In order to manipulate and work with cluster LabVIEW offers lots of functions, such as the
“Bundle” and “Unbundle” functions.
In order to write to a cluster from the code, you may use the “Bundle” function or the
“Bundle By Name” function. See example below:
33
8 WORKING WITH STRINGS
Working and manipulating with strings is an important part in LabVIEW development.
On the Front panel we have the following String controls and indicators available from the
Control palette:
On the Block Diagram we have the following String functions available from the Functions
palette:
34
This function concatenates several strings into on string:
Use this when you want to replace or remove a certain text in a string.
Match Pattern
35
9 ERROR HANDLING
This chapter explains the basic concepts of handle errors in your code.
If a VI does not run, it is a broken, or “nonexecutable”, VI. The Run button often appears
broken, shown at left, when you create or edit a VI. If it is still broken when you finish wiring
the block diagram, the VI is broken and will not run. Generally, this means that a required
input is not wired, or a wire is broken. Click the broken Run button to display the Error list
window, which lists all the errors. Double--‐click an error description to display the relevant
block diagram or front panel and highlight the object that contains the error.
9.2 Error Wiring
Error handling is important in all programming languages. LabVIEW has powerful
mechanism for handling errors and error wiring.
You should always wire the Error cluster between all SubVIs, nodes, etc. that support this,
see example below.
36
The Error cluster contains of the following parts:
37
These are:
In general you should always show the error to the user. See LabVIEW Help for more details
of how to use these SubVIs.
38
10 WORKING WITH PROJECTS
This chapter explains the basic concepts of the project Explorer in LabVIEW.
10.1 Project Explorer
It is not necessary to use the Project Explorer when developing your LabVIEW code,
but it is an easy way to structure your code, especially for larger projects.
The project Explorer is necessary when you want to deploy your code into, e.g., an
executable (.exe) application, build a setup, etc.
The Project Explorer is also very useful when you integrate a source control tool, such as
Team Foundation Server, Visual Source Safe, etc. Then you may easily check files in and out
of the source code system.
In order to create a new Project in LabVIEW, simply select “Empty Project” from the
Getting Started window when you open LabVIEW.
39
10.2 Deployment
When your application is finished, you may want to distribute or deploy your application and
share it with others.
The Project Explorer gives you several choices when it comes to distribute and deploy your
application. Some of the options are:
Create an executable application (.exe) – this means that the target doesn’t need to
have LabVIEW installed on their computer. All the target need is LabVIEW Run--‐Rime,
which is a small installation package.
You may create your own installer, so all the target need is to run a setup.exe in order
to use your application
Other possibilities is to create a Web Service or a Shared Library (DLL) of your
application
All these options are available from the Project Explorer, just right--‐click on your
“Build Specifications” node.
40
Make sure you select a Startup VI.
There are lots of properties and setting you may use in order to create your
application, go through all the Categories in the Properties window.
When you have finished all the steps, just select “Build” in order to create your
application.
When you make changes in your application, it is easy to rebuild your application:
41
42
11 DESIGN TECHNIQUES
This chapter explains some useful techniques to use when creating your application.
43
a loop. If you have multiple operations within a loop, use multiple shift registers to store the
data values from those different processes in the structure.
Sometimes, you may want to change the order of the sequence, repeat one item in the
sequence more often than the other items, stop a sequence immediately, or have items in the
sequence that may execute only when certain conditions are met. Although your program
may not have any such requirements, there is always the possibility that the program must be
modified in the future. Therefore, a state programming architecture is a good choice, even if a
sequential programming structure is sufficient. The following list
describes more complex programming requirements that justify the use of a state
programming architecture for an application.
You need to change the order of the sequence
You must repeat an item in the sequence more often than other items
44
You want some items in the sequence to execute only when certain conditions are
met.
The State Machine approach in LabVIEW uses a Case structure inside a While loop to
handle the different states in the program, and the transitions between them. The Shift
Register is used to save data from and between the different states.
Below we see examples of a state machine principle implemented in LabVIEW.
Simple State Machine principle
45
11.4 Multiple Loops/Parallel programming
Often, you need to program multiple tasks so that they execute at the same time. In
LabVIEW tasks can run in parallel if they do not have a data dependency between them, and
if they are not using the same shared resource. An example of a shared resource is a file, or
an instrument.
Using multiple While loops is sometimes useful in applications that need to handle User
interactions in parallel with, e.g., DAQ operations, etc.
Below we see an example of how this structure could look like. The upper loop could handle
interaction with the user, while the lower loop could handle DAQ operations, such as reading
and writing to some I/O equipments.
46
In order to pass data between the loops, you may e.g. use local variables. The loop
may have different time cycles. The I/O may require faster cycles than the User interaction
loop.
11.5 Templates
You should create your own templates for such VI you use a lot. It is easy to create
your own templates for scratch, just create a VI as you normally do and then save it as a
template with the ending “.vit”. You may also convert a VI you already made just by
changing the extension to “.vit”.
You should copy your templates to the LabVIEW template folder which is default
located in “C:\Program Files\National Instruments\LabVIEW X.X\Templates\”.
The Templates will then be available from the Getting Started Window or File→New… in
LabVIEW.
I may case I have created a sub folder called “My Templates” where I place all my templates.
47
12 USER INTERFACE
This chapter explains the basic concepts of creating user--‐friendly Graphical User Interfaces
(GUI) in LabVIEW.
Below we see a Front Panel (GUI) with a “poor” design.
The information (Controls and Indicators) on the Front Panel is not structured. You
should group elements that naturally belong together and use different colors with care.
When creating Graphical User Interfaces (GUI) you should use the controls from the
System palette and not from the Modern or Classic palettes. Modern Controls may be used in
Sub Vis with no visible User Interface (for the user).
48
12.1 VI Properties
In order to make the appearance of the Window that hosts your application, you
should always make some changes in the “VI Properties”.
You find the “VI Properties” by right--‐click on the icon in the upper right corner of your VI.
The first thing you should change is the “Window title”. Here you may type appropriate name
of your application or SubVI.
The next you should do is to the “Customize” button in order to customize the Window
appearance.
49
Below we see an application with a simple and neat User Interface and with a Customized
Windows appearance.
Below we see a professional application created in LabVIEW that implement common GUI
objects such as a Toolbar, a Tree view, a List view, etc.
50
13 PLOTTING DATA
This chapter explains the basic concepts when plotting data in LabVIEW.
LabVIEW offers powerful functionality for plotting data. In the Graph palette we have lots of
useful controls for plotting and visualization of data.
Waveform Chart
Waveform Graph
XY Graph
13.1 Customizing
You may click on the “Plot Legend” in order to set colors, different line
styles, etc.
51
If you right--‐click on the Graph/Chart, you may set properties such as auto--‐scaling, etc.
52
You may also select which items that should be visible or not.
The “Graph Palette” lets you zoom in and out on the Graph, etc.
53
The NI-USRP driver currently supports the National Instruments’ LabVIEW
graphical development environment software for rapidly developing custom applications.
For more information, navigate to ni.com and search for “Out-of-the-Box Video with NI
USRP.” If you are viewing this digitally, click here to access this Developer Zone tutorial
directly.
54
14. FINDING HARDWARE & INSTALLING SOFTWARE
It is first important to understand the complexities and requirements of your
application to ensure that your wireless signal system is the right fit.
Identifying the Right Hardware
To help you identify the right hardware for your system, first navigate to ni.com/sdr.
At this portal you will find everything that you need to know about the USRP. You can use
the left-hand navigation facets to begin your search and narrow in on the right selection.
Finding the Specifications Online
The most important document for any device is the specifications document. This
document is housed on the product page for each device. Once you know the device of
interest, it is easiest to find the device using the search box in the upper right hand corner of
the ni.com website. Simply enter the product model number (i.e., 2920) and click search. An
example search query is shown on the next page, with the product page result outlined in red.
NI USRP Online Community
This ni.com community is the home for example VIs associated with the NI USRP,
"Universal Software Radio Peripheral." Browse to find a starting point, or post your own NI-
USRP-based examples.
Navigate to ni.com/sdr and click the Code Sharing Community image.
Purchasing Hardware
To receive a quote for NI USRP Hardware, you can add the hardware to your cart at
ni.com from the product page for the product. You can also call your NI Sales Engineer to
help design the best system for your application.
To speak with a technical representative, navigate to ni.com and click on the Contact Us link
on the homepage.
Installing Software
To acquire data from the USRP, you will need to first install a software development
environment and then the hardware driver.
Development Environment: LabVIEW Communications System Design Software
The development environment facilitates the interaction between the computer and user for
acquiring, processing, analyzing, and presenting measurement data. It is either a prebuilt
application with predefined functionality, or a programming environment for building
applications with custom functionality. Custom applications are often used to automate
multiple functions of a device, perform signal-processing algorithms, and display custom user
interfaces.
The primary development environment for NI-USRP is LabVIEW. LabVIEW is a
graphical programming language that abstracts the low-level complexities of text-based
programming into a visual language that scientists and engineers use worldwide to acquire,
analyze, process, and present data in the same environment.
Visit ni.com/labview-communications for more information and to download an evaluation.
Hardware Driver: NI-USRP
Driver software provides application software the ability to interact with a device. It
simplifies communication with the device by abstracting low-level hardware commands and
55
register-level programming. Typically, driver software exposes an application-programming
interface (API) that is used within a programming environment to build application software.
The hardware driver for the USRP is NI-USRP. The USRP driver comes with
example LabVIEW programs and help files to get you started.
56
15. NI-USRP LABVIEW DRIVER
When installed the NI USRP hardware driver automatically installs example
programs, help files, and functions.
NI-USRP Example Programs
To locate example files for using the USRP driver in LabVIEW, navigate to the
Examples » Hardware Input and Output » NI USRP Host.
NI-USRP Help Files
There are two forms of help offered within the LabVIEW development environment:
Context Help and Detailed Help:
Context Help:
The context help window displays basic information about LabVIEW objects when
you move the cursor over each object. To toggle the display of the context help window,
select View » Show Context Help or press <Ctrl-H>.
When you move the cursor over front panel and block diagram objects, the context
help window displays the icon for subVIs, functions, constants, controls, and indicators, with
wires attached to each terminal. When you move the cursor over dialog box options, the
context help window displays descriptions of those options.
57
Detailed LabVIEW Help
58
These categories are: Configure, Read/Write, and Close. These categories are included in
most data acquisition programs and are important programming models to consider when
creating a new LabVIEW Virtual Instrument (VI).
59
Fetch and Write Type Description
Complex Double Cluster
Complex Double
16-bit Integer
60
16. EXAMPLE
Digital Communications
Goals :
Open and run a digital communications example
Identify the parts of the block diagram and elements of the modulation/demodulation
process
Part A : 1. Pair up with the person or group next to you to find out who will open the transmit VI
and who will open the receive VI
In the Exercises folder, open either the USRP Packet Receiver or the USRP
Packet Transmitter VI
61
Note: If you decide to make any changes, click the STOP button and then change the
program options and run again. Changes do not take effect until you stop the program.
Click back to the Specify Modulation tab and change the modulation from QPSK to BPSK or
8-PSK and see how the Constellation Graph changes on the transmitter and the receiver
Note: Higher order modulation schemes may require optimizations such as digital
predistortion which is not covered in this course
62
17. TIPS & TRICKS
17.1 10 functions you need to know about
These are the 10 most useful functions in LabVIEW, so you could already now learn how to
use them and where to find them!
Build Array
This example using the Build Array function inside a For loop in order build an array with 10
elements.
The Index Array is extendible, so you can drag it out to find more than one elements:
63
Find the size of an arbitrary array:
Depending on the input data, go to the Alarm case or the Write Data case.
64
Use this when you want to replace or remove a certain text in a string.
65
This function converts a string into a number:
66
REFERENCES
67
68