LabVIEW Manual
LabVIEW Manual
MANUAL
Subject: Modelling and Simulation
Subject Code: McENG 4066
BSc.Semester 2
Tank placement
Place the tank on the front panel and adjust its size according to your needs.
Now from the Control Palette on the front panel, select Numeric and then
select Vertical Pointer Slide, as shown in the figure below.
Pointer slide placement
LED placement
Front Panel
Place two such LEDs below the vertical pointer in LabVIEW’s VI, one for the
indication of the lower limit of water level in the tank and the other for the
indication of the upper limit of water level in the tank, as shown in the figure
below.
Front panel
Now let’s move toward the block diagram part. First, connect the tank control to
the tank indicator directly, as shown in the figure below.
At the input side of this block, connect the tank level control on the upper input,
and at the lower input, connect the maximum limit control, and at the output,
connect the maximum level indicator, i.e., the round LED, as shown in the figure
below.
Block Diagram
The complete block diagram for water level detection in LabVIEW is shown in the
figure below.
Block diagram
This block diagram will only run once; if we want it to run continuously, we can
use a while loop and place the whole block diagram inside it. From the Function
Palette, select Structures and then select While Loop. This while loop will then
be dragged to the outer boundary of the block diagram. Refer to the figure below.
Less
than minimum value
If the water level on LabVIEW’s VI is between the maximum and minimum
values, then both LEDs will be off, as shown in the figure below.
With
in range
And if the water level on LabVIEW’s VI is higher than the upper limit, the
maximum LED will turn on, as shown in the figure below.
Gre
ater than maximum value
Exercise
Update the VI provided above to display the water level in a numeric
indicator, and both the minimum and maximum limits of the water level are
also displayed in a numeric indicator.
Conclusion
In conclusion, this tutorial has provided a comprehensive overview of the
importance of water level indicators and how to build them in LabVIEW. This also
covers step-by-step procedures for designing a block diagram of this water level
indicator in LabVIEW’s VI purpose. This helps us understand the principle of
level detection for application. You can utilize this concept in various applications,
including level indication for a specific task. Lastly, an exercise is provided to
reinforce the concept of water level indication in LabVIEW. We hope that this
tutorial has been helpful in expanding your knowledge of LabVIEW programming.
From the Function Palette on the block diagram, select Numeric, and then
select Random Number, as shown in the figure below.
Rando
m generator
The problem here is that the built-in random number generator generates
random numbers within the range of 0–1, and it generates floating-point random
numbers, whereas we want to compare them with integers. Hence, first we have
to somehow manipulate the range of the random number generator to 0-10.
We can do this simply by multiplying the output of the random number generator
by 10. From the Function Palette on the block diagram, select Numeric, and
then select Multiply, as shown in the figure below.
Multiply block
Connect one input side of this block with the output of the random generator, and
on the other input side, create a constant as shown in the figure below and give it
a value of 10.
Constant placement
Creating control
This control will take the input value from the user, compare it with the randomly
generated value, and display the correct guess in the form of an LED indicator.
Don’t forget to name or label every control and indicator according to their work
in the VI. Now for the comparison portion of the VI, from the Function
Palette, select Comparison, and then select Equal. As shown in the figure
below,
Comparison block placement
At one input of this block, connect the output of the ‘to integer’ block that was
generating random numbers, and at the other input, connect the numeric control
whose values are taken from the user as a guess.
Comparison Block
This block will compare both values; if they are equal, the output of the block will
be returned as true and false otherwise. The comparison block diagram is shown
in the figure below.
Comparison block
At the output node of this block, press right-click, and from the drop-down menu,
select Create, and then select Indicator, as shown in the figure below.
LED indicator for correction
Block Diagram
This will create an LED indicator to show the correctness of your answer. The
complete block diagram of your VI is shown in the figure below.
Block diagram
Output
Finally, enter a value in the control and run the VI. If the guess matches the
number generated, the LED will turn on, as shown in the figure below.
Correct guess
If the number generated by LabVIEW is different from the number guessed by
the player. Then the LED will remain off, as shown in the figure below.
Guess is incorrect
Now, in order to keep the randomly generated number a secret, we will delete
the numeric indicator from the block diagram and run the VI. The correct and
incorrect conditions are shown in the figure below.
Incorrect guess
Correct guess
Exercise:
Create a guess number game that will allow you to guess numbers in the
range 2–8 instead of 0–10.
Conclusion
In conclusion, this tutorial provides an in-depth overview of how to develop a
guess-the-number game in LabVIEW. This tutorial also provides a step-by-step
procedure for developing the game. You can utilize this concept and add more
rules and functionalities as you like. At the end, an exercise is also provided to
reinforce the concept of the guess the number game in LabVIEW. Hopefully, this
tutorial was helpful in expanding your knowledge of LabVIEW.
For those already acquainted with digital logic design, you likely know the purpose and
workings of a half-adder in the context of digital systems. In this tutorial, we will design a VI
(Virtual Instrument) that accepts two logic inputs (0 or 1) from the user and returns the sum and
carry when these inputs are added together. We’ll begin with a brief introduction to the half-
adder, followed by the step-by-step process of designing the VI for performing the half-adder
operations.
Place two such push buttons for two binary single-digit inputs. Now, in order to place an
indicator for the binary output indication, we have to place LEDs. On the front panel, press right-
click, and from the Control Palette, select Boolean, and then select Square LED as shown in
the figure below.
Boolean indicator
Controls and
indicators
Never forget to name the blocks accordingly. Now move to the block diagram for XOR and
AND gate placement. From the Function Palette on the block diagram window,
select Boolean and then select “Exclusive Or”, as shown in the figure below.
Exclusive Or placement
Summing Block
This block will return the sum of the half-adder output. At the input of this block, connect the
two Boolean controls created previously, and at the output of it, connect the Boolean indicator,
i.e., the square LED you created and named sum previously, as shown in the figure below.
Summing block
To design the carry operation, we have to use an AND gate. From the Function Palette on the
block diagram window, select Boolean and then select AND, as shown in the figure below.
AND block placement
Block Diagram
The complete block diagram of a half-adder is shown in the figure below.
Block diagram
The output of the half adder should be according to the table given below:
A B Sum Carry
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
Now on the front panel, set the values of both A and B to 0 and run the VI. Both the LEDs will
remain on according to the above table, as shown in the figure below.
Output 1
Now change the value of A to 1 and keep the value of B to zero, and again run the VI. According
to the table, the sum LED will turn ON and the carry will remain OFF, as shown in the figure
below.
Output 2
Now change the value of A to 0 and the value of B to 1, and again run the VI. According to the
table, the sum LED will turn ON and the carry LED will remain OFF, as shown in the figure
below.
Output 3
Set the values of both A and B to 1 and again run the VI. The carry LED will now turn ON, the
sum LED will turn OFF, and the output will again be in accordance with the above table, as
shown in the figure below.
Output 4
Conclusion
In conclusion, this tutorial provides an in-depth overview of designing a half-adder circuit in
LabVIEW’s VI. It also covers a step-by-step procedure explanation of each part of the example
in detail. This helps us better understand the concept of designing a half-adder circuit in
LabVIEW’s VI. You can utilize and improve this tutorial’s concept to design a full adder circuit
in LabVIEW as well. Hopefully, this tutorial was helpful in expanding your knowledge of
LabVIEW
Place three push buttons for two binary single-digit inputs. Now, in order to place an indicator
for the binary output indication, we have to add LEDs. On the front panel, right-click and from
the control palette, select Boolean. Then, choose Round LED as shown in the figure below.
Figure 2: Boolean indicator
Place two indicators, also display the sum, and carry on the output. The resulting controls and
indicators are shown in the figure below.
Figure 3: Control and indicators
Now move to the block diagram for XOR, OR, and AND gate placement. From the function
palette on the block diagram window select Boolean and then select Exclusive Or as shown in
the figure below,
Place two such blocks as we are interested to do the XOR operation on three inputs. The output
of these blocks will return the sum of the full adder output.
At the input of the first block, connect the two Boolean controls A and B. Connect its output to
the input of the next XOR block. Then, connect the C control to the remaining input node of the
second XOR gate. At the output of the second XOR gate, connect the Boolean indicator (the
round LED) that you have previously created and named as “sum.” The figure below shows the
correct connections:
Figure 5: Summing block of full adder
To do the carry operation we have to use two AND and one OR gates. From the function
palette on the block diagram window select Boolean and then select AND as shown in the figure
below,
At the input of this AND gate, connect the output of the first XOR gate and the C control. Place
another AND gate with inputs connected to A and B control. Now, from the function palette on
the block diagram window, select Boolean and then select OR as shown in the figure below:
Figure 7: Or block placement
At the inputs of these or blocks connect the output from the two and gates and at the output node
of this block connect the indication of output carry as shown in the figure below,
The complete block diagram of a full adder is shown in the figure below,
Figure 9: Block diagram
The output of the full adder should be according to the table given below:
A B C Sum Carry
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
Now on the front panel, set the values of both A, B, and C as 0 and run the VI, both the LEDs
will remain of as according to the above table, as shown in the figure below,
Figure 10: Output 1
Now change the values and test the VI for different combinations of inputs as shown in the
figure below,
Exercise
Test the designed circuit for all the remaining combinations from the table and verify the
output from the table.
Conclusion
In conclusion, we have learned how to design a full adder circuit in LabVIEW. A full adder is a
crucial component in digital logic design and digital systems, as it allows us to add three binary
digits together, producing a sum and a carry output. Through the step-by-step process outlined in
this tutorial, we have constructed a VI that takes user inputs and provides the corresponding sum
and carry values. By understanding the differences between a half adder and a full adder, and
implementing XOR, OR, and AND gates in LabVIEW, we have successfully designed a
functional full adder circuit. This tutorial serves as a foundation for further exploration into the
realm of digital logic design and its practical applications.
Software Requirements:
Put the motor driver L293D chip in the middle of the breadboard. This ensures
that pins on both sides are not shorted together.
Follow the table below to connect the L293D motor driver with the Arduino Board:
8 and 16 5V or VIN
4 and 5 GND
7 4
2 5
1 6
Table 1: Connection between Motor driver and Arduino
Now we will move on to connecting the motor with the L293D driver chip. The
connections are as follows:
Motor Driver L293D pins 5V DC motor pins
3 Terminal 1
6 Terminal 2
Table 2: Connection between motor driver and DC motor
We are done with the hardware connections of the circuit for this project; now we
can move on to the next step, which is the programming part in LabVIEW.
The third input is “Board Type”, the fourth is “Bytes per packet”, and the
fifth is “Connection Type”. We will make them all constant.
Further, join the blocks as shown in the diagram. We also need to place
two more “close” blocks. For PWM input, we create control as done
previously, and for all other inputs, we create constants.
Opening LabVIEW program in Arduino IDE
Now start the Arduino IDE.
Click “File”, then “Open”, as shown below. Now, go through all these
folders from “Computer” onward and open the LIFA_BASE Arduino file.
Upload the program opened in Arduino IDE using the Arrow button on top
of Arduino IDE.
Once uploading is done, close the Arduino IDE. It’s very important to close
the Arduino IDE because both LabVIEW and Arduino are using COM4. If
not closed, LabVIEW will not be able to communicate, and LabVIEW
software will crash.
Now go to the front panel in LabVIEW and run the program in the toolbar
menu of LabVIEW.
When we right 1 at the place of “direction 1”, the motor rotates in one
direction. When we right 1 at the place of “direction 2”, the motor rotates in
the other direction. Be careful when doing this; do not set 1 for “direction 1”
and “direction 2” simultaneously. Both direction controls should not be on
at once. If one direction control is 1, the other should be 0. Otherwise,
L293D will suffer permanent damage. One more thing to note is that speed
should be somewhere between 0 and 255; otherwise, the motor will not
rotate.
By varying speed between 0 and 255, we can see that motor speed varies.
At 0, the motor stops, and at 255, it rotates at maximum speed.
Video Demo:
In summary:
In this tutorial, we learned DC motor control with LabVIEW and Arduino and how
to interface LabVIEW with Arduino to precisely regulate DC motor speed and
direction.