LabVIEW Embedded

cancel
Showing results for 
Search instead for 
Did you mean: 

how to save data in an array ??

I want to ask about how to save data in an array.For example,i have an array of 360 indexes.Each array has its own values.I want to take the delta=next index´s value - previous index´s value.For instant: delta = index 1´s value - index 0´s value..etc..Then i let it go to the last delta = index 360´s value - index 359´s value.

After that i will make the filter.All of the above index,that have the delta larger than 100 will be chosen.Then i want to save these indexes into a new array.In the new array,these chosen indexes will be the new values.

I tried but i can only save the last result.

Can somebody help me?Thanks a lot.

0 Kudos
Message 1 of 11
(6,640 Views)

Hi !

 

When you give a Value out from a while-loop or a for-loop, you have the option of "auto-indexing output tunnel" (you can set this through right-clic on the output tunnel).

That way you will keep one value for every loop and the output after the loop ends is an array.

In addition, you have the option of setting a condition. Then it only keeps the value when the condition is true.

 

To understand this, I made you a little example.

I hope it is what you are looking for.

 

Best Regards!

 

Martin L.

Message 2 of 11
(6,625 Views)

Thanks a lot for your example.

I try another one in my own way.I got the result but now there is a problem.For example,i get the array that has 5 indexes and that 5 indexes repeats n times.May be the amount of repeat time goes to infinity.

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

Hi

What exactly do you mean by "that index repeats n times"

 

Do you have an Array like this?     [10, 10, 10, 10, 10]

 

If you tell a for-loop to make N iterations it will only make N, that means if your array containes 5 elements and you use "array size" or auto-indexing, there will be no problem.

 

Is this what you mean?

Otherwise I would ask you to explain a little bit more detailed.

 

Regards!

 

Martin L.

0 Kudos
Message 4 of 11
(6,608 Views)

Smiley HappyHi,

Because this is just a subVI and it is inside a big outside while loop.So when i get the array,the array will be repeated and it only stop when i stop the big program by pressing the stop button.

For example,i get the array like: [1 2 3 4 5],in this case,it will be like [1 2 3 4 5 1 2 3 4 5 1 2 3 4 5......]

And i just want to get the array [1 2 3 4 5] but i dont know how to get this.

 

0 Kudos
Message 5 of 11
(6,605 Views)

Hi!

why do you need this code inside a While-loop? Does this While loop make only this task?

If it is the only task, you do not need the while-loop. If it is not the only task, you can call the subVI before you start the while loop and pass the array with the indexes as an input to the while loop.

 

Otherwise you can integrate the example I gave you to the main while Loop. (without for-loop)

 

Regards!

Martin L.

0 Kudos
Message 6 of 11
(6,600 Views)

Hi!

I'm working with the laser scanner LMS 100 of SICK company.Inside the big while loop,there are 4 sub-VIs.The first is for TCP connection between the LMS and computer.It includes IP and port.The second is for transferring data from string to array.The third is the one i am asking.It is used to take the data from the array and calculate the diameter of object.The values of the array are distance from laser scanner to object and because the LMS give the data continuously so it must be put inside the while loop.

The general idea is that.

I just want to cut and use [1 2 3 4 5] from [1 2 3 4 5 1 2 3 4 5..............]

I have an idea to cut this array and use only the first five indexes.But each time i measure,the number of indexes changes.So it will be hard to fix the amount of using indexes.I hope you can help Smiley Very Happy

0 Kudos
Message 7 of 11
(6,595 Views)

Hi

Could you post a Screenshot of your main VI?

 

if I understand correctly you only want the subVI that searches for these index to run one time?

 

There is a function called "first time" and it gives you a "true" value during the first loop and "false" in every other.

So you could run this VI in a case structure only during the first iteration.

 

Regards!

0 Kudos
Message 8 of 11
(6,588 Views)

Hi!

The program i want to ask is on the IRONMAN sub VI.

I get the array from DAQ and then take the indexes which full fill the condition of delta to make new array in IRONMAN.

Smiley Happy

Can you tell me where can i take the function First time?

Regards,

SonNam

0 Kudos
Message 9 of 11
(6,583 Views)

Hi,

the function is in the functions palette -->  "programming --> synchronization --> first call?"

 

Regards!

0 Kudos
Message 10 of 11
(6,580 Views)