Chapter 12 Buffering Your Way through Waveform Generation. NI LabVIEW Data Acquisition Basics

Add to My manuals
331 Pages

advertisement

Chapter 12 Buffering Your Way through Waveform Generation. NI LabVIEW Data Acquisition Basics | Manualzz

12

Buffering Your Way through

Waveform Generation

This chapter shows you which VIs to use in LabVIEW to perform buffered analog updates.

Buffered Analog Output

You can program single-buffered analog output in LabVIEW using an Easy

Analog Output VI, AO Generate Waveforms VI, as shown in Figure 12-1.

This VI writes an array of output values to the analog output channels at a rate specified by update rate. For example, if channels consists of two channels and the waveforms 2D array consists of two columns containing data for the two channels, LabVIEW writes values from each column to the corresponding channels at every update interval. After

LabVIEW writes all the values in the 2D array to the channels, the VI stops.

The signal level on the output channels maintains the value of the final value row in the 2D array until another value is generated. If you use channel names configured in the DAQ Channel Wizard in channels,

waveforms is relative to the units specified in the DAQ Channel Wizard.

Otherwise, waveforms is relative to volts.

Easy VIs contain error handling. If an error occurs in the AO Generate

Waveforms VI, a dialog box appears displaying the error number and description, and the VI stops running.

© National Instruments Corporation

Figure 12-1. Waveform Generation Using the AO Generate Waveforms VI

12-1

LabVIEW Data Acquisition Basics Manual

Chapter 12 Buffering Your Way through Waveform Generation

As with single-point analog output, you can use the Analog Output

Utility VI, AO Waveform Gen VI, for most of your programming needs.

This VI has several inputs and outputs that the Easy I/O VI does not have.

You have the option of having the data array generated once, several times,

or continuously through the generation count input. Figure 12-2 shows an

example diagram of how to program this VI.

Figure 12-2. Waveform Generation Using the AO Waveform Gen VI

In this example, LabVIEW generates the data in the array two times before stopping.

The Generate N Updates example VI, located in labview\examples\ daq\anlogout\anlogout.llb

, uses the AO Waveform Gen VI. Placing this VI in a loop and wiring the iteration terminal of the loop to the iteration input on the VI optimizes the execution of this VI. When iteration is 0,

LabVIEW configures the analog output channels appropriately. If the iteration is greater than 0, LabVIEW uses the existing configuration, which improves performance. With the AO Waveform Gen VI, you also can specify the limit settings input for each analog output channel. For more

information on limit settings, refer to Chapter 3, Basic LabVIEW Data

Acquisition Concepts

.

LabVIEW Data Acquisition Basics Manual

12-2 www.natinst.com

Chapter 12 Buffering Your Way through Waveform Generation

If you want even more control over your analog output application, use the

Intermediate DAQ VIs, as shown in Figure 12-3.

Figure 12-3. Waveform Generation Using Intermediate VIs

With these VIs, you can set up an alternate update clock source (such as an external clock or a clock signal coming from another device) or return the update rate. The AO Config VI sets up the channels you specify for analog output. The AO Write VI places the data in the buffer, the AO Start VI begins the actual generation at the update rate, and the AO Wait VI waits until the waveform generation completes. Then, the AO Clear VI clears the analog channels.

The Generate Continuous Sinewave VI, located in labview\examples\ daq\anlogout\anlogout.llb

, is similar in structure to Figure 12-3.

This example VI continually outputs a sine waveform through the channel you specify.

Changing the Waveform during

Generation—Circular-Buffered Output

When the waveform data is too large to fit in a memory buffer or is constantly changing, use a circular buffer to output the data. You also can use the Easy Analog Output VIs in a loop to create a circular-buffered output; but this sacrifices efficiency because Easy VIs configure, allocate, and deallocate a buffer every time they execute, which causes time gaps

between the data output. Figures 12-4 and 12-5 show two different ways to

perform circular-buffered analog output using the Intermediate VIs in

© National Instruments Corporation 12-3

LabVIEW Data Acquisition Basics Manual

Chapter 12 Buffering Your Way through Waveform Generation

LabVIEW. Figure 12-4 shows the AO Continuous Gen VI, which is more

efficient than the Easy Analog Output VIs in that it configures and allocates a buffer when its iteration input is 0 and deallocates the buffer when the

clear generation input is TRUE.

Figure 12-4. Circular Buffered Waveform Generation Using the AO Continuous Gen VI

With the AO Continuous Gen VI, you can configure the size of the data buffer and the limit settings of each channel. For more information on how

to set limit settings, refer to Chapter 3, Basic LabVIEW Data

Acquisition Concepts

.

The Continuous Generation example VI, located in labview\examples\ daq\anlogout\anlogout.llb

, uses the AO Continuous Gen VI. In this example, the data completely fills the buffer on the first iteration. On subsequent iterations, new data is written into one half of the buffer while the other half continues to output data.

To gain more control over your analog output application, use the

Intermediate VIs shown in Figure 12-5. With these VIs, you can set up an

alternate update clock source and you can monitor the update rate the VI actually uses. The AO Config VI sets up the channels you specify for

LabVIEW Data Acquisition Basics Manual

12-4 www.natinst.com

Chapter 12 Buffering Your Way through Waveform Generation analog output. The AO Write VI places the data in a buffer. The AO Start VI begins the actual generation at the update rate. The AO Write VI in the

While Loop writes new data to the buffer until you click the Stop button.

Then, the AO Clear VI clears the analog channels.

Figure 12-5. Circular Buffered Waveform Generation Using Intermediate VIs

The Function Generator VI, located in labview\examples\daq\ anlogout\anlogout.llb

, is a more advanced example than the one

shown in Figure 12-5. This VI changes the output waveform on-the-fly,

responding to changing signal types (sine or square), amplitude, offset, update rate, and phase settings on the front panel.

Eliminating Errors from Your

Circular-Buffered Application

If you get error number –10843 underFlowError , while performing circular-buffered output, it means your program cannot write data fast enough to the buffer to output the data at the update rate. To solve this problem, decrease the speed of the update rate. If adjusting the update rate does not get rid of the error in your application, increase the buffer size.

© National Instruments Corporation 12-5

LabVIEW Data Acquisition Basics Manual

Chapter 12 Buffering Your Way through Waveform Generation

Buffered Analog Output Examples

Another example VI in this library you might find helpful, Display and

Output Acq’d File (scaled) VI, is shown in Figure 12-6.

Figure 12-6. Display and Output Acq’d File (Scaled) VI

You can use this VI in conjunction with the Cont Acq to File (scaled) VI, located in labview\examples\daq\anlogin\anolgin.llb

. The

Display and Output Acq’d File (scaled) VI also is described in Chapter 7,

Buffering Your Way through Waveform Acquisition . After running the

Cont Acq to File (scaled) VI and saving your acquired data to disk, you can run the Display and Output Acq’d File (scaled) VI to generate your data from the file you created. This example uses circular-buffered output. To generate data at the same rate at which it was acquired, you must know the rate at which your data was acquired, and use that as the update rate.

LabVIEW Data Acquisition Basics Manual

12-6 www.natinst.com

advertisement

Related manuals

Download PDF

advertisement

Table of contents