The post talks about making loops and shift register in the LabView.
For Loop Using LabView
![]() |
For Loop Using Labview |
- The For Loop is located on the Functions>>All Functions>>Structures palette. The value in the count terminal (an input terminal), indicates how many times to repeat the sub diagram.
- The iteration terminal (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.
While Loop Using Labview
![]() |
While Loop Using LabView |
Two different types of terminating conditions can be set:
- Stop if True (default setting) – When using this condition, the while loop will run until a certain condition is met
- Continue if True – When using this condition, the while loop will run until a certain condition is no longer satisfied or true.
(Right-Click on the stop sign terminal and select Continue If True)
Iteration Terminal – The iteration terminal will keep record of how much iteration have been completed. The iteration count always begins from 0, so during the first iteration, the output from the iteration terminal will be 0.
Finding Factorial of a Number using a FOR and a WHILE Loop
Algorithm:
- Create a numeric control in the front panel and connect to the count terminal N of the FOR Loop.
- Create the shift registers on the input and output border of the FOR loop and initialize the value as 1 in the input.
- Increment the iteration terminal, wire it as one of the input to the multiplication and other input is from the shift register.
- Wire the multiplication output to the output shift register.
- Create an indicator at the output terminal of the shift register.
- Run the program and get the factorial of a number.
![]() |
Finding Factorial with For Loop |
Addition of n Numbers using WHILE Loop
To perform addition of numbers using while loop
Operations:
Shift resistor constant = 0
i = i+0
If i >10 : stop and give the result
Algorithm:
- Create a numeric control in the front panel and connect to the count terminal N of the FOR Loop.
- Create the shift registers on the input and output border of the FOR loop and initialize the value as 1 in the input.
- Increment the iteration terminal, wire it as one of the input to the multiplication and other input is from the shift register.
- Wire the multiplication output to the output shift register.
- Create an indicator at the output terminal of the shift register.
- Run the program and get the factorial of a number.
![]() |
Addition of N Numbers Using While Loop |
Addition of n Numbers using FOR Loop and Factorial of Number Using While Loop
Lets perform addition of n numbers using for loop and factorial of N using while loop
![]() |
Addition of n Numbers using for loop and Factorial of N Number using While loop |
No comments:
Post a Comment