Labview vi
Now when the program runs it will stop when the user pressed the button. A corresponding stop button is added to the front panel. Select ‘create control’ and a stop button terminal is created on the block diagram. Right click the red stop terminal in the bottom right of the while loop.
LabVIEW Contextual HelpĪ front panel button can be used to stop the loop.
LABVIEW VI CODE
All the code within the loop will execute repeatedly until it’s told to stop. Drag the loop around the DAQ Assistant function and the indicator. Select Programming > Structures > While Loop. To add a loop, right-click the block diagram to open the Functions Palette. To make this data acquisition repeat continuously a loop is needed. When the program runs, the pre-configured number of samples for each of the five channels are read from the hardware and displayed in the graph. The program can be run by clicking the white run arrow in the top left of the block diagram or front panel. This is due to the data type changing from a double (orange) to a dynamic data type used by Express VIs. Notice the colour of the Waveform Graph indicator has changed colour. By clicking on the output of the DAQ Assistant function and then input of the Waveform Graph indicator a wire is created that will pass the data from the function to the front panel indicator when the program runs. The function has an output called ‘data’. Once configured, clicking OK will put the DAQ Assistant function on the block diagram. Here the range, number of samples to read, acquisition rate etc can be selected. The final window configures each channel to be read. In this example a piece of hardware called USB_Voltage_DAQ is being used and 5 channels (a0 to a4) are being read. Simple hardware integration is another advantage of LabVIEW. The second window shows the hardware and channels that can be selected. The first configuration window allows the type of measurement to be selected. These configuration-based functions are called Express VIs and they are used to speed up development time for simple programs. This means that a configuration wizard will appear to select the data channels when the function is placed on the block diagram. The DAQ assistant is a configuration-based function.
LABVIEW VI DRIVERS
DAQmx is a hardware driver and there are hundreds of third party drivers available for LabVIEW. To do this, right-click on the block diagram to open the Functions Palette and select Measurement I/O > NI-DAQmx > DAQ Assistant to put the function on the block diagram. To get data to display in the graph a LabVIEW function is needed to read data from the USB data acquisition (DAQ) device. There is now a ‘terminal’ for the waveform graph that allows data to be wired in to show on the front panel. The next step in this LabVIEW tutorial and demonstration is to select the block diagram. LabVIEW screen showing VI Front Panel Graph Select block diagram This is a huge advantage over text-based languages where user interfaces can be very time consuming. The Controls Palette has many click and drop controls and indicators that can be used to quickly build a user interface. Select Silver > Graph > Waveform Graph (Silver) and place the item on the front panel. To do this, right-click on the front panel to bring up the Controls Palette. The next step in this tutorial is to put a graph on the front panel that can show the acquired data. LabVIEW screen showing VI Front Panel & Block Diagram Add graph to front panel The block diagram is white and is where the code that defines the application is added. The front panel has a grey background and is where the user interface of the VI is created. The front panel and block diagram of the VI will open. Unlike traditional instruments, a VI doesn’t have fixed functionality meaning it can adapt as a project expands. This will open up a new LabVIEW VI or Virtual Instrument. With the computer turned on and booted up ready to go, the first stage in the tutorial or demonstration is to open LabVIEW, and then select File > New VI. This type of demonstration / tutorial is useful because it is the type of routine that is often required within LabVIEW. The demonstration below how LabVIEW can be used to quickly read five channels of data from a USB data acquisition device and write the measurements to a file. Straightforward LabVIEW demonstrations are able to demonstrate the basic principles behind LabVIEW programming and act as a useful tutorial. What is LabVIEW? LabVIEW environment LabVIEW VIs Programming Drivers Example / tutorial LabVIEW Tutorial: Demo & Example LabVIEW is simple to use and a straightforward demo can easily provide some of the main steps required in starting a LabVIEW programme.