LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Storing data in the For loop

Hi all. 

 

I'm graduate student in Korea. 

 

I have problems in my labview code. 

 

First, i use the DAQ(keysight) equipment and sensors to measure pressure and flow rate. And the signals are handled in labview. 

 

I want to measure the signals N times and finally get the graph the number of measurement vs. signals.

 

So, now i added For loop in my labview code. But, the data did not stored.

 

1. How can i store the data?

 

2. How can i draw the graph?

 

Actually, i search those things. There are two methods maybe. 

First thing is using "Shift register and Insert Into Array" and second thing is using "Shift register and Bulid array."

 

But i don't know how to apply those method into my case.

 

Thank you for your apply.

 

 

0 Kudos
Message 1 of 9
(2,120 Views)

@suminpark wrote:

 

1. How can i store the data?

 

2. How can i draw the graph?

 

Actually, i search those things. There are two methods maybe. 

First thing is using "Shift register and Insert Into Array" and second thing is using "Shift register and Bulid array."

 

But i don't know how to apply those method into my case.

 


What you are really wanting is to have an array of your data when the FOR loop completes, so you need to bring the data out of the FOR loop. The default is that the data will be auto-indexed. You're going to need to provide a better description of what kind of graph that you want (what should the data look like) in order to get good advice on how to graph your data.

0 Kudos
Message 2 of 9
(2,079 Views)

Typically, code images are useless. Why don't you attach the actual VI instead?

 

For each iteration of the FOR loop, you seem to have 8 basically identical sequential code sections that only differ in some constants. Wouldn't one instance of this code be sufficient by autoindexing on arrays of parameters? Suddenly the code would be much easier to debug and maintain!

 

Your "insert into array" near the upper left makes little sense, especially since we cannot tell what's in the diagram constant.

 


@suminpark wrote:

I want to measure the signals N times and finally get the graph the number of measurement vs. signals.

 


Typically we want the opposite: "signals vs. measurement index".

 

What exactly do you want at the end? Should all results be concatenated 5x for each of the eight arrays? How big are these orange arrays? Are all the same size? Do you want to see the graphed progress during execution or just a graph of the final 5 iterations? What is the loop rate? Do you want eight graphs or one graph with eight traces?

 

 

0 Kudos
Message 3 of 9
(2,061 Views)

What exactly do you want at the end? Should all results be concatenated 5x for each of the eight arrays? How big are these orange arrays? Are all the same size? Do you want to see the graphed progress during execution or just a graph of the final 5 iterations? What is the loop rate? Do you want eight graphs or one graph with eight traces?

 

 


Actually, there are 8 sensors(2 flowmeter and 6 pressure sensor) and i received 8 signals each sensors. 

And all of the sensors' outputs are current signal. So, there are 8 identical sequential code. 

My final goal is getting the data and plotting graph the signals according to every iterations. And I want to see the graphed process during execution. 

The number of  iteration in for loop (i.e. 5) is just sample. I want to measure more.

 

Sorry I've never heard the "loop rate"...

Finally, It doesn't matter whether eight graphs or one graph with eight traces.

 

I will attach my labview file later.

 

Thank you for your apply.

0 Kudos
Message 4 of 9
(2,031 Views)

What you are really wanting is to have an array of your data when the FOR loop completes, so you need to bring the data out of the FOR loop. The default is that the data will be auto-indexed. You're going to need to provide a better description of what kind of graph that you want (what should the data look like) in order to get good advice on how to graph your data.


My final goal is just store(accumulate) the data according to the number of repeating. The graph is secondary thing. 

 

 

0 Kudos
Message 5 of 9
(1,999 Views)
0 Kudos
Message 6 of 9
(1,997 Views)

Hi suminpark,

 


@suminpark wrote:

This is my code.


From what I can see you repeat the same code 8 times in your FOR loop, the only difference is the channel number and the scaling parameters: why don't you use an inner FOR loop to simplify your code?

 


@suminpark wrote:

My final goal is just store(accumulate) the data according to the number of repeating.


Then you need to collect ("accumulate") your measurement data in loop tunnels at the border of your FOR loop…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 9
(1,982 Views)

(Sorry, I don't have any of your drivers so I can't really do much with your VI.)

 

You've been told now the second time how to simplify your code 8x.

 


@altenbach wrote:

For each iteration of the FOR loop, you seem to have 8 basically identical sequential code sections that only differ in some constants. Wouldn't one instance of this code be sufficient by autoindexing on arrays of parameters? Suddenly the code would be much easier to debug and maintain!


You still have not explained why you need to prepend five zeroes to one of the data, but if this is what you want, built array (concatenate mode) is the more logical function:

 

altenbach_0-1624973626323.png

 

You have not explained how long these result arrays are and how the output should look like. Do you want to see the data live as it builds or only at the end? 

 

  • Linear scaling can typically be reduced to two parameters.
  • Your error wire also belongs in a shift register.
  • If you don't know how many iterations you want to do, use while loop, not a FOR loop.

 

 

Maybe you can reduce your example to a simple VI that creates random data of the same size, then tell us exactly what you want at the end.

0 Kudos
Message 8 of 9
(1,944 Views)

See if this can give you some ideas....

 

altenbach_0-1624978314840.png

 

0 Kudos
Message 9 of 9
(1,927 Views)