07-17-2018 03:42 PM
I am currently trying to run a case structure inside a for loop under a certain range of values. My question is how do I create a range of values between the iteration mines a value of x where the case value will run for one value, and then when the range is exceeded (again i-x) the case structure will be changed to another value?
Thank you in advance and I am a relatively new user to labview.
07-17-2018 04:12 PM
A simple state machine is all you need.
Please be much more specific. What are the values? Are they increasing monotonically? Unless you can calculate the total number of iterations based on the values of the array you cannot use a FOR loop. I assume you have an array of values, so instead of a case structure, just use "index array" and change the index to the next element when appropriate.
It usually help if you would attach some code (even incomplete) so we have a better picture on what you are talking about.
07-19-2018 09:28 AM
I have attached the file.
I am basically trying to run the loop for a set amount of iterations (in this case 200) and have the case value be false until it reaches a range of values in which case there will be a true value.
I would then like to add another case structure for when it reached 200 to run another sub vi within the case strucuture.
Thank you again for any help you can provide.
07-19-2018 12:57 PM
All you probably need is a single case structure connected to [I], but that's not very flexible. Are the ranges always the same? (Sorry, on the phone. Cannot look at code).
07-19-2018 01:07 PM
No the ranges can change. I think you might have a better idea when you see the simple code.
07-19-2018 01:16 PM
I had a look at it.
First, you're using a While loop, not a For loop. For loops are for when you know exactly how many iterations you want before you start, and While loops are for when you're not sure and you want to check a condition. Which better suits you? (Note that you can choose to terminate a FOR loop early as well).
Next, you're doing floating point math and then comparing it to an integer loop value. Big no-no. You'll want to change that at the very least to a "greater than or equals" because the instant you have any input that's not a whole number you're never going to pass the equals check. A better want would be to change the representation of all your numbers that should only be integers to I32s to force them to be that way. Right now if you try to run this with an acceleration time with anything other that an integer number of seconds it will never match equality.
07-19-2018 01:17 PM - edited 07-19-2018 01:18 PM
OK, looking at the code:
07-19-2018 01:43 PM
Thank you. I meant a while loop.
What about creating a range of values?
07-19-2018 01:46 PM
07-19-2018 02:08 PM
Thank you very much! I'm looking through it now and will probably have questions later on!