Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
LabVIEW-Measurements.pdf
Скачиваний:
61
Добавлен:
29.05.2015
Размер:
3.37 Mб
Скачать

Chapter 7

Analog Output

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 7-1 shows an example block diagram of how to program this VI.

Figure 7-1. 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, available in 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.

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

Intermediate DAQ VIs, as shown in Figure 7-2.

Figure 7-2. 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

LabVIEW Measurements Manual

7-4

www.ni.com

Chapter 7

Analog Output

until the waveform generation completes. Then, the AO Clear VI clears the analog channels.

The Generate Continuous Sinewave VI, available in examples\daq\ anlogout\anlogout.llb, is similar in structure to Figure 7-2. 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.

Open the AO Continuous Gen VI to see one way to perform circular-buffered analog output using the Intermediate VIs. This VI 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.

With the AO Continuous Gen VI, you can configure the size of the data buffer and the limit settings of each channel. Refer to the Basic LabVIEW Data Acquisition Concepts section in Chapter 5, Introduction to Data Acquisition in LabVIEW for more information about how to set limit settings.

Refer to the Continuous Generation VI in the examples\daq\ anlogout\anlogout.llb for an example of using 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 7-3. 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 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. The AO Clear VI clears the analog channels.

© National Instruments Corporation

7-5

LabVIEW Measurements Manual

Chapter 7

Analog Output

 

 

 

 

Figure 7-3. Circular Buffered Waveform Generation Using Intermediate VIs

Refer to the Function Generator VI in the examples\daq\ anlogout\anlogout.llb for a more advanced example than the one shown in Figure 7-3. 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 an error, –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 or increase the buffer size.

Circular-Buffered Analog Output Examples

Another example VI in this library you might find helpful is the Display and Output Acq’d File (scaled) VI.

You can use this VI in conjunction with the Cont Acq to File (scaled) VI, available in examples\daq\anlogin\anolgin.llb. 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.

Sometimes in performing analog output, the rate that your updates occur is just as important as the signal level. This is called waveform generation, or buffered analog output. For example, you might want your DAQ device to act as a function generator. You can do this by storing one cycle of sine wave data in an array and programming the DAQ device to generate the

LabVIEW Measurements Manual

7-6

www.ni.com

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]