You are on page 1of 4

PROGRAMMING EXERCISES ON LABVIEW

Building, Editing, Debugging VI, subVI



1. Create a VI to add two numbers by using numeric control
2. Create a VI program to find the speed when distance and time is given
3. Create a VI program to calculate frequency (F) using time period (T) (F=1/T)
4. Create a simple VI which consists of a knob and a waveform chart
5. Create a simple VI which consists of a dial and a thermometer
6. Create a VI to add two numbers and compute the sine of the result
7. Create a VI to calculate the power of any number.
8. Create a VI to input five numbers and find the average. Use the compound arithmetic function
9. Create a VI which performs all the following functions
a) Add two input numbers and display the result
b) Multiplies the same two input numbers and display the result
c) Compare those same numbers and turn on an LED if they are equal.
10. Suppose the temperature from a dial is in degree Celsius, develop a VI to convert this
temperature to degree Fahrenheit F = 9/5 (C+32)
11. Build a VI to compare a temperature with a set point and if it exceeds the limit, an indicator is
on.
12. Build a VI to convert the temperature in degree C to degree K
13. Construct a VI that uses a round pushbutton control to turn on a square light indicator whenever
the pushbutton is pressed.
14. Construct a VI that performs the following tasks:
a) Takes two floating point numbers X and Y as inputs on the front panel
b) Subtracts Y from X and displays the result on the front panel.
c) Divides X by Y and displays the result on the front panel
d) If the input Y=0, a front panel LED glows to indicate division by zero.
15. Create a VI that has a numeric control to input a number x, uses the add and multiply functions
to calculate 3x
2
+
2x + 5 and display the output using a numeric indicator.
16. Create a VI using Express VI that generate a triangle wave with a frequency 125Hz and added
noise.
17. Create a VI where a sinusoidal signal can be simulated and shown through a waveform graph.
Suitable controls may be provided to change the amplitude and frequency of the signal.
18. Create a VI that generates a saw tooth signal at an amplitude that is prescribed by the user, and
display the signal graphically.
19. Create a VI to simulate a noise filled sinusoidal signal and filter it. Display both the waveforms
on one graph.
20. Construct a VI to accept five numeric inputs, add them up and display the result on a gauge, and
light up a round light if the sum of the input numbers is less than 18.0. The light should light up
in green and the gauge dial should be yellow.
21. Construct a VI that generate two random numbers and displays both of them on meters. Label
the meters Random Number 1 and Random Number 2 respectively. Make the face of one meter
blue and the face of the other meter red. When the value of the random number on the red meter
is greater than the random number on the meter with the blue face, have square LED show
green; otherwise have the LED show black.
22. Create a dial control that goes from 0 to 2, with three LED displays: one green, one yellow, and
one red. Have the VI turn the LED green when the dial is on 0, yellow when the dial is on 1, and
red when the dial is on 2.



23. Create a front panel that has 8 LED indicators and a vertical slider control that is an 8 bit
unsigned integer. Display a digital indicator for the slider. Make sure that the LEDs are evenly
spaced and aligned at the bottom. The problem is to turn on the 8 LEDs into a binary (base 2)
representation for the number in the slider. (Hint: for a number 131 which is 10000011, the
LEDs 0, 1 and 7 should be on).
24. Develop a VI to convert an input value in degrees to radians with four digits of precision.
25. Construct a VI to find the average of four numbers. Edit the icon into a particular shape, assign
the connectors and prepare fully the subVI. Create another VI in which this subVI is used to
find the average of marks of four subjects, and the grade of a student is calculated by comparing
it with set values as follows: If the average is greater than or equal to 90, then Grade is A, and
if the average is less than 90 and greater than or equal to 60, then Grade is B, and if the average
is less than 60 and greater than or equal to 40, then Grade is C, and if it is less than 40, then the
student is Fail.

Structures

26. Create a VI to generate ten random numbers and display them. Display the iteration count also.
27. Create a VI to generate random numbers and display them. Use a STOP button to stop.
28. Create a VI to add two numbers. The program ends by using a STOP button.
29. Create a VI to display all numbers less than or equal to a given number and then stop.
30. Create a VI to generate random numbers and display them. If the value of the number is greater
than 0.5 then the loop stops.
31. Create a VI to compute the running sum of the iteration count within the For loop.
32. Create a VI to compute the running average of a sequence of random numbers.
33. Create a VI to compute the sum of all integers less than a given number by the user.
34. Create a VI that generates the sum of all random numbers generated. Use a While loop with
shift registers.
35. Do the same problem using feedback node.
36. Construct a VI that displays a random number between 0 and 1 once every second. Compute
and display the sum of the last four numbers generated. Display the sum only after the first four
numbers have been generated, till then display a 0.
37. Build a VI that computes the ratio of two numbers. If the denominator is zero, the VI outputs
infinity to the front panel and causes the system to make a beep sound. If the denominator is not
zero, the ratio is computed and displayed on the front panel. Use CASE structure.
38. Build a VI that functions like a calculator. The front panel should have digital controls to
input two numbers and a digital indicator to display the result of the operation (Add, Subtract,
Divide, or Multiply) that the VI performs on the two numbers. Use CASE structure.
39. Build a VI that computes the value of the equation y = x esinx by using a formula node.
Compare the results by computing the value using numeric functions
40. Build a VI that computes the ratio of two numbers by using a formula node. If the denominator
is zero, the VI outputs infinity to the front panel and if the denominator is not zero, the ratio is
computed and displayed on the front panel. Compare the results by computing the value using
numeric functions
41. Build a VI to compute y = mx + c using formula node, where m and c are constants and x varies
from 0 to 29. Put a delay also which helps to view the values slowly.
42. Develop a VI to convert temperature in degree Celsius to degree Fahrenheit by means of the
expression F = 9/5 (C+32). Use formula node





43. Create a VI to write a code in the formula node and get the output according to it. The value of x
is generated and varied from 1 to 10. The code is:
If (x>=5) y=1, z=2;
else y=0,z=0;
Use also the conditional branching statement in the formula node and compare the results.
y=(x>=5)?1:0
z=(x>=5)?2:0
44. Create a VI to generate and plot a given number of random numbers and also calculate the
average of them. Use a MATLAB Script node.
45. Use the MATLAB script node to obtain a plot of a sine wave on a MATLAB figure. The sine
wave frequency should be an input to the MATLAB script node.

Arrays and Clusters

46. Create an array of 5 numbers by generating random numbers
47. Display the contents of an array to an indicator with a time gap of 1 second.
48. Create a two dimensional array (5x2 matrix) by generating random numbers.
49. Create a VI that performs scaling of an array by a number
50. Create a VI to initialize an array with a particular element, specify the size of the array also.
51. Create a 3x2 matrix. Append a scalar number, a 2x3 matrix and another 2x2 matrix to the initial
matrix, so that you obtain an 8x3 matrix.
52. Create a 8x3 matrix and create a portion of this matrix by specifying the row number and
column number from which we require the smaller matrix.
53. Create a VI to concatenate a scalar value to an array, and display the new array. Using the array
size function and the array initialize function, create another array of appropriate dimension
with all elements initialized to any particular value. Compute the difference between the two
arrays and display.
54. Create an array by generating random numbers and multiplying each random number by t/2.
Initialize another array of the same size with 10.0 and add both the arrays.
55. Create a VI that performs addition of two matrices, addition of two vectors, addition of a scalar
to a vector, a scalar to a matrix. Do all this in one VI.
56. Create a VI to generate 20 random numbers and display them in an array. Compute the average
using the MEAN function.
57. Build a VI that generates a two dimensional array (8x4) containing integers between 0 and 50
using a random number generator. Display the two dimensional array and its transpose and
extract from it (i) row 3 (ii) column 2 (iii) element (4,3).

58. Create a VI that calculates the dot (inner) product of two 3-dimensional vectors.
Hint: If the two vectors are denoted by a and b where

( )
( )
( )(
(
(

=
2
1
0
a
a
a
a and
( )
( )
( )(
(
(

=
2
1
0
b
b
b
b then the dot product is ( ) ( ) ( ) ( ) ( ) ( ) 2 2 1 1 0 0 . b a b a b a b a + + =

59. Create a VI that calculates the cross product of two 3-dimensional vectors.
Hint: If the two vectors are denoted by a and b where



( )
( )
( )(
(
(

=
2
1
0
a
a
a
a and
( )
( )
( )(
(
(

=
2
1
0
b
b
b
b then the cross product is given by

( ) ( ) ( ) ( )
( ) ( ) ( ) ( )
( ) ( ) ( ) ( ) (
(
(

=
0 1 1 0
2 0 0 2
1 2 2 1
b a b a
b a b a
b a b a
axb
60. Create a VI that performs matrix multiplication for two input matrices A and B. Let matrix A be
a 4x2 matrix and matrix B be a 2x3 matrix.
61. Build a cluster containing two numeric controls and an array. Build a VI to multiply all the
numeric values in the cluster by a given number.
62. Build a VI to create a new cluster using bundle function, from three inputs: a floating point real
number, an integer and an array of numbers generated by a For Loop.
63. Build a VI to change the already existing cluster of three controls: a floating point, a numeric
and an array with different numbers and random numbers generated by a For Loop.
64. Build a VI to unbundle the elements of a cluster. The cluster has four elements: a numeric
control, toggle switch, a string indicator and a knob control. Each element should indicate the
values in its own individual indicator outside the cluster.
65. The logistic difference equation x
k+1
= r x
k
(1 x
k
) where k = 0,1,2,, r is the rate of
population growth and x
o
is the given initial value, has been used as a model to study population
growth patterns. The model has been scaled so that the values of the population vary between 0
and 1, where 0 represents extinction and 1 represents the maximum conceivable population.
Build a VI using a formula node containing the logistic difference equation as y = r x(1 x) and
calculate 30 values and plot on a waveform graph. Let x
o
be 0.02. If the population falls below
zero, set it to exactly zero ie. population is extinct. Write your conclusion by changing the
values of r (rate of growth), (i) for value of 1< r < 3 (ii) for 3 < r < 4 (iii) for r > 4
66. Build a VI to plot a unit circle by using a sine and cosine function. Use Express XY graph
67. Build a VI to plot the following on a single plot (i) a sine curve (ii) a cosine curve (iii) e
-0.1x
for
0 x 41.
68. Create a VI that graphs the function sin x where x = 0nt, and the integral
}
=
t n
xdx y
0
sin
.
The value of n should be an input on the front panel.

Strings
69. Create a VI to find the length of a string
70. Create a VI to concatenate three strings and make a single string
71. Create a VI to cut apart a part of a string, by specifying the point at which it is to be cut and the
length to be cut
72. Create a VI for the following string operations (i) to convert a string to uppercase characters (ii)
to convert a string to lowercase characters (iii) to rotate a string (iv) to reverse a string
73. Create a VI that concatenates a message string, a numeric and a unit string, eg., Set to 10.24
volts by specifying formats
74. Using Build Text Express VI, create a VI to build a text by getting inputs from numeric
controls. Eg. Speed is 1500 rpm and voltage is 230 volts.
75. Create a VI which prompts for user inputs to get two input strings. Compare each character of
string1 with each character of string2. Display the number of mismatches

You might also like