From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

passing values from a for loop

Solved!
Go to solution

Hi All,

I am fairly new to labview. What I am trying to do is a read a txt file that contains time vs speed and use the speed values to control an actuator.

 

So far I was able to extract the values from the file as a 2D array using a “for loop”. However, I can’t pass the values out from the “for loop” in real time. I used index at the tunnel, but either it will give the last value or all the values at ones. I want to get the “speed” values every second.

 

With the highlight executioner I can see that it will execute the “for loop”; but wait till the whole file is finished to execute the code after the loop. I tried shift registry, local variable, flat sequence structures….

 

If someone can help me, that will be awesome. Thank you so much in advance.

 

I have attached the VI and the txt file as well.

 

Download All
0 Kudos
Message 1 of 5
(2,709 Views)
You don't use a for loop to read the file. Call Read From Spreadsheet File once and have the for loop index the 2D array row by row. The actuator code goes inside the for loop.
Message 2 of 5
(2,700 Views)

@Sasoo wrote:

Hi All,

I am fairly new to labview. What I am trying to do is a read a txt file that contains time vs speed and use the speed values to control an actuator.

 

So far I was able to extract the values from the file as a 2D array using a “for loop”. However, I can’t pass the values out from the “for loop” in real time. I used index at the tunnel, but either it will give the last value or all the values at ones. I want to get the “speed” values every second.

 

With the highlight executioner I can see that it will execute the “for loop”; but wait till the whole file is finished to execute the code after the loop. I tried shift registry, local variable, flat sequence structures….

 

If someone can help me, that will be awesome. Thank you so much in advance.

 

I have attached the VI and the txt file as well.

 


There are several things that can be done much simpler in your vi, but in any case the following diagram (marked in red box) will help what you're trying to do (live update of your calculations):

 

 liveUpdate.png

 

-BTC

 

--------------------------------------------------------

New Controls & Indicators made using vector graphics & animations? Click below for Pebbles UI


Message 3 of 5
(2,693 Views)

Thank you so much for the replies.

 

I am afraid I didn’t have the second phase of the VI. The ultimate goal of this project is to follow the actuator according the txt file and use PID to make it closed loop. I am trying to build a closed loop dyno control system that will follow a trace. So the actuator is for a throttle control and speed signals from the dyno will be used to tune the PID.

 

Please excuse my English.

 

I am sorry, what function is this (see picture)

Also, I have attached updated VI

Download All
0 Kudos
Message 4 of 5
(2,676 Views)
Solution
Accepted by Sasoo

No worries on your English, it was fine.

 

That is "Build array" (under functions palette->Programming->Array). If you're asking what is on the edge of your For-loop, that's a shift-register (right click on right or left hand side edge of For loop, you'll see the option to "Add Shift Register."

 

-BTC

--------------------------------------------------------

New Controls & Indicators made using vector graphics & animations? Click below for Pebbles UI


Message 5 of 5
(2,671 Views)