LabVIEW Documentation Resources


LabVIEW modules and toolkits also provide additional documentation specific to those products. In the LabVIEW Help, documentation for modules you have installed appears after the Controlling Instruments book in the Contents tab. Documentation for toolkits you have installed appears under the Toolkits book.LabVIEW includes extensive documentation for new and experienced LabVIEW users.

How to choose the right sensor for your measurement system

Design World Editorial Director Paul J. Heney discusses all things sensors with Jim Schwartz, CompactDAQ Product Marketing Engineer for National Instruments. Schwartz explains the types of sensors available, what they do, common measurements that they take and what kind of signals are created for each. In addition, he talks about some of the issues that engineers sometimes have in selecting the right sensor, as well as exploring some of the resources available.



How to Choose the Right Bus for Your Measurement System

You have hundreds of different data acquisition (DAQ) devices to choose from, each with a variety of compatible buses. It can be difficult to select the right bus for your application needs. Each bus has different advantages and is optimized for throughput, latency, portability, or distance from a host. This podcast examines the most common PC bus options and outlines the technical considerations to keep in mind when choosing the right bus for your measurement application.

Tips on Connecting LabVIEW to Industrial Networks


Most new industrial machines or retrofits require some form of connectivity to an existing communications infrastructure. From industrial fieldbuses to 3G cellular networks to web interfaces, even though each design has its own unique requirements, you can use LabVIEW to make the connection.

LabVIEW is a visual programming platform and development environment that can be used to support the connection of laptops and Programmable Automation Controllers (PACs), including CompactRIO, PXI/cPCI systems, and Industrial PCs (IPCs) to a variety of industrial networks and web technologies.

A CompactRIO programmable automation controller connected with the NI 9144 modular EtherCAT slave chassis over standard CAT5 cabling.
When coupled with PACs, this platform offers a superset of traditional PLC functions, making it easy to retrofit or upgrade an existing installation. PACs outperform PLCs in the areas of high-speed analog measurements and intensive processing algorithms needed for applications like machine condition monitoring (MCM) or machine vision. Because LabVIEW can interface to most industrial networks, PACs are commonly used to augment the PLCs in an existing machine or automation process to increase efficiency or predict maintenance of mechanical gearboxes and motors.
Integration to existing systems
The simplest way to integrate LabVIEW into an existing system is to use the basic analog and digital I/O capabilities of PACs and PLCs to exchange signals. LabVIEW will provide simple updates to a PLC system such as pass/fail status.
For example, a customer used CompactRIO and LabVIEW to acquire a high-speed voltage reading from a gamma-based thickness sensor, and perform the complex inline signal processing required on that data to calculate an extremely accurate thickness measurement for the steel they were rolling. Then they output a simple analog voltage in the 0-10 V range that corresponded to the thickness of the steel over a cable connected to the existing PLCs controlling the rolling mill. The thickness measurement that the PLCs now use is more accurate than before and the customer can produce better quality and more consistent steel. In the end, they maintained their existing PLC control scheme but augmented it to build a better product.
That is just one example of how LabVIEW can be used with communication schemes. Here’s a quick overview of how to connect it to each of the popular industrial networks.
OPC
A widely used method to integrate multiple vendors’ automation controllers is OPC (OLE for process control). OPC is a Windows based standard for accessing industrial devices. Through the OPC client/server architecture, LabVIEW can integrate with a range of PLCs and PACs from a laptop or IPC. The OPC server manages the various industrial communications and provides a common bus for controllers, sensors, and actuators without physically wiring them together. You can use communication gateways as needed to extend to more specialized protocols.
Modbus TCP and Modbus Serial
Modbus TCP and Modbus Serial are two of the more commonly used industrial protocols. Through multiple levels of functionality, LabVIEW supports Modbus TCP and Modbus Serial on any Ethernet or serial port on PCs or PACs. Through its graphical configuration assistant, you can create a Modbus TCP or Modbus Serial I/O server. LabVIEW can act as a Modbus master or slave and specify the different registers to read and write. In addition to the I/O server functions, there is a direct API to the Serial or TCP/IP versions of Modbus for flexibility and performance. That API can query or write to registers, coils, and discrete I/O. It can also check for exceptions.
PROFIBUS
PROFIBUS is an industrial field bus originally developed in Europe. With more than 30 million installed nodes, it is the communication standard for Siemens Automation PLCs, smart sensors, actuators, and I/O. NI supports the more commonly used version of PROFIBUS, DP (Distributed Peripherals).
Our PROFIBUS PCI, PXI, and CompactRIO one-port interfaces function as masters or slaves, connecting to PC-based controllers. The interfaces include a stand-alone configurator and a LabVIEW driver for human machine interface (HMI) and SCADA applications. You can perform PROFIBUS device control or automated test using these interfaces.
EtherCAT
Published as part of the IEC 61158 specification, Ethernet for Control Automation Technology (EtherCAT) implements a master-and-slave architecture over standard Ethernet cabling, typically in a line topology. As a control bus, it focuses on deterministic, high-speed I/O for single-point applications such as machine control and motion.
Both master and slave devices are available for use with EtherCAT. For the master controller, real-time PACs with dual Ethernet ports on the CompactRIO, PXI, and industrial controller platforms are available. There is also an EtherCAT slave with field-programmable gate array (FPGA) intelligence, the 8-slot NI 9144 chassis for C Series I/O modules.
EtherNet/IP
EtherNet/IP is also a real-time Ethernet protocol, managed by the Open DeviceNet Vendors Association (ODVA) and commonly found in Rockwell Automation (Allen-Bradley) PLCs. It communicates over standard Ethernet using TCP/IP and UDP/IP using a master (scanner) and slave (adapter) network architecture.
The EtherNet/IP Drive for Industrial Communication handles explicit messaging and adapter communication on this network. LabVIEW can use explicit messaging to read from and write to tags on a PLC supported by RSLogix 5000 and RSLogix 500. The adapter communication lets LabVIEW function as a slave (adapter), providing implicit I/O data to a remote PLC.
PCMCIA-FOUNDATION-fieldbus-interfaces
NIVarious USB, PCI, and PCMCIA FOUNDATION Fieldbus interfaces can control Fieldbus networks from LabVIEW.
DeviceNet
DeviceNet is another industrial protocol managed by ODVA and commonly found in Rockwell Automation (Allen-Bradley) PLCs. Unlike Ethernet/IP, which is based on the Ethernet physical layer, DeviceNet is based on the CAN physical layer and increases strength and interconnectivity by specifying various parameters, such as the required cable length, connectors, and baud rates.
The DeviceNet for Control PCI and PXI master (scanner) interfaces manage and control a network of DeviceNet slaves. Included with these interfaces is the NI-Industrial Communications for DeviceNet software, which offers a high-level API that supports drag-and-drop I/O variables and explicit messaging function blocks. DeviceNet for Test interfaces for PCI, PXI, and PCMCIA have master (scanner) and slave (adapter) support, best used for testing DeviceNet products. The included test software consists of a configurator, analyzer, and the NI-DNET driver, which provides low-level functions.
CANopen
CANopen is a higher-level protocol based on the CAN physical layer and was developed as a standard embedded network with highly flexible configuration capabilities. Originally designed for motion control applications, it is common in many industry segments including medical equipment, off-road vehicles, public transportation, and building automation.
For CANopen master function, the CANopen LabVIEW Library has high-level, easy-to-use functions to create CANopen master applications. These functions cover the spectrum of CANopen master applications, including transmitting and receiving service data objects (SDOs) and process data objects (PDOs), network management, heartbeat and node guarding, emergencies, and synchronization objects. Because the CANopen functions work on top of NI-CAN driver software, all PCI, PXI, and PCMCIA high-speed NI Series 2 CAN devices can operate as fully functional CANopen master interfaces.
industrial-networks
DeviceNet, Modbus, Profibus, DNP3, and EtherNet/IP are some of the industrial networks supported in LabVIEW.
DNP3
DNP3 (Distributed Network Protocol) was developed by GE Harris to create a standard protocol specification for vendors of power grid SCADA (Supervisory Control and Data Acquisition) components. Since 1993, this open and public protocol has been managed by the DNP3 Users Group. DNP3 is commonly used in North American electric and water utilities for communication between SCADA masters and outstations like Remote Terminal Units (RTUs).
The Industrial Communications for DNP3 software driver programs LabVIEW targets DNP3 outstation devices with such functions as power quality monitoring, phasor measurements, and other smart grid-related analysis. Because DNP3 is built on standard Ethernet, the NI implementation of DNP3 is portable across multiple LabVIEW supported platforms, including Industrial PCs, PXI, and CompactRIO. The DNP3 software driver supports Ethernet communication, file transfer, and time synchronization between master and outstation. Also, multiple communication channels per outstation and multiple sessions (logical devices) per channel may be used.
PCI,-PXI-and-CompactRIO-PROFIBUS-DP-interfaces
PCI, PXI and CompactRIO PROFIBUS DP interfaces can be set for master and slave support.
FOUNDATION Fieldbus
FOUNDATION Fieldbus is a bi-directional serial communication protocol commonly used in process automation. It uses a system of distributed control with intelligent devices, where the control schedule can be downloaded onto the devices instead of a central control system. Of its two versions, NI interfaces support H1.
The USB-8486, PCI-FBUS, and PCMCIA-FBUS series interfaces connect these fieldbus’s devices to standard desktop, industrial, and notebook PCs. With the PCI-FBUS, an IPC can act as the host within this protocol system. Use the USB-8486 and PCMCIA-FBUS for portable data logging and in-the-field configuration and maintenance of devices and networks.
Web and Enterprise connectivity
Enterprise connectivity is also playing a larger role in deployed systems so that off-site users can view the real-time data and change system parameters on the fly. LabVIEW graphical tools provide functions for Web-published software interfaces, Web services, common gateway interface programming, short message service (SMS), and e-mail messaging. In combination with HTTP and FTP servers on CompactRIO, these functions can be used for remote monitoring and control, phone or e-mail alerts, and file transfers of logged data. Leveraging NI third-party partners, you can share data via global cellular networks or synchronize global processes via GPS in LabVIEW.

HOW TO FIND THE MOBILE NUMBER OF ANY SIM CARD


S.No.
Operator
Dial For Display Mobile Number on Screen
1
Docomo*580#
2
Airtel*400*2*1*1*0#, *333#(roaming.), *140*6575#, *141*1600#., *121*9#,
3
Idea*112#, *789# , *100#, *131*1#
4
Vodafone*777*0#, *555# , *111*2#
5
Reliance*1# , *#1#,
6
BSNL24365 N ask them
7
AIRCEL....*888#
8
uninor*555#
9
Videocon*1#

Listing post titles in alphabetical or chronological order

In this tutorial I will show you how to list the titles of your blog’s 1000 2000 most recent posts. If you are looking for an alternative to Blogger’s Archive gadget, then this might be it. This list can also be used as a Table Of Contents. This list is made possible with the use of Yahoo! Pipe.

See the demo in Blogger Sentral Widget Showcase.

The list comes with several options:

1. List them inside a widget or in a post static page.

2. Arrange the titles in alphabetical or chronological order. If you use your blog as an online serial novel, then chronological order is just what you need.

3. Append (or not) a comment count at the end of each title.

4. Choose numbered or bulleted list style.

Let’s get started,
 <script type="text/javascript">
 var d = new Date();
 var time = d.getHours();
 
 if (time < 10) {
 document.write("<b>Good morning</b>");
 } else {
 document.write("<b>Good day</b>");
 }
 </script>
 

Use this option if you want to put the list on a separate page. (You can then access it via a tab.)

1. Create a new page by going to Posting > Edit Pages and clicking the New Page button.

2. Click Edit HTML tab to switch to HTML mode.

3. Copy and paste the code into the editor.

4. Click Post Options at the bottom of the editor. Under the Edit HTML Settings heading, select Ignore newlines.


5. Publish and view your post . The list should appear inside the page.

6. Then add a link to the page from your homepage. This can be done by adding navigation tabs. If you have the page gadget installed, this is added automatically by Blogger.

7. If you want to remove the extras (sidebars, footer etc.) from the page, read Apply different layout/styling to static pages.

3) Put the list in a gadget

Use this option if you want to put the list on a sidebar, making it visible at all times.

1. Go to Design > Page Elements.

2. Click Add A Gadget link.

3. Select HTML/Javascript gadget.

4. Enter the title of your widget e.g. All Posts List.

5. Copy and paste the code inside the content box.

Replace http://www.bloggersentral.com (the value of YourBlogUrl) in code line 20 with your own blog URL. Do not include the trailing slash (as in .com/). Refer to step 4 for options/customizations.

Reminder: In the process of editing your code, never switch to Rich Text mode. Doing so will add line breaks (
) in your code, rendering the code useless.

6. Save and view your blog.



4) Customizing the list

Below are a few available customizations/options:

§ Listing order -the default order is alphabetical. To change to chronological order, just change the word alphabet in code line 21 to chrono.

§ Comment count - comment count is displayed by default. To remove comment count, delete code line 13.

§ List style -the default is bulleted list. To change to numbered list, replace ul (in line 4 and 16) with ol.

§ Style the list with the inline style attribute in line 4.

§ If your list becomes too long, you might want to put it in a scroll box



5) Editing the pipe (optional)

If you want further customize the widget output, you need to edit the (Yahoo) pipe itself. Follow the steps below:

1. Go to the Yahoo! pipe.

2. Log in to your Yahoo! account.

3. Create a clone by clicking the Clone button.

4. Click edit source to edit it in anyway you like.

5. When you’re done editing and saving, test run it by clicking Run Pipe button to confirm the output of the pipe.

6. To use your edited pipe, copy the pipe id and paste it to replace the existing id in line 22. (To get the id, look in your browser’s address bar. The id is the end part the URL when you are viewing or editing the pipe.)

Enjoy!

Lab .2(d) While Loop / For Loop / Shift Register / Selectors


More than often, we would like an action to repeat until a condition is satisfied; for example, we may want to accept data from the user until the datum provided is of a particular value, at which point we stop processing any further data. This is where loop structures such as the While Loop come in handy.

A While Loop executes the functions it contains until the conditional terminal receives a specific Boolean value (True or False). By default, the conditional terminal is Stop If True( ); this means that, when we connect a Boolean control (a control that returns either True or False) to the terminal, the While Loop will stop iterating as soon as the Boolean control returns True. Another kind of conditional terminal, called Continue If True, is available by right-clicking on the conditional terminal.

There is another terminal called the iteration terminal, which is an output terminal ( ). Every run of the While Loop is considered one iteration. During, and after, execution, this terminal returns the number of iterations completed. The iteration terminal starts off at 0; as a result, during the first iteration, the iteration terminal returns 0.

Example VI
The following exercise will demonstrate the use of a While Loop structure in a VI. This VI will keep generating a random integer between 0 and 100 in a loop until it matches a number defined by the user. An indicator will be used to count the number of iterations used to attain this match.

1. Open LabVIEW.

2. Open a new VI by clicking on Blank VI in the LabVIEW Getting Started window.

3. Save the VI as Number to Match.vi.

4. Create a random number generator, to generate integers between 0 and 100 inclusive, in a While
Loop.

• From the Functions palette, place a While Loop from the Programming → Structures subpalette.

• Using the random number generator found in the Programming → Numeric subpalette, gen-
erate a random integer between 0 and 100. Since the random number generator generates
random floating-point values between 0 and 1, use appropriate functions in the Functions palette to multiply the values by 100 and round them to an integer. You may find the Round to Nearest function useful, but you will need to look for it using the provided search functionality.

5. Create a control on the front panel that will be used to compare the results of the random number to a user-defined value, and display the number of iterations that were required to attain this match.

• From the Controls palette, place a numeric control on the front panel and label it Number to
Match.

• From the Controls palette, place a numeric indicator on the front panel and label it Iterations.

• Create an Equal? function from the Programming → Comparison subpalette and place it on the block diagram to compare the random number generated with the number present in Number to Match, as shown in Figure .

6. Create stop conditions for the While Loop.

• It is good programming practice to allow users the ability to exit a loop structure using a control on the front panel. To this effect, create a stop button control on the front panel from the Modern → Boolean subpalette.


• To also allow the While Loop to terminate when a match has been found, use the appropriate
logic functions from the Programming → Boolean subpalette to construct the necessary logic
for the stop terminal of the loop. The overall block diagram should look similar to that shown in Figure.

Notice, in the block diagram, that 1 has been added to the iteration terminal (i); this is done because iteration counts for loop structures in LabVIEW begin at 0, whereas we need to start counting iterations from 1. To create a constant (in this case, 1), right-click on the terminal and select Create → Constant.


7. Run Number to Match.vi and verify its operation. Run the VI again with the Highlight Execution button selected.

For Loop

A For Loop, like a While Loop, is a loop structure and functions similarly; the sole exception is that a For Loop performs as many iterations as determined by the count terminal).

Example
The following exercise will demonstrate the use of a For Loop structure in a VI. This VI will generate a random floating-point number between 0 and 1 every second and repeat for a finite number of iterations specified by the user. The VI will then return the largest number generated. An indicator will be used to count the number of iterations elapsed.

1. Open LabVIEW.

2. Open a new VI by clicking on Blank VI on the LabVIEW Getting Started window.

3. Save the VI as Max Search.vi.

4. Create a random number generator to generate floating-point numbers between 0 and 1 in a For
Loop and display it on the front panel. Have this loop repeat every second.

• In the block diagram, place a For Loop from the Programming → Structures subpalette.

• Also in the block diagram, place a random number generator found in the Programming → Numeric subpalette.

• Create a numeric indicator labeled Random Number on the front panel, from the Modern → Numeric subpalette, to display the random numbers. In the block diagram, wire the random number generated to this indicator.

• Back in the block diagram, place a Wait (ms) function into the For Loop and wire it to
a constant of 1000. You can do this by right-clicking on the left terminal (the one labeled
milliseconds to wait) and selecting Create → Constant. Again, use either the search functionality or the available categories to determine where the function itself is located in the Functions palette.

What have you just done? By adding the Wait (ms) block, you ensure that every iteration waits 1000 milliseconds, or 1 second, after completion before the next iteration starts.

5. Create a control on the front panel which will be used to define the number of iterations for the For Loop and place a numeric indicator to display the current iteration value.

• From the Controls palette, place a numeric control on the front panel and label it Number of
Iterations. Since this value can only be an integer, change the data representation of this
control from DBL (which stores double precision floating-point numbers) to I32 (which stores
integers) by right-clicking on the control in the block diagram, selecting Representation and
choosing I32, as shown in Figure. Connect this control to the iteration value N of the For
Loop.
Fig. How to Change the Data Representation
• From the Controls palette, place a numeric indicator on the front panel and label it Iterations. Wire the iteration index i to this indicator in the block diagram.

We now need to keep track of the maximum number generated in the iterations that have completed, but this involves maintaining history. In other words, we need a way to remember past values. Before we continue with this exercise, we will explore the concept of a shift register.

Shift Register
A shift register will be one of the most useful and ubiquitous constructs that we will use in the labs to come. In order to understand how a shift register works, we draw the following analogy: Notice how the For Loop looks like a finite sheaf of papers. This represents the fact that whatever is present on the topmost sheet is duplicated onto the other sheets. As the VI runs, each of these sheets are ‘run’ one after the other: in effect, we are thus repeatedly running the code on the topmost sheet, as a For Loop must.

Essentially, a shift register is like a data pipeline connecting two adjacent sheets, or iterations, together; the right square saves the result of the current iteration so that the next iteration can use it, while the left one uses the result of the previous iteration. Formally, during the ith iteration, data sent forward from the (i − 1)th iteration can be obtained from the left square of the shift register, manipulated or used in some way during the current iteration, and then sent forward to the (i + 1)th iteration using the right square of the shift register. As a result, the shift register allows us to remember values from previous iterations. We will use this property for the current task.

In other words, the left square of the shift register can be seen as an input from the previous iteration, and the right square of the shift register can be treated as an output for the current iteration.

6. Find the largest random number generated.

• Right-click on the left border of the For Loop and select Add Shift Register. You should now see a square on either side of the For Loop: the left one pointing down ( ), and the right one pointing up ( ); together, they constitute a shift register.


Figure. How to Add a Shift Register

• Outside the For Loop but near the left square of the shift register, drag a numeric constant from the Programming → Numeric subpalette and initialize this constant to 0. Then, connect this constant to the left square.

Notice that the left square now has a constant attached to it (in this case, that constant is 0). This is because, in the first iteration, there is no data from a previous iteration to be used, so an initial value must be attached to the left shift register; in this case, during the first iteration, the left shift register will produce the value 0.
If this initial value is not present, then running the VI the first time will cause LabVIEW to use a default initial value (usually 0 for numeric data), but running the VI subsequently will cause LabVIEW to use, as initial values, the values obtained from the previous runs of the VI, which is usually unintended behavior.

• Create a numeric indicator labeled Max on the front panel from the Modern → Numeric subpalette to display the maximum number.

• Using the necessary logic functions from the Programming → Comparison subpalette, implement an algorithm that will compare the random number with the previous maximum value and update the new maximum value. Figure shows the final block diagram for Max Search.vi.
Figure 6. Max Search.vi Block Diagram


Wait, what is that large triangular block in the block diagram?

Selectors

A selector acts as a sluice gate, and as such, allows us to choose which data should flow through a wire. It is analogous to the if-construct in programming languages. A selector has three input terminals: t, s, and f. The s terminal accepts a wire carrying Boolean data, which is data that is either True or False. If the datum is True, then the data contained in the wire connected to the t terminal is allowed to flow through; if the datum is False, then the data contained in the wire connected to the f terminal is allowed to flow through.

In the example shown in Figure 6, the Greater Than comparison block produces a True Boolean value, if the value flowing into its upper terminal is strictly greater than the value flowing into its lower terminal. This Boolean value feeds into the s terminal of the selector. With this in mind, we interpret the block diagram as follows: if a past value, provided by the shift register, is greater than the number randomly generated in this iteration, then that number is propagated to the next iteration; otherwise, the new random number is propagated. As a result, the shift register remembers the maximum value generated so far.

7. Run Max Search.vi and verify its operation. Run the VI again with the Highlight Execution
button selected.

Self-Exercise
Now that we learned how to use a For Loop, implement the following VI which generates two random numbers between −0.5 and 0.5 for a set amount of time defined by the user. Denote the first random number as Random Number A and the second as Random Number B. Points are attributed to a random number whenever its value is greater than the other. Write a VI that keeps track of the points for each random number generator and displays the winner, with the help of Boolean indicators. Also, include an indicator in the event of a tie. Note that the winner should only be displayed at the end of the competition (once all iterations have finished). Save this VI as Random Competition.vi.

You will probably need two shift registers and two selectors to achieve this task, one each for A and for B. Think about what each shift register should remember, and how these values should be updated; for instance, if A gets a higher score than B, which shift register should be updated? How about the other shift register?

Also, using the analogy of data flow, where would you obtain the final scores of A and of B, and how would you use this information to determine the winner?

Figure. Random Competition.vi Front Panel

Lab .1(c) How to create a basic VI which calculates the area and perimeter of a circle, given its radius r.

1. Open LabVIEW.
2. Open a new VI by clicking on Blank VI in the LabVIEW Getting Started window.
3. Save the VI as Circle Area Perimeter.vi:

  • Select File → Save.

• Navigate to the location where you wish to save the VI.

• Name the VI Circle Area Perimeter.vi.

• Click OK.

4. Now we Create the front panel shown in following Figure.


• Right-click on the front panel to open the Controls palette, and put down a Numeric Control from the Modern → Numeric subpalette, as shown in Figure .

• Double-click on the label for this control and rename it to r.

• Place down two numeric indicators from the Modern → Numeric subpalette and rename them Area and Perimeter.

Note:- the distinction between an indicator and a control. A control receives input, while an indicator displays output.

• You can change the font of the labels using the font drop-down menu near the menu bar, as shown in Figure .

5. Open Context Help using the key combination Ctrl-H. When you hover over any block or con-
nector, the Context Help will provide a brief description of its function or its type, depending on
context. This will prove very helpful in creating VIs.

6. Create the block diagram for this VI as shown in Figure 4.


• Right-click on the block diagram to open the Functions palette and place down the necessary
mathematical functions from the Programming → Numeric subpalette, as shown in Figure .

If you will be using a right-click menu frequently, as you did just now, you can ‘pin’ the menu
down by clicking on the button that resembles a pushpin ( ) on the top left corner of the 
menu. Also, clicking on the Search button causes the search functionality to persist.


• Place down the necessary constants from the Programming → Numeric → Math Constants subpalette, as shown in Figure .


• Wire the functions as shown in Figure 4.

The key combination Ctrl-E will help you toggle quickly between the front panel and the block
diagram.

7. Run the VI and verify its operation.

• Click on the numeric control r and set its value to 1.5.
• Run the application by clicking on the Run button. (  )
• Verify that the area and perimeter indicators return the correct result.
• Run the VI for different values of r and verify its operation.

8. Select the Highlight Execution button in the toolbar of the block diagram ( ), and run the VI
while viewing the block diagram. Notice how data flows from left to right through the block diagram and gets processed by each block. Deselect the button when done.

Self-Exercise

Now that you have learned how to build a simple VI, implement the following VI that calculates the roots of a quadratic equation Ax2 + Bx + C = 0 based on its coefficients. Save this VI as Quadratic Roots.vi.

The front panel is shown in Figure . For this simple exercise, the VI will not support complex roots.


Messy VI block diagram? Do not despair! The key combination Ctrl-U will clean it up for you. The key combination Ctrl-B removes all broken wires.

Lab .6(b): Design of a Virtual PLC Using Lab View


Abstract: Using LabVIEW environment a trial has been made to create a set of programmable virtual
instruments, which resemble the traditional PLC programmable functions and networks. The target of this work is to improve the programmability of PC-based control systems. Bringing the PLC to the industrial type computer it becomes possible to make use of the advantages of computer based DCSs. It will be possible to have unlimited number of programmable objects, and to run more than one program at the same time. By utilizing LabVIEW front panel it is an easy job to realize MMI as required, and by creating sub VIs the program becomes more compact and easier to debug.

Lab .6(a): Using LabVIEW to Measure Temperature with a Thermistor


Before starting this exercise, install LabVIEW and drivers following the instructions in the
“LabVIEW Quick Start” document, and connect and test the USB-68008 data acquisition unit
following the directions in the “Connecting the USB-68008” document. The screen shots shown
in this document are from a Windows VISTA machine. Your setup may have slight differences.

Comming Soon On Request

Lab .2(a): Basic Example

1. Build a VI to add and multiply two given numbers and display the results

2. To write a VI for the Multiplication of a random number with 10 and displaying the result continuously, until it is stopped.


3. Write a VI to convert a given temperature value from Degrees C to Degrees F. This VI will teach you:
(a) Methodology for writing small VIs targeting a conversion in units.
(b) The procedure for using a small program as a sub VI in another program by creating Icons. You will use this VI as a sub VI in another program later to build a thermometer demo VI.

4. Build a thermometer, which measures temperature and displays temperature values using the C to F converter you built in the earlier exercise.

5. Create a thermometer using the above two VIs and plot the output temperature values on a chart to display the variation of temperature values. At same time show the mean of the temperature values on a thermometer.

6. To build a VI to monitor the temperature continuously

7. To Build a VI to chart the average temperature of multiple measurements, graph the current sample and calculate the rate of change of temperature in degrees/second (display on a gage).

Finite State Machine Implementation with LabVIEW: Tic-Tac Game

In this lab you will explore using Finite State Machines to build a small Tic-Tac-Toe game. The tic-tac-toe game is simplified from the usual 3×3 type of game to a 2×2 type of game (called Tic-Tac). 
For example: 

The Front Panel of the game will be built with four “O” buttons from the Boolean Controls Palette. Place the four controls close together to make a matrix. The computer begins by placing an X in some location of the matrix. One then uses the buttons to click on them and then select the square to place an O into. If one gets two in a row one wins (diagonal does not count).

The Game will start with the empty matrix, like the following:

The Computer begins by placing an X in a location:

The player then clicks on one location, and in so doing changes the value of the button text from a null string to an O. The button must also be disabled so that a subsequent click cannot change it.

The Computer then selects a place to put another X (initially set so it will always win) and this matrix location receives the X and its button is disabled. (The original X should have been disabled at the beginning.)


The application will pop up a two button dialog box saying “I Have Won”. The two buttons on the dialog box should say “Play Again” and “Quit”, where “Quit” stops the program and “Play Again” clears the board and allows you to play again. You should also add a button on the Front Panel, “Restart” which will clear the board and restart.

In order to simplify the game, we will make two changes:

1. The computer starts first, and always moves in the upper left corner with an X.

2. The computer stops as soon as it wins.

To do this lab you will have to do multiple things:

1. Learn how to dynamically change the names on the OK buttons, and disable.

a. Setup: Do this by creating Property Nodes for each button (right click while in the Front Panel, under “Create”. On the Block Diagram you need to add another element to each property node (right-click, choose “Add Element”). Then set one element to “Disabled”, the other to `BoolText.text' by searching through the “Properties” menu on a right click. Change both elements to write.

b. Changing strings: You should now be able to attach a string to the “Booltext.text” and display it in the button when you run the program. To make a selection, build an array of strings, and select a single element of the array with an index. Set the array of strings to be “X”, “O”, and “ ” (an empty string). Test with a numeric control (make it U8!): when the program runs change the values of the numeric control to select different values of the text to be displayed on the button.

c. Disabling: Add a Boolean switch. In the dialog box, convert the Boolean value to a number using the “Boolean to (0:1)” function. Send the output of this to the Disable element of the button. If one passes a 0 to the Disable element, the button behaves normally. If one passes a 1, it is disabled. (FYI, if a 2 is passed to the button, the button is grayed out and disabled). By running the application you should be able to enable or disable the button at will, as well as change its caption.

2. Design a finite state machine on paper.

a. Work through the states of a FWM which compromise the Tic-Tac game. Start by assuming an unchecked space has a 0, a space with an X has a 1, and a space with an O has a 2. Each state could then have a label abcd, as below.

b. What is the initial state? Draw a circle for this one and label with


So this is state abcd = 0000. (The labels following the pattern of buttons.)

c. What are the first four possible states (primary states)? In a row below the initial state, draw a circle for each primary state and provide a label. For instance, if there is an X in upper left corner, the primary state would be labeled as


This is therefore state abcd = 1000. Draw an arrow from the initial state to each of the four different possible primary states.

d. Now draw a row of secondary states below the row of primary states. We will simplify by following only one of the primary states in this lab, otherwise the number of states grows tremendously. So for only state abcd = 1000 out of the first possible initial states, define the secondary states. For instance if the player chooses to move into bottom left, this would be a state abcd = 1020.


Each secondary state should be unique, but there may be arrows from two different primary states to
a single secondary state.

e. Now define the third level states and fourth level states. Note that the computer can win in every case, so the third level states are essentially predefined for two of the secondary states, but one of the secondary states has two different third state possibilities. There is only one fourth level state, where the computer prints out its victory message and waits.

3. Now that you have the state diagram, you have a certain number of unique states. Assign each of the above states a number. This is an arbitrary assignment and does not have to be in any order. The easiest way to do this is to name them abcd, i.e. state 1020, 2010, 1120, 0010, etc. In this case you have almost no work to do. Note that state 0000 would be interpreted by the Case Structure in LabVIEW as state 0. (One could use strings of the numbers to select as well actual numbers). The final victor state can be any number you have not already used; e.g. 9999.

4. Use a Case Structure imbedded within a While Loop to generate the finite element machine that jumps between the various states. In each state, assess what the input data is (the values of each of the 4 buttons in the matrix as well as the “Restart” switch) and select the next state to jump to. Pass this state back to the case statement using a tunnel in the While Loop. If you choose to number the states as 1020, 2010, etc, then as you add each case to the case statement, and change the case value to these numbers. State 0000 would be interpreted as state 0.

a. You will need to have a sort of numeric scratch pad where you can write some data and store it as well as read it back. The strategy here will be to use a local variable. First create four numeric controls. Each represents the states of each of the 4 matrix check boxes. Give each controll a representation of U8. You can hide the numeric controls from being visible on the Front Panel by right clicking on the numeric control from the front panel, and selecting “Hide Control” (located under submenu “Advanced”). Int the Block Diagram, make sure these numeric controls are outside of the Case Structure which controls the finite state machine sequence, but inside the overall While Loop. Use these variables to select the caption of the individual matrix element buttons (using the Array select, as in the part 1) as well as to disable the matrix element buttons (check to see if the variable is non-zero; if it is, disable the button).

b. Go to your initial state abcd = 0000 in the Block Diagram. Right click on the data object to select Create→Local Variable. Drop a local variable for each of the four numerical controls buttons into the abcd = 0000 state. Assign all of these value 0, except a, which will have value 2. You can use numeric constants to assign these values. Setup the jump to the next state abcd = 1000

c. Go to next state: abcd = 1000. Again, add local variables for bcd into this case. Assign b,c,d from the b, c, and matrix switch values. Setup a new state to jump to based on these switch values. (Hint: form an integer P= a +2b + 4c , then pass this to a new case statement embedded within this particular case statement. Select what the next state will be depending upon P=0, P=1, P=2 & P=4 ).

5. One state will pop up a dialog box. Be sure to wire the cancel output to stop the program.

6. One state, abcd = 1002, will have two possible computer moves to win. Use a random number generator to select which path will occur. The random number generator makes a number between 0.0 and 1.0. So compare the random number with 0.5, if it is less, the jump to one state, if it is more, jump to each other.

7. Be sure to initialize the state of the machine to 0 outside the main while loop. You probably will want to initialize each of the numeric matrix values as well here.

8. Try using the debugging features of LabVIEW as they will help you to discover problems. In particular, it can help you trace through the steps that your finite state machine is progressing through, and help you to diagnose when you are not jumping to the correct state.