LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabView programing

PURPOSE Create a LabVIEW program that reads from a text file a group of numbers and place their values in a 1-D array. Then, from this original array, the program creates two additional arrays: one array containing the numbers of the original array that fall within a range of values input by the user; the other array containing the numbers that are multiples of a number input by the user. PROGRAM TASK A text file with numbers written in a column (a number per line) will be provided. The numbers will vary randomly between 1 and 99 (no zeros and no repetitions). The program must read the numbers in the text file and place them in an array of the corresponding size. The user must enter on the front panel the file path where the text file can be found in the computer. An array indicator must eventually display the full original array of numbers. The user must also enter a minimum value and a maximum value of a range of values and the program should display an array with the numbers belonging to the original array whose values fall within that range including the minimum and maximum values. The program should display on the front panel a new array with the correct length with those numbers falling in the range. The user should also enter on a separate control a number that will be used by the program to find multiples of that number from the set of numbers of the original array. Another new array with the correct length must display those numbers that are multiples. At the beginning of running the program, the three arrays should be displayed as having only one NULL element initialized with value zero. A Start button must be pressed by the user to start the process of building the arrays. As the program runs, it must display the arrays growing progressively as each new element is added. The original array obtained from the text file must be displayed first in its entirety. Then the other two arrays should be built. At the end of the program, the three arrays displayed on the front panel should have the exact lengths. In summary, display the arrays on the front panel incrementally element by element until their proper final length. Start with only one element of each array displayed on the front panel as a NULL element (greyed out). As the program runs, the arrays build automatically to their final lengths.
 
 
 
 
 
 
 
To read a text file with numbers, you need to read the file and then convert the characters of a string into actual numerical values. To do that you need to use the functions: “Read from Text File” and “Spreadsheet String to Array”. In the latter function, use “%d”, which is format decimal integer, for the format string, and use the “Enter key” (return key/next line character) as the delimiter. Make use of the various array function options that are very useful like: Initialize Array, Insert into Array, Replace Array Subset, Build Array, Index Array, Array Size. The Help will tell you what the functions do and what inputs/outputs are needed. If you initialize with zeros an array with certain number of elements, you may later change their value with the “Replace Array Subset” function. If you initialize a Null array with no elements, you may insert elements with the “Insert into Array” function. The “Index Array” function is also very useful. If it receives as input the index of an element, it places at the output that element’s value. You may use comparison functions including the “Select” function. You may also use the gate functions like AND, OR, NOT, etc. To display the arrays on the front panel incrementally element by element, you may, in the block diagram, initialize each array as an empty array and use the function “Insert to Array” within a loop to add one element at the time to the corresponding array. For the incremental display of the array, you right click on the array indicator terminal of the block diagram, and on the menu that appears select: create property node number of rows. On the “number of rows” icon you right click and select “Change All to Write”. The text file with the numbers, the range of values to enter, and the number whose multiples are to be found will be given at the time of the homework presentation. An example of text file is provided separately for practicing and testing your program. The front panel should look like in the figures below before pressing the “Start” button and after the program finishes running. In these figures, the user has previously entered values for minimum and maximum of range and a number whose multiples are to be found. And the user has previously defined the file path for the example (practicing) text file provided.
0 Kudos
Message 1 of 5
(1,306 Views)

People here won't do your homework for you.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 2 of 5
(1,298 Views)

Which part are you having trouble with?

 

For fun I prompted ChatGPT with the purpose paragraph in your original post.

Spoiler

To create a LabVIEW program that reads from a text file and performs the operations you mentioned, you can follow the steps below:

  1. Create a new VI in LabVIEW and add a "Read from Text File" function from the "File I/O" palette to the front panel.

  2. Add a 1-D array to the front panel to store the values read from the text file. You can add a "1D Array" function from the "Array & Cluster" palette to the front panel.

  3. Connect the output of the "Read from Text File" function to the input of the "1D Array" function.

  4. Add two controls to the front panel, one for the range and another for the multiple. You can use "Numeric Control" or "Numeric Indicator" functions from the "Controls" palette for this.

  5. Add two more 1-D arrays to the front panel, one for the values within the range and another for the multiples of the number. You can add "1D Array" functions from the "Array & Cluster" palette.

  6. Add a "For Loop" structure to the block diagram and place it after the "1D Array" function that reads the values from the text file. Within the For Loop, use a "Case Structure" to perform the operations of filtering the values that fall within the range and finding the multiples of the number.

  7. In the first case of the "Case Structure", use a "Compare" function to check if the current value of the loop is within the range. If it is, use the "Build Array" function to add the value to the array for values within the range.

  8. In the second case of the "Case Structure", use the "Modulo" function to find the remainder of dividing the current value of the loop by the number. If the remainder is zero, use the "Build Array" function to add the value to the array for multiples of the number.

  9. Connect the output of the "For Loop" to the inputs of the two arrays for the filtered values.

  10. Add a "Stop" function to the block diagram and connect the output of the "For Loop" to the input of the "Stop" function.

  11. Save the VI and run it. You will be prompted to select the text file to read from. The program will then read the values from the file and store them in a 1-D array. It will then filter the values that fall within the range and find the multiples of the number, storing the results in two additional arrays.

This is just a basic example, and you can add more functionality and error handling to the program as needed.

Matt J | National Instruments | CLA
Message 3 of 5
(1,274 Views)

@Jacobson-ni wrote:

Which part are you having trouble with?

 

For fun I prompted ChatGPT with the purpose paragraph in your original post.

Spoiler

To create a LabVIEW program that reads from a text file and performs the operations you mentioned, you can follow the steps below:

  1. Create a new VI in LabVIEW and add a "Read from Text File" function from the "File I/O" palette to the front panel.

  2. Add a 1-D array to the front panel to store the values read from the text file. You can add a "1D Array" function from the "Array & Cluster" palette to the front panel.

  3. Connect the output of the "Read from Text File" function to the input of the "1D Array" function.

  4. Add two controls to the front panel, one for the range and another for the multiple. You can use "Numeric Control" or "Numeric Indicator" functions from the "Controls" palette for this.

  5. Add two more 1-D arrays to the front panel, one for the values within the range and another for the multiples of the number. You can add "1D Array" functions from the "Array & Cluster" palette.

  6. Add a "For Loop" structure to the block diagram and place it after the "1D Array" function that reads the values from the text file. Within the For Loop, use a "Case Structure" to perform the operations of filtering the values that fall within the range and finding the multiples of the number.

  7. In the first case of the "Case Structure", use a "Compare" function to check if the current value of the loop is within the range. If it is, use the "Build Array" function to add the value to the array for values within the range.

  8. In the second case of the "Case Structure", use the "Modulo" function to find the remainder of dividing the current value of the loop by the number. If the remainder is zero, use the "Build Array" function to add the value to the array for multiples of the number.

  9. Connect the output of the "For Loop" to the inputs of the two arrays for the filtered values.

  10. Add a "Stop" function to the block diagram and connect the output of the "For Loop" to the input of the "Stop" function.

  11. Save the VI and run it. You will be prompted to select the text file to read from. The program will then read the values from the file and store them in a 1-D array. It will then filter the values that fall within the range and find the multiples of the number, storing the results in two additional arrays.

This is just a basic example, and you can add more functionality and error handling to the program as needed.


Super excited to hear about the GPT integration for LabVIEW 2023! 

______________________________________________________________
Have a pleasant day and be sure to learn Python for success and prosperity.
0 Kudos
Message 4 of 5
(1,218 Views)

@Jay14159265 wrote:

@Jacobson-ni wrote:

Which part are you having trouble with?

 

For fun I prompted ChatGPT with the purpose paragraph in your original post.

Spoiler

To create a LabVIEW program that reads from a text file and performs the operations you mentioned, you can follow the steps below:

  1. Create a new VI in LabVIEW and add a "Read from Text File" function from the "File I/O" palette to the front panel.

  2. Add a 1-D array to the front panel to store the values read from the text file. You can add a "1D Array" function from the "Array & Cluster" palette to the front panel.

  3. Connect the output of the "Read from Text File" function to the input of the "1D Array" function.

  4. Add two controls to the front panel, one for the range and another for the multiple. You can use "Numeric Control" or "Numeric Indicator" functions from the "Controls" palette for this.

  5. Add two more 1-D arrays to the front panel, one for the values within the range and another for the multiples of the number. You can add "1D Array" functions from the "Array & Cluster" palette.

  6. Add a "For Loop" structure to the block diagram and place it after the "1D Array" function that reads the values from the text file. Within the For Loop, use a "Case Structure" to perform the operations of filtering the values that fall within the range and finding the multiples of the number.

  7. In the first case of the "Case Structure", use a "Compare" function to check if the current value of the loop is within the range. If it is, use the "Build Array" function to add the value to the array for values within the range.

  8. In the second case of the "Case Structure", use the "Modulo" function to find the remainder of dividing the current value of the loop by the number. If the remainder is zero, use the "Build Array" function to add the value to the array for multiples of the number.

  9. Connect the output of the "For Loop" to the inputs of the two arrays for the filtered values.

  10. Add a "Stop" function to the block diagram and connect the output of the "For Loop" to the input of the "Stop" function.

  11. Save the VI and run it. You will be prompted to select the text file to read from. The program will then read the values from the file and store them in a 1-D array. It will then filter the values that fall within the range and find the multiples of the number, storing the results in two additional arrays.

This is just a basic example, and you can add more functionality and error handling to the program as needed.


Super excited to hear about the GPT integration for LabVIEW 2023! 


I was wondering of ChatGPTs abilities with LabVIEW. Thanks! So now its a simple matter of writing some scripting code that takes that text and makes LabVIEW code. 

Certified LabVIEW Architect
0 Kudos
Message 5 of 5
(1,200 Views)