06-26-2013 04:57 AM
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.
06-27-2013 04:21 AM
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.
06-27-2013 06:21 AM
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.
06-27-2013 09:12 AM
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.
06-27-2013 09:50 AM
Hi,
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.
06-27-2013 10:18 AM
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.
06-27-2013 07:08 PM - edited 06-27-2013 07:12 PM
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
06-28-2013 04:27 AM
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!
06-28-2013 06:15 AM - edited 06-28-2013 06:16 AM
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.
Can you tell me where can i take the function First time?
Regards,
SonNam
06-28-2013 06:28 AM
Hi,
the function is in the functions palette --> "programming --> synchronization --> first call?"
Regards!