LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading one and one value from either excel or text file

Solved!
Go to solution

Hello

 

We are some students working on a schoolproject where we want to control some motor outputs. We want to create a set of input-values that are being red into our program either excel or text file.

For example we want a input to read value "1" then the program runs its course and we get a result of the input "1", after that read the next value "2" and the program runs its course and so on.

 

We have searched for clues and answeres, but i guess were really bad at that. Anyone here that could help us out?

 

Under you can see one of our programs, its designed to control 3 fans depending on the input (CO ppm). We want to replace the "Numeric Controller" (CO ppm) into "something else" that gives us one and one input from a list of values.

 

 

 labv prog.PNG

 

 

Kindly regards

 

Weary students

0 Kudos
Message 1 of 11
(3,143 Views)
All that you need is a Read From Spreadsheet function to get data from a text file. This will return an array. Wire it into a for loop and it will be auto-indexed one line at a time. There are shopping examples and numerous posts on reading from text files.
0 Kudos
Message 2 of 11
(3,129 Views)

Thanks for the reply, we will look into it and try it out.

0 Kudos
Message 3 of 11
(3,105 Views)

Hi Guys!

 

Nice to see that you are using this for your school project! Below I included two Knowledge bases with the information that you need. You can learn from it and try to see if you can read something and display it, to start with. Then try looking for specific data. 

 

http://digital.ni.com/public.nsf/allkb/E02847A93FD79F7486256E050070E85B?OpenDocument 

 

http://digital.ni.com/public.nsf/allkb/99F61B6AB9CD6AFA8625734600814D6B?OpenDocument 

 

Please let me know how this works out for you. 

 

Collin de Wit
National Instruments
Applications Engineering

0 Kudos
Message 4 of 11
(3,066 Views)

Hi guys, the links have a space at the end, this might cause an error when opening. After clicking on it, please delete the space at the end and the links will work just fine!

 

Collin de Wit
National Instruments
Applications Engineering

0 Kudos
Message 5 of 11
(3,045 Views)

Thanks for the replies!

 

We will try it out as soon as we can 🙂

 

 

 

0 Kudos
Message 6 of 11
(3,024 Views)

We have managed to create the file to read from and getting the output shown below.

Lab 1.PNG

 

But our new problem is implementing it to our VI as shown below

Lab 2.PNGLab 3.PNG

 

Have checket the forums for conversions to numeric, but we still get some errors that faults our comparison function.

 

Any suggestions?

0 Kudos
Message 7 of 11
(3,002 Views)
None of that makes any sense. First, you not want to be constantly reading the file in a loop. Second, off you want the values as strings, simply select that type by clicking on the polymorphic selector below the function. There doesn't appear to be any need to convert to strings, however. Third, if you want to compare each element to some value and connect to a case statement, the read from spreadsheet should be outside an auto-indexing for loop with the compare and case statement inside the loop. You simply cannot connect a case selector to an array.
0 Kudos
Message 8 of 11
(2,988 Views)

To simplify our questin of what we want is to switch out our input (CO ppm) to a function that reads a set of values. Say that it first read "20" then "45" --> "60" --> "75" --> "90" -->"100" -->"100" --> "90" and downwards in timed intervals.

The different values that are given in will be compared to different set-points, when the comparison values are met, we get an output depending on how many compares are triggered.

 

lab 4.PNG

0 Kudos
Message 9 of 11
(2,970 Views)
So do as I recommended with the Read From Spreadsheet outside a for loop. If you are unaware of a for loop's auto-indexing feature, you really need to take some of the free LabVIEW tutorials.
0 Kudos
Message 10 of 11
(2,958 Views)