LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Making the vi faster - read from txt or array or binary reading

I prepared a vi that reads a table from txt file and find the desired values corresponding independent two variables by interpolation-attached. This via reads the txt file for each calculation. I wonder that is this process slow or enough for me. Becasue I add this via to a daq vi and I send measurement values from this via to the interpolation.vi. I acquired samples once in a sec. Or is this more convenient to read the txt once and after writing values to arrays and use these arrays as a constant (Right click array-->Data Operation-->Make current value default) in the vi? Which one is faster? And also, I wonder that instead of reading from txt file, is it a good way to convert my values in txt to binary data and read this binary values by vi? Last thing, how can I learn a vi program run-spend time?

 

Egemen
0 Kudos
Message 1 of 4
(2,831 Views)

I would read your file one time and initialize your values. I would then pass those initialized values to the subVI that is doing your DAQ stuff. File i/o is very slow (in computer terms) and should be avoided in time critical VIs. I WOULD NOT paste these as a constant. That would be very inflexible and difficult to maintain. There are a variety of ways you can pass the initialized data through your code. You could wire it directly or use action engines. If you are ambitious you could use LVOOP. Either way, hardcoded constants are not a very good approach.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 2 of 4
(2,825 Views)

@newbieeng wrote:

Last thing, how can I learn a vi program run-spend time?


Reordering your words a bit... Are you asking how to measure how long it takes to run your VI?  You can do this with a sequence structure (one of the few reasonable uses for them): in the first frame put a "Tick Count" or "Get Date/Time in Seconds" function.  In the next frame put your code.  In the last frame, put the same function that you placed in the first frame.  Subtract the time value in the first frame from the value in the last frame; the difference is the time it took to run your VI in milliseconds or seconds (depending on which time function you used).

 

Another option is the VI Profiler, under Tools -> Performance and Memory.  Open that window, click "Start," run your code, and click "Stop."  It will report how much time it took to run your VI along with other timing information.

0 Kudos
Message 3 of 4
(2,808 Views)

@nathand wrote:

@newbieeng wrote:

Last thing, how can I learn a vi program run-spend time?


Reordering your words a bit... Are you asking how to measure how long it takes to run your VI?  You can do this with a sequence structure (one of the few reasonable uses for them): in the first frame put a "Tick Count" or "Get Date/Time in Seconds" function.  In the next frame put your code.  In the last frame, put the same function that you placed in the first frame.  Subtract the time value in the first frame from the value in the last frame; the difference is the time it took to run your VI in milliseconds or seconds (depending on which time function you used).

 

Another option is the VI Profiler, under Tools -> Performance and Memory.  Open that window, click "Start," run your code, and click "Stop."  It will report how much time it took to run your VI along with other timing information.


Thank you nathand. I am sorry for usage of wrong order. I tried your suggestion and it works great. The first vi takes 4-6 msec. And the second one takes just 0 msec because it does not calculate anything, including just constant values.

Egemen
0 Kudos
Message 4 of 4
(2,786 Views)