01-26-2016 01:11 PM
Hello, I am looking for a function similar to a SELECT function, but for arrays.
I am trying to do the following:
Let's say, 3 random numbers functions are compared to a value (of 0,5). If the condition (is bigger than) is TRUE, i need to switch on a button and hold logical ONE for the rest of the time - so I do not care about the value of random number after. It is important for me, that the condition was true once. So it is like a cummulative function of 3 led buttons, which tells me at the end, that the condition was fulfilled at least once for each of 3 comparisions (if all of the buttons are true).
I managed to do it for a single random number only, using SELECT function and SHIFT register, but I did not manage to do with arrays of numbers.
Maybe it is easy for someone of you a you can help me, because I am stuck :D....
If this problem has been resolved already, I am pretty sorry - but I could not find the keyword for describing my issue.
Thank you very much and have a nice day.
Pinca
Solved! Go to Solution.
01-26-2016 01:14 PM
Please provide what you've tried already so we can better understand and help portray back to you what we suggest.
Most everything that can be done with a scalar can easily be adapted to an array. Instead of Select, you could us Search Array for the first True value.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
01-26-2016 01:14 PM
Attach your VI you have so far. That way we can see how you've started and can help you figure out how to become unstuck.
01-26-2016 02:55 PM
Yeah I think I know what you want, but your description could be interpreted a couple of ways, code would make it more clear what you are trying to do when you use a scalar, and why it doesn't work when you use an array.
If you have 3 arrays, and you want to pick one, you could try to use something like this:
https://lavag.org/topic/16842-my-xnode-select-n-inputs/#entry109444
Note that the thread is primarily about an XNode select function which is unsupported, but that thread has useful information on selecting an array.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
01-26-2016 03:39 PM - edited 01-26-2016 03:40 PM
Use an array ot three booleans in the shift register (initialized with an array of three False booleans).
Build an array of your three buttons and take the OR of the two arrays (one from the buttons and one from the left shift register and feed the output into the right side shift regsiter.
An "AND array elements" of the array will turn true once all elements are true..
01-26-2016 04:02 PM - edited 01-26-2016 04:03 PM
Here is some simple code as described.
The VI will stop once all booleans have been true at least once. I set the condition to >0.98 to make it run a bit longer. Modify as needed.
(note that even in your original code, a boolean OR is significantly simpler than a "select" function.
01-27-2016 12:42 AM
This is where I became stuck - for a single condition everything was ok (i clicked the button and ONE was held in the shift register for the rest of time.
For array, the appropriate values were displayed only but were not kept when no condition was fulfilled.
01-27-2016 12:49 AM
Thank you very much altenbach. I will try to modify it for the situation, where I do not have the exact number of booleans to compare (between one and four). So I will try it.
Pinca
01-27-2016 01:22 AM
@Pinca wrote:
This is where I became stuck - for a single condition everything was ok (i clicked the button and ONE was held in the shift register for the rest of time.
For array, the appropriate values were displayed only but were not kept when no condition was fulfilled.
You array code does not contain a shift register at all. That's a critical ommission.
01-27-2016 07:34 AM
Yes, I had it there before, but this was the only try that made a little sense - but using shift register in this case made it all doing wrong.
Thank you.