10-30-2013 09:07 AM - edited 10-30-2013 09:08 AM
Hello all,
This must be simple and easy, but I don't seem to get it. A sample VI is attached.
I have a slider control onto which I do some manipulation to generate a numeric element output. I can keep on sliding and get the generated outputs, but now I need to store all those possible outputs in a 1D array.
Your help will be much appreciated.
Regards
Solved! Go to Solution.
10-30-2013 10:07 AM
Yes reasonably simple and easy. You missed a few basics on LabVIEW. see the attached note in the modified VI.
(Also presented as snippette for those not caring to DL Attachment
10-30-2013 10:43 AM
Thanks Jeff,
I was also trying the shift-register at my end, but with a 'for loop'. Didn't work.
Just for understanding, is the loop suspension done to first have the initialized array in the buffer ? Or it serves additional purpose too.
Regards
10-30-2013 10:46 AM
Do a quick search on the term "Greedy Loop." The link will take you to many discussions that can explain why some delay is desireable.
10-30-2013 11:01 AM - edited 10-30-2013 11:02 AM
nskatlv wrote:Just for understanding, is the loop suspension done to first have the initialized array in the buffer ? Or it serves additional purpose too.
The wait forces the loop to wait 10ms before going to the next iteration. This is still way too generous, because there is no way you can operate the control that fast. Ideally you should use an event structure so the loop only spins when a new value is entered. It is really not very useful to overwrite the same value 100x per second if nothing changes.
A loop without any wait at all is called a greedy loop. It spins as fast as the computer allows (millions of times per second), using 100% of a CPU core, and starving all other processes and programs on your computer that also want a slice of the pie. It is only useful in winter if your heater is broken and you want to run your computer as hot as possible. 😄
10-30-2013 11:11 AM
Lol, I get it altenbach.
From the search term Jeff shared, I had already stumbled upon this toon of yours. Will never forget it now. 🙂
Although the problem as I stated stands solved, it turns out it might not be easy (or so it seems) to implement it in my actual big diagram. Because there are many a sliders and then scripts etc running to finally yield that output numeric indicator I need to store the values of.
Is there another solution (may be using event structure), which sees 'only' the output indicator and stores it's values as they change.
Regards
10-30-2013 11:37 AM
nskatlv wrote:Is there another solution (may be using event structure), which sees 'only' the output indicator and stores it's values as they change.
What is your definition of "see"?
10-30-2013 11:45 AM - edited 10-30-2013 11:47 AM
I mean a code that only envelops the output indicator, and not the slew of code behind it that makes it's values change.
I just created a version using Event Structure, but it needs the rest of code in the structure. Attached.
Regards
10-30-2013 12:42 PM
@nskatlv wrote:
I mean a code that only envelops the output indicator, and not the slew of code behind it that makes it's values change.
I just created a version using Event Structure, but it needs the rest of code in the structure. Attached.
Regards
Thanks for coming back to the topic.
YES, I would be using an event structure to capture user activity on the front panel. I did not want to go past the few larger problems untill you understood them. Go ahead and try something new. Check the help file. Post another thread when you get stuck or want a specific piece of advice.
10-30-2013 12:54 PM
Thanks Jeff,
The point where I am stuck is that in the latest code I attached (with Event Structure), is it possible to modify it so that only the indicator (Y=x*5) is taken inside the structure and while-loop. While the rest of stuff (sliders and calculators here) remain outside.
I say this because in my actual code, the input sliders and the calculating code is big and scattered, and am afraid of messing it up while trying to put certain things inside structure and the loop.
Regards