lvb1day3

Upload: jobin-varghese

Post on 14-Apr-2018

213 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/27/2019 Lvb1day3

    1/79

    LV Basics I 157

    Lesson 8Data Acquisition and Waveforms

    A. About plug-in data acquisition (DAQ) boards

    B. About the organization of the DAQ VIs

    C. How to perform a single analog inputD. About the DAQ Wizards

    E. About waveform analog input

    F. How to write waveforms to file

    G. How to scan multiple analog channelsH. How to output an analog signal

    I. How to drive the digital I/O lines

    J. About buffered data acquisition

    You Will Learn:

  • 7/27/2019 Lvb1day3

    2/79

    LV Basics I 158

    DAQ library supports allDAQ boards

    LabVIEW uses the NI-DAQdriver-level software

    DAQ boards for Analog I/O Digital I/O Counter/timer I/O

    Data acquisition systemcomponents

    Overview

  • 7/27/2019 Lvb1day3

    3/79

    LV Basics I 159

    Analog Input Considerations

    Single-Ended vs. Differential

    Resolution

    100 200150500

    Time (ms)0

    1.25

    5.00

    2.50

    3.75

    6.25

    7.50

    8.75

    10.00

    Amp

    litude(volts)

    16-Bit Versus 3-Bit Resolution(5kHz Sine Wave)

    16-bit

    3-bit

    000

    001

    010

    011

    100

    101

    110

    111

    | ||||

    Range

    Gain

  • 7/27/2019 Lvb1day3

    4/79

    LV Basics I 160

    Analog Input Considerations

    Sampling Rate

    Averaging

    Adequately Sampled

    Aliased due to undersampling

    1 0

    1 * 212 = 2 .4 mV

    2 0

    1 * 21 2 = 4 .8 mV Code Width

  • 7/27/2019 Lvb1day3

    5/79

    LV Basics I 161

    DAQ Software Architecture Windows

    LabVIEW for Windows

    DAQ Library VIs

    Win95 Device Manager

    nidaq32.dll for

    Windows

    Windows Registry

    DAQ Board

    DAQ-STC

  • 7/27/2019 Lvb1day3

    6/79

    LV Basics I 162

    DAQ Hardware Configuration

    Measurement & Automation Explorer (MAX)

  • 7/27/2019 Lvb1day3

    7/79

    LV Basics I 163

    The DAQ Signal Accessory

  • 7/27/2019 Lvb1day3

    8/79

    LV Basics I 164

    Exercise 8-1 on page 8-10

    Students examine MAX and the

    DAQ Configuration Utility

    Time to complete: 15 min.

  • 7/27/2019 Lvb1day3

    9/79

    LV Basics I 165

    DAQ VI Organization

    Analog Input

    Analog Output

    Digital I/O

    Counter

    Calibration andConfiguration

    Signal Conditioning

  • 7/27/2019 Lvb1day3

    10/79

    LV Basics I 166

    Analog Input VI Organization

    Easy I/O VIs

    Advanced VIsUtilitly VIs

    Intermediate VIs

    Single-point VIs

  • 7/27/2019 Lvb1day3

    11/79

    LV Basics I 167

    DAQ Channel Name Control

    Data type used tocommunicate with

    DAQ boards

    Enter channel names

    by number or byvirtual channel name

    defined in MAX

  • 7/27/2019 Lvb1day3

    12/79

    LV Basics I 168

    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.

  • 7/27/2019 Lvb1day3

    13/79

    LV Basics I 169

    Exercise 8-3 on page 8-25

    Students modify Measurement Averaging.viTime to complete: 20 min.

  • 7/27/2019 Lvb1day3

    14/79

    LV Basics I 170

    DAQ Wizards

    DAQ Channel Wizard

    DAQ Solution Wizard

  • 7/27/2019 Lvb1day3

    15/79

    LV Basics I 171

    Exercise 8-4 on page 8-27

    Students use the DAQ Solution Wizard

    Time to complete: 10 min.

  • 7/27/2019 Lvb1day3

    16/79

    LV Basics I 172

    Waveform Analog Input

    AI Acquire Waveform

    VI displays a dialog box if an error occurs

    VI returns a waveform datatype

  • 7/27/2019 Lvb1day3

    17/79

    LV Basics I 173

    Exercise 8-5 on page 8-33

    Students Build Acquire Waveform.viTime to complete: 25 min.

  • 7/27/2019 Lvb1day3

    18/79

    LV Basics I 174

    Writing Waveform Data to File

    Waveform File I/O

    subpalette of the

    Waveform palette

    Three VIs for writing

    waveform data to file

  • 7/27/2019 Lvb1day3

    19/79

    LV Basics I 175

    Exercise 8-6 on page 8-37

    Students buildAcquire Waveform to File.viTime to complete: 15 min.

  • 7/27/2019 Lvb1day3

    20/79

    LV Basics I 176

    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

  • 7/27/2019 Lvb1day3

    21/79

    LV Basics I 177

    Scanned Waveforms and Graphs

    Plot all waveforms on the same waveform graph

  • 7/27/2019 Lvb1day3

    22/79

    LV Basics I 178

    Exercise 8-7 on page 8-40

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

  • 7/27/2019 Lvb1day3

    23/79

    LV Basics I 179

    Exercise 8-8 on page 8-41

    (Optional)

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

  • 7/27/2019 Lvb1day3

    24/79

    LV Basics I 180

    Analog Output VIs

    Single-point VI

    Waveform Generation VI

  • 7/27/2019 Lvb1day3

    25/79

    LV Basics I 181

    Exercise 8-9 on page 9-43

    Students examine and runVoltage OutputExample.vi with Voltmeter.vi

    Time to complete: 15 min.

  • 7/27/2019 Lvb1day3

    26/79

    LV Basics I 182

    Digital Input and Output VIs

    Line = single TTL signal

    Port = collection of lines (4 or 8)

  • 7/27/2019 Lvb1day3

    27/79

    LV Basics I 183

    Exercise 8-10 on page 8-48

    Students examine and run Digital Example.viTime to complete: 20 min.

  • 7/27/2019 Lvb1day3

    28/79

    LV Basics I 184

    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

  • 7/27/2019 Lvb1day3

    29/79

    LV Basics I 185

    Analog Input Operations

    SequenceAI Config Configure channels, gains, and

    computer buffer

    AI Start Set trigger conditions, program clocks,

    and start DAQAI 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

  • 7/27/2019 Lvb1day3

    30/79

    LV Basics I 186

    Analog Input Intermediate VIs

    Buffered Analog Input

    Continuous Data Acquisition

  • 7/27/2019 Lvb1day3

    31/79

    LV Basics I 187

    Exercise 8-11 on page 8-52

    (Optional)

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

  • 7/27/2019 Lvb1day3

    32/79

    LV Basics I 188

    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

  • 7/27/2019 Lvb1day3

    33/79

    LV Basics I 189

    Additional Exercises on page 8-56

    8-12 -- Students build Temp Monitor with LED.viTime to complete: 25 min.

    8-13 -- Students use the DAQ Solution Wizard toopen Simple Data Reader.vi

    Time to complete: 25 min.

  • 7/27/2019 Lvb1day3

    34/79

    LV Basics I 190

    Lesson 9Instrument Control

    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

    You Will Learn:

  • 7/27/2019 Lvb1day3

    35/79

    LV Basics I 191

    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 availableInstruments Computer

  • 7/27/2019 Lvb1day3

    36/79

    GPIB Communication

    1965 1987 1990 1992 19931975

    GPIB Instrument

    GPIB Cable

    GPIB Interface

    LV Instr 1-192

    1999

  • 7/27/2019 Lvb1day3

    37/79

    LV Basics I 193

    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)1

    12

    13

    24

    DIO5DIO6DIO7DIO8RENGND (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

    DIO1DIO2DIO3DIO4EOIDAV

    NRFDNDAC

    IFCSRQATN

    SHIELD

  • 7/27/2019 Lvb1day3

    38/79

    LV Basics I 194

    GPIB Software Architecture Windows

  • 7/27/2019 Lvb1day3

    39/79

    LV Basics I 195

    Configuring GPIB Board and Instruments

    Measurement & Automation Explorer (MAX)

  • 7/27/2019 Lvb1day3

    40/79

    LV Basics I 196

    Exercise 9-1 on page 9-7

    Students use MAX to examine the GPIB board

    settings and communicate with an instrumentTime to complete: 20-25 min.

  • 7/27/2019 Lvb1day3

    41/79

    LV Basics I 197

    Instrument Drivers

    More than 650 LabVIEW instrument drivers

    Programming simplified to high-level API

  • 7/27/2019 Lvb1day3

    42/79

    LV Basics I 198

    Installing and Finding Instrument Drivers

    NI Web site orInstrument Driver CD

    Install the instrument

    driver VI Library into

    LabVIEW\instr.libdirectory

    Access drivers fromInstrument I/O

    Instrument Driverssubpalette

  • 7/27/2019 Lvb1day3

    43/79

    LV Basics I 199

    Exercise 9-2 on page 9-13

    Students open the Getting Started InstrumentDriver VI for the NI Instrument Simulator

    Time to complete: 20-25 min.

  • 7/27/2019 Lvb1day3

    44/79

    LV Basics I 200

    Instrument Drivers

    Instrument drivers have a similar hierarchy

    Instrument Driver VI Tree

  • 7/27/2019 Lvb1day3

    45/79

    LV Basics I 201

    Instrument Driver Inputs and Outputs

    VISA Sessions

    A connection or link to a specific instrument

    Created after instrument is initialized

    Used throughout VI whenever youcommunicate with that specific instrument

    Error Clusters

    NI DEVSIM Initialize.vi

  • 7/27/2019 Lvb1day3

    46/79

    LV Basics I 202

    VISA Resource Name

    Exact name and

    location of the

    instrument

    Use the VISA

    Resource Name

    control (like the DAQChannel Name control)

    You can specify the

    full resource name

    or the VISA Alias

  • 7/27/2019 Lvb1day3

    47/79

    LV Basics I 203

    Putting It All Together

    Initialize instrument

    Do operation(s)

    Close instrument

    Check error status

    VISA Sessions

    Error Clusters

  • 7/27/2019 Lvb1day3

    48/79

    LV Basics I 204

    Exercise 9-3 on page 9-21

    Students build the Voltage Monitor.viTime to complete: 10 min.

  • 7/27/2019 Lvb1day3

    49/79

    LV Basics I 205

    Virtual Instrument Software Architecture

    Standard API for programming instruments Platform independent

    Interface independent

    Interface to Serial, GPIB, and VXI instruments

    Uses VISA.DLL

    NI-488.2OS Calls NI-VXI

    GPIB VXISerial PXI

    VISA

  • 7/27/2019 Lvb1day3

    50/79

    LV Basics I 206

    VISA Terminology

    ResourceInstrument, Serial Port, or Parallel PortSessionConnection to a Resource

    Instrument DescriptorResource location

    Format: Interface Type::Address::INSTR

    Examples:

  • 7/27/2019 Lvb1day3

    51/79

    LV Basics I 207

    Instrument Descriptor Syntax

    Resource Name contains interface info

    VISA Aliases also work

    Interface Resource Name Grammar

    Serial ASRL[board][::INSTR]

    GPIB GPIB[board]::pr imary address[::INSTR]

    VXI VXI[board]::VXI log ical add ress[::INSTR]

    GPIB-VXI GPIB-VXI[board][::GPIB-VXI prim aryaddress]::VXI log ical add ress[::INSTR]

  • 7/27/2019 Lvb1day3

    52/79

    LV Basics I 208

    VISA Functions

  • 7/27/2019 Lvb1day3

    53/79

    LV Basics I 209

    Exercise 9-4 on page 9-29

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

  • 7/27/2019 Lvb1day3

    54/79

    Serial Communication

    RS-232 Instrument

    RS-232 Cable

    PC SerialPort

    LV Instr 1-210

    Popular means of communication betweencomputer 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

  • 7/27/2019 Lvb1day3

    55/79

    LV Basics I 211

    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 softwarehandshaking options

  • 7/27/2019 Lvb1day3

    56/79

    LV Basics I 212

    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

    Pin DTE DCE

    1 DCD Input Output2 RxD I O3 TxD O I4 DTR O I5 Com - -6 DSR I O

    7 RTS O I8 CTS I O9 RI I O

  • 7/27/2019 Lvb1day3

    57/79

    LV Basics I 213

    Serial VIs and Functions

    Found in Serial

    subpalette under

    Instrument I/O

    Based on VISA functions

    Serial VIs and functionsalso work with parallel

    port communication

  • 7/27/2019 Lvb1day3

    58/79

    LV Basics I 214

    Serial I/O Example

    Initialize the serial port settings

    Write commands to the device

    Read device response

    Check for errors

  • 7/27/2019 Lvb1day3

    59/79

    LV Basics I 215

    Exercise 9-5 on page 9-38

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

  • 7/27/2019 Lvb1day3

    60/79

    LV Basics I 216

    Waveform Transfers (Optional)

    ASCII Waveforms

    Binary Waveforms

    1-byte integers

    2-byte integers

  • 7/27/2019 Lvb1day3

    61/79

    LV Basics I 217

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

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

  • 7/27/2019 Lvb1day3

    62/79

    LV Basics I 218

    Exercise 9-7 on page 9-49

    (Optional)

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

  • 7/27/2019 Lvb1day3

    63/79

    LV Basics I 219

    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

  • 7/27/2019 Lvb1day3

    64/79

    LV Basics I 220

    Additional Exercises on page 9-51

    9-8Students use the NI DEVSIM Getting

    Started VI to communicate in serial mode with

    a deviceTime to complete: 20-25 min.

    9-9Students modify a previous VI and save it

    as Voltage Data to File.viTime to complete: 20-25 min.

  • 7/27/2019 Lvb1day3

    65/79

    LV Basics I 221

    Lesson 10

    VI Customization

    You Will Learn:

    A. How to customize the panel windowB. How to create pop-up panels

    C. How to use Key Navigation

    D. How to edit VIs with disabled options

    E. About customizing palettes

  • 7/27/2019 Lvb1day3

    66/79

    LV Basics I 222

    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

  • 7/27/2019 Lvb1day3

    67/79

    LV Basics I 223

    Window Appearance

    Only affects VI panel while VI is running

  • 7/27/2019 Lvb1day3

    68/79

    LV Basics I 224

    Window Size

    Set minimum and current panel size

    Adjust size of panel relative to the monitor

    Scale objects on panel as window resizes

  • 7/27/2019 Lvb1day3

    69/79

    LV Basics I 225

    Creating Pop-Up Panels

    Use Top-Level Application Window or Dialog

    appearance types Create custom window appearance

  • 7/27/2019 Lvb1day3

    70/79

    LV Basics I 226

    SubVI Node Setup

    Access SubVI Node Setup by right-clickingon subVI icon on calling VIs diagram

    Affects only that single instance of the subVI

  • 7/27/2019 Lvb1day3

    71/79

    LV Basics I 227

    Exercise 10-1 on page 10-8

    Students build Use Pop-Up Graph.viand

    Pop-Up Graph.viTime to complete: 20-30 min.

    K N i ti

  • 7/27/2019 Lvb1day3

    72/79

    LV Basics I 228

    Key Navigation

    Assigns keyboard strokes to front panel controls

  • 7/27/2019 Lvb1day3

    73/79

    LV Basics I 229

    Exercise 10-2 on page 10-13

    Students buildTemperature System.viTime to complete: 25-30 min.

    C bi ti f VI P ti (O ti l)

  • 7/27/2019 Lvb1day3

    74/79

    LV Basics I 230

    Combination of VI Properties (Optional)

    Opens, runs, and closes LabVIEW

    without user intervention

    Save with Options to make backups

  • 7/27/2019 Lvb1day3

    75/79

    LV Basics I 231

    Exercise 10-3 on page 10-19(Optional)

    Students modifyEdit_Me.viTime to complete: 25-30 min.

  • 7/27/2019 Lvb1day3

    76/79

    LV Basics I 232

    Customizing LabVIEW Palettes (Optional)

    Access different palette setsfrom the Options button in

    Control or Function palette

    Display either icon or text

    Control and Function palettes

    Editi C t l & F ti P l tt

  • 7/27/2019 Lvb1day3

    77/79

    LV Basics I 233

    Editing Control & Function Palettes

    Modify the existing

    palettes

    Create your own

    palettes

  • 7/27/2019 Lvb1day3

    78/79

    S mmar

  • 7/27/2019 Lvb1day3

    79/79

    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 FunctionBrowser window