09-02-2011 08:57 PM
Hello,
I am quite new to LabVIEW and am having an issue with a shift register. I have a case structure within a for loop. I am sending a 1D array into the for loop, and if my condition is true, I would simply like to let the value leave. For false I am trying to simply do nothing, allowing the for loop to filter out the elements that don't meet my criteria.I tried using this shift register, but to no avail.
Attached is my code, the area of interest is at the bottom of the block diagram where it leads into the 1D array "index (closest < D)"
Any advise would be appreciated.
09-02-2011 09:08 PM
You only have one shift register shown in your VI, and that is in the third of your four For Loops. You are either incrementing a value or not incrementing a value.
If you are talking about your fourth For Loop, you don't have a shift register there at all. Your code is actually broken because you have an unwired tunnel. If you want to selectively build an array, then you need to add a shift register for the array, and either build a new element onto the end of the array in one case, or pass it through untouched in the other case.
09-02-2011 09:17 PM - edited 09-02-2011 09:18 PM
Sorry, Uploaded the wrong version. I've been testing it with entering in N= 4, and D = 50. I am unsure how to wire the false case to do nothing, so far I just have wire it through in the false case which is not correct. Thank you.
09-02-2011 10:12 PM
Can you save your VI as LV2010 and repost (File>>Save For Previous Version)? Thanks.
09-06-2011 12:53 PM
Hi Scirocco90,
I'm not quite sure if I understand you very well. Do you want to feed in a pre-existing array and then check the values of the array and delete elements as needed? Or do you want to build an array based on input numbers, and decide whether these inputs are valid or not before putting them in the array?
I have attached an example program which builds on array based on whether the boolean button on the front panel is turned on or off. If the button is true, the case structure is entered and the build array function is reached, which adds the value in "Number to Insert" to the array. However, if the button is off, the array is not added to. It may be easier for you to use while loops with shift registers instead of for loops as well. I hope this helps!
09-07-2011 09:19 AM
@julianne K wrote:
Hi Scirocco90,
I'm not quite sure if I understand you very well. Do you want to feed in a pre-existing array and then check the values of the array and delete elements as needed? Or do you want to build an array based on input numbers, and decide whether these inputs are valid or not before putting them in the array?
I have attached an example program which builds on array based on whether the boolean button on the front panel is turned on or off. If the button is true, the case structure is entered and the build array function is reached, which adds the value in "Number to Insert" to the array. However, if the button is off, the array is not added to. It may be easier for you to use while loops with shift registers instead of for loops as well. I hope this helps!
One suggestion I have, and this should be standard practice for all app engineers who work with NI, when you post, down convert your code to something like 8.2 so more folks can view your suggestions. We all can benefit this way. Thanks.
09-07-2011 10:35 AM
code snippets are also good to show many people the solution..
09-08-2011 10:55 AM
Hi MoReese,
Thanks for the suggestion. I have attached the code saved in version 8.2 and also a screenshot of the code snippet.