Lab View 6

75
www.ni.com CHAPTER 1 Transducers, Signals, and Signal Conditioning Topics • Data Acquisition Overview • Transducers • Signals • Signal Conditioning Lesson 8 Data Acquisition and Waveforms

Transcript of Lab View 6

Page 1: Lab View 6

www.ni.comwww.ni.com

CHAPTER 1

Transducers, Signals, and Signal Conditioning

Topics• Data Acquisition Overview• Transducers• Signals• Signal Conditioning

Lesson 8Data Acquisition and Waveforms

Page 2: Lab View 6

System Overview

Page 3: Lab View 6

Transducer Overview

Topics• What is a Transducer?• Types of Transducers

Page 4: Lab View 6

What is a Transducer?

A transducer converts a physical phenomena into a measurable signal

Signal

PhysicalPhenomena

Page 5: Lab View 6

Signal Overview

Topics• Types of Signals• Information in a Signal

– State, Rate, Level, Shape, and Frequency

Page 6: Lab View 6

Signal Classification

Your Signal

AnalogDigital

Page 7: Lab View 6

Two possible levels:• High/On (2 - 5 Volts)• Low/Off (0 - 0.8 Volts)

Two types of information:• State• Rate

Digital Signals

Digital

Your Signal

Page 8: Lab View 6

Digital Signal Information

Digital

Your Signal

Page 9: Lab View 6

Analog Signals

Your Signal

Analog

Continuous signal• Can be at any value with

respect to timeThree types of information:

• Level• Shape• Frequency (Analysis required)

Page 10: Lab View 6

Analog Signal Information

Your Signal

Analog

Analysis

Required

Page 11: Lab View 6

Signal Conditioning Overview

Topics• Purpose of Signal Conditioning• Types of Signal Conditioning

Page 12: Lab View 6

Why Use Signal Conditioning?

• Signal Conditioning takes a signal that is difficult for your DAQ device to measure and makes it easier to measure

• Signal Conditioning is not always required– Depends on the signal being measured

Noisy, Low-Level Signal Filtered, Amplified Signal

Page 13: Lab View 6

Amplification• Used on low-level signals (i.e. thermocouples)

• Maximizes use of Analog-to-Digital Converter (ADC) range and

increases accuracy

• Increases Signal to Noise Ratio (SNR)

Low-Level Signal ExternalAmplifier DAQ Device

Lead Wires

InstrumentationAmplifier

Noise

ADC+_

Page 14: Lab View 6

DAQ Hardware Overview

Topics• Types of DAQ Hardware• Components of a DAQ device• Configuration Considerations

Page 15: Lab View 6

Data Acquisition Hardware

DAQ Hardware turns your PC into a

measurement and automation system

Computer

Your Signal

DAQ Device

Terminal Block

Cable

Page 16: Lab View 6

Terminal Block and Cable

Your Signal

Terminal Block

Cable

• Terminal Block and Cable route your signal to specific pins on your DAQ device

• Terminal Block and Cable can be a combination of 68 pin or 50 pin

50 pin connector

Page 17: Lab View 6

DAQ Device

Computer

DAQ Device

• Most DAQ devices have:– Analog Input– Analog Output– Digital I/O– Counters

• Specialty devices exist for specific applications– High speed digital I/O– High speed waveform generation– Dynamic Signal Acquisition (vibration, sonar)

• Connect to the bus of your computer• Compatible with a variety of bus protocols

– PCI, PXI/CompactPCI, ISA/AT, PCMCIA, USB, 1394/Firewire

Page 18: Lab View 6

Configuration Considerations

• Analog Input– Resolution– Range– Gain– Code Width– Mode (Differential, RSE, or NRSE)

• Analog Output– Internal vs. External Reference Voltage– Bipolar vs. Unipolar

Page 19: Lab View 6

Resolution

• Number of bits the ADC uses to represent a signal• Resolution determines how many different voltage

changes can be measured

• Example: 12-bit resolution

• Larger resolution = more precise representation of your

signal

# of levels = 2resolution = 212 = 4,096 levels

Page 20: Lab View 6

100 200150500

Time (s)

0

1.25

5.00

2.50

3.75

6.25

7.50

8.75

10.00

Amplitude(volts)

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

16-bit resolution

3-bit resolution

000

001

010

011

100

101

110

111

| ||||

Resolution Example• 3-bit resolution can represent 8 voltage levels• 16-bit resolution can represent 65,536 voltage levels

Page 21: Lab View 6

Range

• Minimum and maximum voltages the ADC can digitize• DAQ devices often have different available ranges

– 0 to +10 volts – -10 to +10 volts

• Pick a range that your signal fits in• Smaller range = more precise representation of your signal

– Allows you to use all of your available resolution

Page 22: Lab View 6

Range

100 200150500Time (s)

0

1.25

5.00

2.50

3.75

6.25

7.50

8.75

10.00

Amplitude(volts)

Range = 0 to +10 volts(5kHz Sine Wave)

3-bit resolution

000

001

010

011

100

101

110

111

| ||||

100 20015050Time (s)

0

-7.50-10.00

-5.00

-2.50

2.50

5.00

7.50

10.00

Amplitude(volts)

Range = -10 to +10 volts(5kHz Sine Wave)

3-bit resolution

000

001

010

011

100

101

110

111

| ||||

Proper Range• Using all 8

levels to represent your signal

Improper Range• Only using 4

levels to represent your signal

Page 23: Lab View 6

Gain• Gain setting amplifies the signal for best fit in

ADC range

• Gain settings are 0.5, 1, 2, 5, 10, 20, 50, or 100 for most devices

• You don’t choose the gain directly– Choose the input limits of your signal in LabVIEW– Maximum gain possible is selected– Maximum gain possible depends on the limits of your

signal and the chosen range of your ADC

• Proper gain = more precise representation of your signal

– Allows you to use all of your available resolution

Page 24: Lab View 6

Gain Example

100 200150500

Time (s)

0

1.25

5.00

2.50

3.75

6.25

7.50

8.75

10.00

Amplitude(volts)

Different Gains for 16-bit Resolution(5kHz Sine Wave)

Gain = 2

| ||||

Your Signal

Gain = 1

– Input limits of the signal = 0 to 5 Volts– Range Setting for the ADC = 0 to 10 Volts– Gain Setting applied by Instrumentation Amplifier = 2

Page 25: Lab View 6

• Code Width is the smallest change in the signal your system can detect (determined by resolution, range, and gain)

• Smaller Code Width = more precise representation of your signal

• Example: 12-bit device, range = 0 to 10V, gain = 1

code width = range

gain * 2 resolution

101 * 212

= 2.4 mVrange

gain * 2 resolution=

20

1 * 212= 4.8 mVIncrease range:

10

100 * 212= 24 VIncrease gain:

Code Width

Page 26: Lab View 6

Grounding Issues

• To get correct measurements you must properly ground your system

• How the signal is grounded will affect how we ground the instrumentation amplifier on the DAQ device

• Steps to proper grounding of your system:– Determine how your signal is grounded

– Choose a grounding mode for your Measurement System

Measurement System

SignalSource

VS

-

+

VM

Page 27: Lab View 6

Signal Source Categories

Grounded

+

_Vs

Floating

+

_Vs

Signal Source

Page 28: Lab View 6

Grounded Signal Source

• Signal is referenced to a system ground

– earth ground– building ground

• Examples:– Power supplies– Signal Generators– Anything that plugs into

an outlet ground

Grounded

+

_Vs

Signal Source

Page 29: Lab View 6

Floating Signal Source

Floating• Signal is NOT

referenced to a system ground

– earth ground– building ground

• Examples:– Batteries– Thermocouples– Transformers– Isolation Amplifiers

+

_Vs

Signal Source

Page 30: Lab View 6

Measurement System

• Three modes of grounding for your Measurement System

– Differential– Referenced Single-

Ended (RSE)– Non-Referenced Single-

Ended (NRSE)

• Mode you choose will depend on how your signal is grounded

Measurement System

-

+

Page 31: Lab View 6

VM

ACH (n)

ACH (n + 8)

+

_

Instrumentation

Amplifier

+

_

VS

+

_

AISENSE

AIGND

Measurement System

Differential Mode

Differential Mode• Two channels used for each signal

– ACH 0 is paired with ACH 8, ACH 1 is paired with ACH 9, etc.

• Rejects common-mode voltage and common-mode noise

Page 32: Lab View 6

VM

ACH (n)

ACH (n + 8)

+

_

Instrumentation

Amplifier

+

_

VS

+

AISENSE

AIGND_

RSE Mode

Referenced Single-Ended (RSE)• Measurement made with respect to system ground• One channel used for each signal• Doesn’t reject common mode voltage

Measurement System

Page 33: Lab View 6

VM

ACH (n)

ACH (n + 8)

+

_

Instrumentation

Amplifier

+

_

VS

+

_ AISENSE

AIGND

NRSE ModeNon-Referenced Single-Ended (NRSE)

• Variation on RSE• One channel used for each signal• Measurement made with respect to AISENSE not system ground• AISENSE is floating• Doesn’t reject common mode voltage

Measurement System

Page 34: Lab View 6

Choosing Your Measurement SystemSignal Source

Differential RSE NRSE

Measurement System

Grounded

+

_Vs

Floating

+

_Vs

Differential RSE NRSE

Measurement System

Page 35: Lab View 6

Options for Grounded Signal Sources

RSE

NRSE

Differential

BETTER

+ Rejects Common-Mode Voltage

- Cuts Channel Count in Half

NOT RECOMMENDED

- Voltage difference (Vg) between the two grounds makes a ground loop that could

damage the device

GOOD

+ Allows use of entire channel count

- Doesn’t reject Common-Mode Voltage

Page 36: Lab View 6

Options for Floating Signal Sources

RSE

NRSE

Differential

BEST

+ Rejects Common-Mode Voltage

- Cuts Channel Count in Half

- Need bias resistors

BETTER

+ Allows use of entire channel count

+ Don’t need bias resistors

- Doesn’t reject Common-Mode Voltage

GOOD

+ Allows use of entire channel count

- Need bias resistors

- Doesn’t reject Common-Mode Voltage

Page 37: Lab View 6

DAQ Software Overview

Topics• Levels of DAQ Software• NI-DAQ Overview• Measurement & Automation

Explorer (MAX) Overview

Page 38: Lab View 6

Levels of Software

DAQ Device

User

Page 39: Lab View 6

What is NI-DAQ?• Driver level software

– DLL that makes direct calls to your DAQ device

• Supports the following National Instruments software:– LabVIEW– Measurement Studio

• Also supports the following 3rd party languages:– Microsoft C/C++– Visual Basic– Borland C++– Borland Delphi

Page 40: Lab View 6

What is MAX?

• MAX stands for Measurement & Automation Explorer• MAX provides access to all your National Instruments

DAQ, GPIB, IMAQ, IVI, Motion, VISA, and VXI devices

• Used for configuring and testing devices

• Functionality broken into:

– Data Neighborhood

– Devices and Interfaces

– Scales

– Software

Icon on your

Desktop

Page 41: Lab View 6

Data Neighborhood• Provides access to the DAQ

Channel Wizard

• Shows configured Virtual Channels

• Includes utilities for testing and reconfiguring Virtual Channels

Page 42: Lab View 6

DAQ Channel Wizard• Interface to create

Virtual Channels for:– Analog Input– Analog Output– Digital I/O

• Each channel has:– Name and Description– Transducer type– Range (determines Gain)– Mode (Differential, RSE,

NRSE)– Scaling

Page 43: Lab View 6

Devices and Interfaces• Shows currently installed

and detected National Instruments hardware

• Includes utilities for configuring and testing your DAQ devices

– Properties– Test Panels

Page 44: Lab View 6

Properties

• Basic Resource Test– Base I/O Address – Interrupts (IRQ)– Direct Memory Access

(DMA)

• Link to Test Panels• Configuration for:

– Device Number– Range and Mode (AI)– Polarity (AO)– Accessories– OPC

Page 45: Lab View 6

Test Panels

• Utility for testing– Analog Input– Analog Output– Digital I/O– Counters

• Great tool for troubleshooting

Page 46: Lab View 6

Scales

• Provides access to DAQ Custom Scales Wizard

• Shows configured scales

• Includes utility for viewing and reconfiguring your custom scales

Page 47: Lab View 6

DAQ Custom Scales Wizard

• Interface to create custom scales that can be used with Virtual Channels

• Each scale has its own:

– Name and Description– Choice of Scale Type

(Linear, Polynomial, or Table)

Page 48: Lab View 6

Sampling Considerations

• Analog signal is continuous

• Sampled signal is series of discrete samples acquired at a specified sampling rate

• Faster we sample the more our sampled signal will look like our actual signal

• If not sampled fast enough a problem known as aliasing will occur

Actual Signal

Sampled Signal

Page 49: Lab View 6

Aliasing

Adequately

Sampled

Signal

Aliased

Signal

Page 50: Lab View 6

Nyquist Theorem

Nyquist Theorem• You must sample at greater than 2 times the

maximum frequency component of your signal to accurately represent the FREQUENCY of your signal

NOTE: You must sample between 5 - 10 times greater than the maximum frequency component of your signal to accurately represent the SHAPE of your signal

Page 51: Lab View 6

Nyquist Example

Aliased Signal

Adequately Sampled

for Frequency Only

(Same # of cycles)

Adequately Sampled

for Frequency and

Shape

100Hz Sine Wave

100Hz Sine Wave

Sampled at 100Hz

Sampled at 200Hz

Sampled at 1kHz100Hz Sine Wave

Page 52: Lab View 6

Data Acquisition Palette

Analog Input

Analog Output

Calibration and Configuration

Signal Conditioning

Digital I/O

Counter

DAQ Channel NameConstant

Page 53: Lab View 6

DAQ Channel Name Data Type• Allows you to use numeric channels

(0, 1, etc.) or virtual channels• Automatically detects all currently

configured virtual channels

Control Terminal Constant

Page 54: Lab View 6

Analog Input Palette

• Intermediate VIs– Built out of Advanced VIs

+ Highly recommended

+ Very flexible

• Easy VIs– Built out of Utility VIs

+ Easy to use

- Less flexible

• Utility VIs– Convenient

groupings of Intermediate VIs

• Advanced VIs– Building blocks for other levels

Easy VIs

Intermediate VIs

Advanced VIs

Utility VIs

Page 55: Lab View 6

Single-Point AI VIs

• Perform a software-timed, non-buffered acquisition

+ Good for battery testing, control systems

- Not good for rapidly changing signals due to software timing

AI Sample Channel– Acquires one point on one channel

AI Sample Channels– Acquires one point on multiple channels

Page 56: Lab View 6

Multiple-Point (Buffered) AI VIs• Perform a hardware-timed, buffered acquisition• Highly recommended for most applications• Allows triggering, continuous acquisition, different input limits for

different channels, streaming to disk, and error handling

AI Config– Configures your device, channels, buffer

AI Start– Starts your acquisition, configure triggers

AI Read– Returns data from the buffer

AI Clear– Clears resources assigned to the

acquisition

Page 57: Lab View 6

AI Config• Interchannel Delay

– Determines the time (in seconds) between samples in a scan

• Input Limits– Max and Min values for your signal

– Used by NI-DAQ to set gain

• Device– Number of the device (from MAX)

you are addressing

• Channels– Chooses what channel(s) you are

addressing

• Buffer Size– Number of scans the buffer

can hold

– A scan acquires one sample for every channel you specify

– 1000 scans x 2 channels = 2000 total samples

• Task ID– Passes configuration

information to other VIs

• Error In/Out– Receives/Passes any errors

from/to other VIs

Page 58: Lab View 6

Different Gains for Different Channels

• AI Config allows different gains for different channels• The first element of the input limits array corresponds to the

first element of the channel array

Gain = 2Gain = 20

Range = 0 to +10V

Page 59: Lab View 6

AI Start• Task ID In/Out

– Receives/Passes configuration information to/from other VIs

• Number of Scans to Acquire– Total number of scans acquired before the acquisition completes– Default value (-1) sets # of Scans to Acquire = Buffer Size (AI Config)– A value of 0 acquires continuously

• Scan Rate– Chooses the number of scans per second

• Error In/Out– Receives/Passes any errors from/to other VIs

Page 60: Lab View 6

AI Read & AI Clear• Number of Scans to Read

– Specifies how many scans to retrieve from the buffer– Default value (-1) sets # of Scans to Read = # of Scans to Acquire (AI Start)– If # of Scans to Acquire (AI Start) = 0, default for # of Scans to Read is 100

• Scan Backlog– Number of unread scans in the buffer

• Waveform Data– Returns t0, dt (inverse of scan rate), and Y array for your data

• Clears resources assigned to the device

Page 61: Lab View 6

Error Cluster• Cluster containing:

– Boolean - tells if an error occurred– Numeric - tells the error code– String - tells the source of the error

• Right-click on edge of cluster and select Explain Error for dialog box (see below) with more information

Terminal

Indicator

Page 62: Lab View 6

Clear Resources

Return Data from the Buffer

Display

Errors

Configure the Device

Start the Acquisition

Buffered Acquisition Flowchart

Page 63: Lab View 6

Buffered Acquisition• AI Start begins the acquisition

• Acquisition stops when the buffer is full

• AI Read will wait until the buffer is full to return data

• If error input is true then Config, Start, and Read pass the error on but don’t execute; Clear passes AND executes

Page 64: Lab View 6

Start the Acquisition

Return Data from the Buffer

Display

Errors Clear Resources

Configure the Device

Continuous Acquisition Flowchart

Done?NO

YES

Page 65: Lab View 6

Continuous Buffered AcquisitionDifferences from a buffered acquisition

• # of scans to acquire = 0• While loop around AI Read• Number of Scans to read does not = buffer size• Scan backlog tells how well you are keeping up

Page 66: Lab View 6

Analog Output Architecture

DAC

Channel 0

Channel 1

DACChannel 0

Channel 1

• Most E-Series DAQ devices have a Digital-to-Analog Converter (DAC) for each analog output channel

• DACs are updated at the same time• Similar to Simultaneous Sampling for Analog Input

Page 67: Lab View 6

Analog Output Palette

• Intermediate VIs– Built out of Advanced VIs

+ Highly recommended

+ Very flexible

• Easy VIs– Built out of Utility VIs

+ Easy to use

- Less flexible

• Utility VIs– Convenient

groupings of Intermediate VIs

• Advanced VIs– Building blocks for other levels

Easy VIs

Intermediate VIs

Advanced VIs

Utility VIs

Page 68: Lab View 6

Single-Point AO VIs

• Perform a software-timed, non-buffered generation

+ Good for generating DC voltages, or control systems

- Not good for waveform generation because software timing is slow

AO Update Channel– Generates one point on one channel

AO Update Channels– Generates one point on multiple channels

Page 69: Lab View 6

AO Update Channels

• Device– Number of the device (from

MAX) you are addressing– Ignored if using virtual channel

• Channels– Chooses what channel(s) you

are addressing– Can either be a number or a

virtual channel name– Uses the DAQ Channel Name

control

• Values– 1-D array of data – The first element of the

array corresponds to the first channel in your channels input

Page 70: Lab View 6

Multiple-Point (Buffered) AO VIs• Perform a hardware-timed, buffered generation• Highly recommended for most applications• Allows continuous generation, triggering, and error handling

AO Config– Configures your device, channels, buffer

AO Write– Writes data to the buffer

AO Start– Starts your generation

AO Wait– Waits until the generation is complete

AO Clear– Clears resources assigned to the

generation

Page 71: Lab View 6

Clear Resources

Display

Errors

Buffered Generation FlowchartWait Until Generation CompletesConfigure the Device

Start the Generation

Write Data to the Buffer

Page 72: Lab View 6

Buffered Generation• AO Write fills the buffer with waveform data• AO Start begins the generation• Without AO Wait the generation would start (AO Start) and

then end immediately after (AO Clear)• If error input is true then Config, Write, Start, and Wait pass

the error on but don’t execute; Clear passes AND executes

Page 73: Lab View 6

AO Write One Update

• Your analog output channel will continue to output the last value written to it until either:

– The device is reset (power off, reset VI)

– A new value is written

• Use AO Write One Update at the end of your generation to set the channel back to 0

Page 74: Lab View 6

Clear Resources

Start the GenerationConfigure the Device

Write Data to the Buffer

Display

Errors

Continuous Generation Flowchart

Done?NO

YES

Page 75: Lab View 6

Continuous GenerationDifferences from a buffered generation

• number of buffer iterations = 0• No AO Wait

– AO Wait would hang because the generation never completes

• While loop with AO Write– The second AO Write is used for error checking ONLY