0% found this document useful (0 votes)
169 views2 pages

Sum and Factorial in LabVIEW VI

The document describes using LabVIEW to create VIs that calculate the sum of the first 10 natural numbers and the factorial of a given number using a for loop and shift registers. It explains the components of a for loop including the count and iteration terminals and use of tunnels to pass data in and out of loops. It provides instructions on adding shift registers to loop borders to access data from previous iterations and sample block diagrams for the sum and factorial calculations.

Uploaded by

Anand Kumar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
169 views2 pages

Sum and Factorial in LabVIEW VI

The document describes using LabVIEW to create VIs that calculate the sum of the first 10 natural numbers and the factorial of a given number using a for loop and shift registers. It explains the components of a for loop including the count and iteration terminals and use of tunnels to pass data in and out of loops. It provides instructions on adding shift registers to loop borders to access data from previous iterations and sample block diagrams for the sum and factorial calculations.

Uploaded by

Anand Kumar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

EXPERIMENT-07

Aim: (a) Create a VI to find the sum of first 10 natural numbers using for loop and Shift Registers.
(b) Create a VI to find the factorial of given number using for loop and Shift Registers.
Apparatus: LabVIEW software.
Theory:
For loop: A For Loop executes a sub-diagram, a set number of times. The For Loop is located on the
Functions>>Programming>>Structures Palette.

N: The value in the count terminal ‘N’ (an input terminal) indicates how many times to repeat the sub-
diagram. Set the count explicitly by wiring a value from outside the loop to the left or top side of the count
terminal, or set the count implicitly with auto-indexing.
i: The iteration terminal ‘i’ (an output terminal) contains the number of completed iterations. The iteration
count always starts at zero. During the first iteration, the iteration terminal returns 0.
Tunnels: Data can be passed out of or into a loop through a tunnel. Tunnels feed data into and out of
structures. The tunnel appears as a solid block on the border of the loop. The block is the color of the data
type wired to the tunnel. Data passes out of a loop after the loop terminates. When a tunnel passes data
into a loop, the loop executes only after data arrives at the tunnel.
Shift registers: When programming with loops, you often need to access data from previous iterations of
the loop. For example, you may have a VI that reads the temperature and displays it on a graph. If you
want to display a running average of the temperature as well, you need to use data generated in previous
iterations. Two ways of accessing this data include the shift register and the feedback node.
Procedure:
1. Selecting File>>New VI to open a blank VI.
2. Right click on the block diagram panel, select program, go to structures and select a FOR loop.
3. Right click on the border of the FOR loop and select add shift register, borders are converted into
shift register.
4. Using wiring operations required connections are given in the block diagram.
5. Inputs are given in the front panel and the program is executed.
Block diagram of sum of 10 natural numbers with output.

Block diagram to find the factorial of number with output.

Precautions:
1. Be sure tunnel mode is indexing. Check the tunnel mode before run the program.
2. Connect the wires properly.
Result: Sum of First 10 natural numbers and factorial of number was performed by using for loop, shift
register and tunnel.

You might also like