You are on page 1of 79

Lesson 8 Data Acquisition and Waveforms

You Will Learn: A. About plug-in data acquisition (DAQ) boards B. About the organization of the DAQ VIs C. How to perform a single analog input D. About the DAQ Wizards E. About waveform analog input F. How to write waveforms to file G. How to scan multiple analog channels H. How to output an analog signal I. How to drive the digital I/O lines J. About buffered data acquisition
LV Basics I 157

Overview
DAQ library supports all DAQ boards LabVIEW uses the NI-DAQ driver-level software DAQ boards for Analog I/O Digital I/O Counter/timer I/O Data acquisition system components

LV Basics I 158

Analog Input Considerations


Single-Ended vs. Differential Resolution
(5kHz Sine Wave)
10.00

Range Gain

16-Bit Versus 3-Bit Resolution


8.75 7.50 6.25 5.00 3.75 2.50 1.25 0| 0
111 110 101 100 011 010 001 000
| | | |

16-bit 3-bit

Amplitude (volts)

50

100 Time (ms)

150

200

LV Basics I 159

Analog Input Considerations


Code Width Sampling Rate
Adequately Sampled 10 1 * 2 12 = 2.4 mV 20 1 * 2 12 = 4.8 mV

Aliased due to undersampling

Averaging
LV Basics I 160

DAQ Software Architecture Windows


Win95 Device Manager LabVIEW for Windows

DAQ Library VIs

nidaq32.dll for Windows

DAQ-STC

Windows Registry DAQ Board


LV Basics I 161

DAQ Hardware Configuration


Measurement & Automation Explorer (MAX)

LV Basics I 162

The DAQ Signal Accessory

LV Basics I 163

Exercise 8-1 on page 8-10

Students examine MAX and the

DAQ Configuration Utility


Time to complete: 15 min.

LV Basics I 164

DAQ VI Organization
Analog Input Analog Output Digital I/O Counter

Calibration and Configuration


Signal Conditioning

LV Basics I 165

Analog Input VI Organization

Easy I/O VIs


Intermediate VIs Utilitly VIs Advanced VIs

Single-point VIs

LV Basics I 166

DAQ Channel Name Control


Data type used to communicate with DAQ boards Enter channel names by number or by virtual channel name defined in MAX

LV Basics I 167

Exercise 8-2 on page 8-23


Students build Voltmeter.vi *This VI will be used in a later exercise.
Time to complete: 20 min.

LV Basics I 168

Exercise 8-3 on page 8-25


Students modify Measurement Averaging.vi
Time to complete: 20 min.

LV Basics I 169

DAQ Wizards
DAQ Channel Wizard DAQ Solution Wizard

LV Basics I 170

Exercise 8-4 on page 8-27

Students use the DAQ Solution Wizard


Time to complete: 10 min.

LV Basics I 171

Waveform Analog Input


AI Acquire Waveform VI displays a dialog box if an error occurs

VI returns a waveform datatype

LV Basics I 172

Exercise 8-5 on page 8-33


Students Build Acquire Waveform.vi
Time to complete: 25 min.

LV Basics I 173

Writing Waveform Data to File


Waveform File I/O subpalette of the Waveform palette Three VIs for writing waveform data to file

LV Basics I 174

Exercise 8-6 on page 8-37

Students build Acquire Waveform to File.vi


Time to complete: 15 min.

LV Basics I 175

Scanning Multiple Analog Input Channels


AI Acquire Waveforms VI accepts multiple channel names as input 1D array of waveforms is returned Order of the channels (in DAQ Channel Name) determine the array order

LV Basics I 176

Scanned Waveforms and Graphs


Plot all waveforms on the same waveform graph

LV Basics I 177

Exercise 8-7 on page 8-40


Students examine and run Scan Example.vi
Time to complete: 15 min.

LV Basics I 178

Exercise 8-8 on page 8-41 (Optional)


Students build Scan Two Waveforms.vi
Time to complete: 20-25 min.

LV Basics I 179

Analog Output VIs


Single-point VI

Waveform Generation VI

LV Basics I 180

Exercise 8-9 on page 9-43


Students examine and run Voltage Output Example.vi with Voltmeter.vi
Time to complete: 15 min.

LV Basics I 181

Digital Input and Output VIs


Line = single TTL signal

Port = collection of lines (4 or 8)

LV Basics I 182

Exercise 8-10 on page 8-48

Students examine and run Digital Example.vi


Time to complete: 20 min.

LV Basics I 183

Buffered Data Acquisition (Optional)

Intermediate VIs - Highly recommended for most applications - Continuous acquisition with triggering available - Interval scanning - Different gains for different channels - Streaming data to disk - Error handling
LV Basics I 184

Analog Input Operations


Sequence AI Config Configure channels, gains, and computer buffer AI Start Set trigger conditions, program clocks, and start DAQ AI Read Read data from buffer (repeat if continuous) AI Clear Stop DAQ, free board and computer resources General VI parameters taskID to control execution order Bold terminals Default values
LV Basics I 185

Analog Input Intermediate VIs

Buffered Analog Input

LV Basics I 186

Continuous Data Acquisition

Exercise 8-11 on page 8-52 (Optional)


Students build Continuous Acquire with MIO.vi
Time to complete: 20-25 min.

LV Basics I 187

Summary
Use the Measurement & Automation Explorer to configure DAQ boards and virtual channels DAQ VIs organized into five subpalettes Analog Input, Analog Output, Digital I/O, Counter, Configuration and Calibration, and Signal Conditioning Analog Input and Output subpalettes are divided into levels Easy I/O, Intermediate, Advanced, and Utility VIs Easy I/O contains VIs for Single-channel analog input and output Single-channel waveform input and output Multichannel waveform input and output Digital input and output Continuous DAQ can be performed using the intermediate VIs of AI Config, AI Start, AI Read, and AI Clear
LV Basics I 188

Additional Exercises on page 8-56

8-12 -- Students build Temp Monitor with LED.vi


Time to complete: 25 min.

8-13 -- Students use the DAQ Solution Wizard to open Simple Data Reader.vi
Time to complete: 25 min.

LV Basics I 189

Lesson 9 Instrument Control


You Will Learn: A. An overview of instrument control B. About GPIB communication and configuration C. About LabVIEW instrument drivers D. How to use instrument driver VIs E. About Virtual Instrument Software Architecture F. How to use the VISA functions G. About serial port communication H. About waveform transfers
LV Basics I 190

Instrument Control Overview


Control any instrument if you know the following: Type of connector on the instrument Type of cables needed Electrical properties involved Communication protocols used Software drivers available
Instruments
Computer

LV Basics I 191

GPIB Communication
GPIB Instrument GPIB Interface

GPIB Cable

1965
LV Instr 1-192

1975

1987

1990

1992 1993 1999

GPIB Hardware Specifications


Max cable length between devices = 4 m (2 m average) Max cable length = 20 m Max number of devices = 15 (2/3 powered on)

DIO1 DIO2 DIO3 DIO4 EOI DAV NRFD NDAC IFC SRQ ATN SHIELD

13

12 24

DIO5 DIO6 DIO7 DIO8 REN GND (TW PAIR W/DAV) GND (TW PAIR W/NRFD) GND (TW PAIR W/NDAC) GND (TW PAIR W/IFC) GND (TW PAIR W/SRQ) GND (TW PAIR W/ATN) SIGNAL GROUND

LV Basics I 193

GPIB Software Architecture Windows

LV Basics I 194

Configuring GPIB Board and Instruments


Measurement & Automation Explorer (MAX)

LV Basics I 195

Exercise 9-1 on page 9-7

Students use MAX to examine the GPIB board settings and communicate with an instrument
Time to complete: 20-25 min.

LV Basics I 196

Instrument Drivers
More than 650 LabVIEW instrument drivers Programming simplified to high-level API

LV Basics I 197

Installing and Finding Instrument Drivers


NI Web site or Instrument Driver CD Install the instrument driver VI Library into LabVIEW\instr.lib directory Access drivers from Instrument I/O Instrument Drivers subpalette

LV Basics I 198

Exercise 9-2 on page 9-13


Students open the Getting Started Instrument Driver VI for the NI Instrument Simulator
Time to complete: 20-25 min.

LV Basics I 199

Instrument Drivers
Instrument drivers have a similar hierarchy

Instrument Driver VI Tree


LV Basics I 200

Instrument Driver Inputs and Outputs

NI DEVSIM Initialize.vi

VISA Sessions A connection or link to a specific instrument Created after instrument is initialized Used throughout VI whenever you communicate with that specific instrument Error Clusters
LV Basics I 201

VISA Resource Name


Exact name and location of the instrument Use the VISA Resource Name control (like the DAQ
Channel Name control)

You can specify the full resource name or the VISA Alias

LV Basics I 202

Putting It All Together


VISA Sessions

Error Clusters


LV Basics I 203

Initialize instrument Do operation(s) Close instrument Check error status

Exercise 9-3 on page 9-21


Students build the Voltage Monitor.vi
Time to complete: 10 min.

LV Basics I 204

Virtual Instrument Software Architecture

VISA
Serial
OS Calls

GPIB
NI-488.2

VXI
NI-VXI

PXI

Standard API for programming instruments



LV Basics I 205

Platform independent Interface independent Interface to Serial, GPIB, and VXI instruments Uses VISA.DLL

VISA Terminology
ResourceInstrument, Serial Port, or Parallel Port SessionConnection to a Resource Instrument DescriptorResource location Format: Interface Type::Address::INSTR

Examples:

LV Basics I 206

Instrument Descriptor Syntax


Resource Name contains interface info VISA Aliases also work Interface Resource Name Grammar Serial GPIB VXI ASRL[board][::INSTR] GPIB[board]::primary address[::INSTR] VXI[board]::VXI logical address[::INSTR]

GPIB-VXI GPIB-VXI[board][::GPIB-VXI primary address]::VXI logical address[::INSTR]

LV Basics I 207

VISA Functions

LV Basics I 208

Exercise 9-4 on page 9-29


Students build Read VISA Waveform.vi
Time to complete: 20-25 min.

LV Basics I 209

Serial Communication
RS-232 Instrument PC Serial Port

RS-232 Cable

Popular means of communication between computer and peripheral device Data sent one bit at a time across the cable Used for low transfer rates or long distances Only a cable is needed since most computers have at least one available serial port
LV Instr 1-210

Serial Communication

Terminology Baud rate bits per second Data bits inverted logic and LSB first Parity optional error-checking bit Stop bits 1, 1.5, or 2 inverted bits at data end Flow control hardware and software handshaking options
LV Basics I 211

Serial Hardware Connection


RS-232 Most PCs DCE or DTE configurations 9-pin or 25-pin Single-ended RS-422 Macintosh 8-pin Differential RS-485 Multidrop Industrial Automation
LV Basics I 212

Pin 1 2 3 4 5 6 7 8 9 DCD RxD TxD DTR Com DSR RTS CTS RI

DTE DCE Input Output I O O I O I I O O I I O I O

Serial VIs and Functions


Found in Serial subpalette under Instrument I/O Based on VISA functions

Serial VIs and functions also work with parallel port communication

LV Basics I 213

Serial I/O Example

Initialize the serial port settings Write commands to the device Read device response Check for errors

LV Basics I 214

Exercise 9-5 on page 9-38


Students examine and run Serial Write & Read.vi
Time to complete: 15-20 min.

LV Basics I 215

Waveform Transfers (Optional)


ASCII Waveforms

Binary Waveforms 1-byte integers

2-byte integers

LV Basics I 216

Exercise 9-6 on page 9-45 (Optional)


Students examine and run Waveform Example.vi
Time to complete: 20 min.

LV Basics I 217

Exercise 9-7 on page 9-49 (Optional)


Students build Binary Waveform.vi
Time to complete: 20-25 min.

LV Basics I 218

Summary
LabVIEW can communicate with any instrument that connects to your computer if you know the interface type Use the Measurement & Automation Explorer (MAX) to detect, configure, and test your GPIB interface and instruments An instrument driver eliminates the need for your to have detailed knowledge of the specific strings used by an instrument Instrument Library more than 650 instruments supported Instrument driver VIs share a common hierarchy and come with an example to help you get started VISA a standard protocol for using multiple types of I/O and instrument driver development Serial library contains functions for serial communication You need to know the format of the returned data string in order to convert it to the correct values
LV Basics I 219

Additional Exercises on page 9-51 9-8 Students use the NI DEVSIM Getting Started VI to communicate in serial mode with
a device
Time to complete: 20-25 min.

9-9 Students modify a previous VI and save it as Voltage Data to File.vi


Time to complete: 20-25 min.

LV Basics I 220

Lesson 10 VI Customization

You Will Learn: A. B. C. D. E. How to customize the panel window How to create pop-up panels How to use Key Navigation How to edit VIs with disabled options About customizing palettes

LV Basics I 221

Customizing VI Properties
Access VI Properties... by right-clicking on icon pane or selecting it from the File menu Affects every instance of that VI in all applications

LV Basics I 222

Window Appearance
Only affects VI panel while VI is running

LV Basics I 223

Window Size
Set minimum and current panel size Adjust size of panel relative to the monitor Scale objects on panel as window resizes

LV Basics I 224

Creating Pop-Up Panels


Use Top-Level Application Window or Dialog appearance types Create custom window appearance

LV Basics I 225

SubVI Node Setup


Access SubVI Node Setup by right-clicking on subVI icon on calling VIs diagram Affects only that single instance of the subVI

LV Basics I 226

Exercise 10-1 on page 10-8


Students build Use Pop-Up Graph.vi and

Pop-Up Graph.vi
Time to complete: 20-30 min.

LV Basics I 227

Key Navigation
Assigns keyboard strokes to front panel controls

LV Basics I 228

Exercise 10-2 on page 10-13

Students build Temperature System.vi


Time to complete: 25-30 min.

LV Basics I 229

Combination of VI Properties (Optional)


Opens, runs, and closes LabVIEW without user intervention

Save with Options to make backups

LV Basics I 230

Exercise 10-3 on page 10-19


(Optional)
Students modify Edit_Me.vi
Time to complete: 25-30 min.

LV Basics I 231

Customizing LabVIEW Palettes (Optional)


Access different palette sets from the Options button in Control or Function palette Display either icon or text Control and Function palettes

LV Basics I 232

Editing Control & Function Palettes


Modify the existing palettes Create your own palettes

LV Basics I 233

Exercise 10-4 on page 10-25 (Optional)


Students modify the Functions Palette
Time to complete: 20-25 min.

LV Basics I 234

Summary
Use VI Properties to set VI execution, window, and documentation options Use SubVI Node Setup to set execution options for a single instance of a subVI Use the Key Navigation option to assign front panel controls to a keyboard key combination Use the Save with Options from the file menu to make backups of your VIs You can often edit VIs by aborting them from the diagram of another VI You can fully customize the Control and Function palettes from the Option button in the Function Browser window
LV Basics I 235

You might also like