01-19-2021 09:20 PM
Hello everyone,
im pretty new to labview and im trying to code a tool that is analyzing the duration of a signal. The values im getting with the waveform duration vi is displayed in a histotgramm graph. The thing is, the code should run for a while and when its gonna acumulate a lot of data, the anomalies are going to get lost in the histogramm. The Signal is just a simulation im working with for the later experiment in the laboratory
My idea was that im writing a case-structure where im defining default value +/- tolerance. I want to write the values that are out of tolerance into an array and display it into a graph.
The code works and the values are getting written into the array, but it always overwrites the elements in the array.... Im sitting for hours at the problem now and i cant solve it.....
Does anybody have a solution or an idea why its not working? Thanks a lot to the people taking their time to help a noob in labview!
I have attached the part of the code that im have trouble with.
Best Regards!
P.S. Sorry if my english is not that good, not a native speaker here
Solved! Go to Solution.
01-19-2021 09:36 PM
Why are you placing your values into the array inside a for loop? Your for loop will run for as many iterations are your "i" value is from the while loop. For the first iteration of the loop, you will NEVER place any values into the array since you are wiring a 0 to the "n" value of the for loop. If your condition is true for the second iteration, you will put one value into the array. If the third iteration of the while loop meets the condition, you will write two values in the array, starting at index 0. If your condition is met in the 1000th iteration of the while loop, you will write 999 entries of the same value into your array, again starting at index 0 thus overwriting any previous data in the array.
What would seem to make more sense would be to write either a 2-D array so that you can write the current loop iteration your condition was met as well as the value at that point in time. Or you could have an array of clusters. The cluster would contain the iteration value when the condition was detected and the second element would be the value.
You can use a conditional, auto indexing terminal on your while loop to build the array of values.
01-19-2021 10:24 PM
Hello Mark,
thanks for answering to my post.
i dont fully understand clusters yet, so i didnt try anything with that method. i was just using the for-loop to fill the array because thats what i saw in the basic videos on youtube.
I tried the method with the conditional auto-indexing out of the while-loop and it worked. Is there a possibility to build the array inside the while-loop? The Methode with the auto-indexing out of the while-loop works, but it shows the results after the while-loop stops, that means that i cant see the data that is going to be displayed into the graph until the data aquisition is completly done.
Thanks a lot for trying to help me and sorry if im asking stupid questions without realizing
01-19-2021 11:08 PM
You can use shift registers on your while loop and a "build array" node to build the array inside the loop.
01-20-2021 10:46 AM - edited 01-20-2021 11:22 AM
@Flouran93 wrote:
I tried the method with the conditional auto-indexing out of the while-loop and it worked. Is there a possibility to build the array inside the while-loop? The Methode with the auto-indexing out of the while-loop works, but it shows the results after the while-loop stops, that means that i cant see the data that is going to be displayed into the graph until the data aquisition is completly done.
Several additional comments:
01-20-2021 11:27 AM
Here are some of the points I mentioned illustrated. Still not perfect but should give you some ideas....
(Note that is a literal translation and does not judge the validity of the algorithms ;))
01-20-2021 05:56 PM
Hello altenbach,
thanks a lot for your comments and tips. It really helps me as a newbie learning to work with labview.
You're completly right that the code i wrote can be considering as poor coding, but my primary goal is trying to set it up, so its runing.
Also thanks a lot for the modified example you attached in your post.
Have a great day!