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

Chapter 6

Analog Input

when using the Easy VIs. To call the AI Config VI only once, put it outside of the While Loop in your program. The AI Config VI configures channels, selects a high/low limit, and generates a taskID. Then, the AI Config VI passes the taskID and error cluster into the While Loop. LabVIEW calls the AI Single Scan VI to retrieve a scan and passes the returned data to the My Single-Scan Processing VI. With this VI, you can program any processing needs your application calls for, such as looking for a limit to be exceeded. The VI then passes the data through the Build Array function to a waveform chart for display on the front panel. The Wait Until Next ms Multiple (metronome) function controls the loop timing. After you enter a scan rate, the application converts the value into milliseconds and passes the converted value to the Wait Until Next ms Multiple function. The loop then executes at the rate of scanning. The loop ends when you press the stop button or an when error occurs. After the loop finishes, the Simple Error Handler VI displays any errors that occurred.

The previous examples use software-timed acquisition. With this type of acquisition, the CPU system clock controls the rate at which you acquire data. The system clock can be interrupted by user interaction, so if you do not need a precise acquisition rate, use software-timed analog input.

Using Analog Input/Output Control Loops

When you want to output analog data after receiving some analog input data, use analog input/output (I/O) control loops. With control loops, this process is repeated over and over again.

The single-point analog input and output VIs support several analog I/O control loops at once because you can acquire analog inputs from

several different channels in one scan and write all the analog output values with one update. You perform a single analog input call, process the analog output values for each channel, and then perform a single analog output call to update all the output channels.

The following sections describe the two different types of analog I/O control loop techniques: software-timed and hardware-timed analog I/O.

Using Software-Timed Analog I/O Control Loops

With software-timed analog control loops the analog acquisition rate and subsequent control loop rate are controlled by a software timer such as the Wait Until Next ms Multiple timer. The acquisition is performed during each loop iteration when the AI Single Scan VI is called and the control loop is executed once for each time interval. Your loop timing can be interrupted by any user interaction, which means your acquisition rate is

© National Instruments Corporation

6-17

LabVIEW Measurements Manual

Chapter 6

Analog Input

not as consistent as that which can be achieved through hardware-timed control loops. Generally, if you do not need a precise acquisition rate for your control loop, software timing is appropriate.

In addition to user interaction, a large number or large-sized front panel indicators, like charts and graphs, affect control loop rates. Refreshing the monitor screen interrupts the system clock, which controls loop rates. Therefore, keep the number of charts and graphs to a minimum when you are using software-timed control loops.

Refer to the Analog IO Control Loop (immed) VI in the examples\daq\ anlog_io\anlog_io.llb for an example of software-timed control loops. Open this example VI to see how it performs software-timed analog I/O using the AI Read One Scan and AO Write One Update VIs.

The AI Read One Scan VI configures your DAQ device to acquire data from analog input channels 0 and 1. Once your program acquires a data point from channels 0 and 1, it performs calculations on the data and outputs the results through analog output channels 0 and 1. Because the iteration count is connected to the AI Read One Scan and AO Write One Update VIs, the application configures the DAQ device for analog input and output only on the first iteration of the loop. The loop rate as well as

the acquisition rate is specified by loop rate. The reason why the actual loop period is important is because user interaction affects the loop and acquisition rate. For example, pressing the mouse button interrupts the system clock, which controls the loop rate. If your analog acquisition rate for control loops does not need to be consistent, use software-timed control loops.

Refer to the examples in the examples\daq\solution\control.llb for more control examples.

Using Hardware-Timed Analog I/O Control Loops

For more precise timing of your control loops and more precise analog input scan rate, use hardware-timed control loops.

Refer to the Analog IO Control Loop (hw timed) VI in the examples\ daq\anlog_io\anlog_io.llb for an example of hardware-timed, non-buffered control loops. Open and examine its block diagram.

With hardware-timed control loops, your acquisition is not interrupted by user interaction. Hardware-timed analog input automatically places the data in your DAQ device FIFO buffer at an interval determined by the analog input scan rate. You can synchronize your control loop diagram to

LabVIEW Measurements Manual

6-18

www.ni.com

Chapter 6

Analog Input

this precise analog input scan rate by repeatedly calling the AI Single Scan VI to read the oldest data in the FIFO buffer.

The AI Single Scan VI returns as soon as the next scan has been acquired by the DAQ device. If more than one scan is stored in the DAQ device FIFO buffer when the AI Single Scan VI is called, then LabVIEW was not able to keep up with the acquisition rate. You can detect this by monitoring the data remaining output of the AI Single Scan VI. In other words, you have missed at least one control loop interval. This indicates that your software overhead is preventing you from keeping up with your hardware-timed loop rate. In the Analog IO Control Loop (hw timed) VI, the loop too slow Boolean indicator is set to TRUE whenever this occurs.

In this block diagram, the AI Config VI configures the device to acquire data on channels 0 and 1. The application does not use a buffer created in CPU memory, but instead uses the DAQ device FIFO buffer. Input limits (also known as limit settings) affects the expected range of the input signals. The AI Start VI begins the analog acquisition at the loop rate (scan rate) parameter. On the first iteration of the loop, the AI Single Scan VI reads the newest data in the FIFO buffer. Some data may have been acquired between the execution of the AI Start and the AI Single Scan VIs. On the first iteration of the loop, the application reads the latest data acquired between the AI Start and the AI Single Scan VIs. On every subsequent iteration of the loop, the application reads the oldest data in the FIFO buffer, which is the next acquired point in the FIFO buffer.

If more than one value was stored in the DAQ device FIFO buffer when you read it, your application was not able to keep up with the control loop acquisition and you have not responded with one control loop interval. This eventually leads to an error condition, which makes the loops complete. After the application completes analog acquisition and generation, the

AI Clear VI clears the analog input task.

The block diagram of the Analog IO Control Loop (hw timed) VI also includes a waveform chart in the control loop. This reduces your maximum loop rate. You can speed up the maximum rate of the control loop by removing this graph indicator.

You easily can add other processing to your analog I/O control loop by putting the analog input, control loop calculations, and analog output in the first frame of a sequence inside the loop, and additional processing in subsequent frames of the sequence. Keep in mind that this additional processing must be less than your control loop interval. Otherwise, you will not be able to keep up with your control loop rate.

© National Instruments Corporation

6-19

LabVIEW Measurements Manual

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