03-25-2010 06:07 PM - edited 03-25-2010 06:08 PM
I want to create a VI that allows the variable (SEE SHIFT REGISTER) to increase from min to MAX by Delta and then decrease from MAX to min. The problem is that I want one thing: that at the end of the descent the cycle stops itself (Numeric, at the end, must be zero). I have tried with variable Control, but the program stops itself when numeric is 3.
To explain: the variable starts from 0, after 1, 2, 3, 4, 5, 4, 3, 2, 1, 0 and stop.
Have you a very intelligent solution for this problem? Can you post a VI for LW8? Maybe with same correction to my, THANKS!!!
03-25-2010 06:32 PM
a very basic fix would be:
stop the loop if Numeric=0 and iteration counter i>0
this would only work for your example case 0,1,2,3,4,5,4,3,2,1,0
if your starting value [min] is < 0, then it won't work
03-25-2010 06:51 PM
Laura,
One thing I notice is that you write TRUE to Stop local variable when Control=2 (lower left of the diagram). It doesn't sound like this is something that you want.
Greg
03-25-2010 07:09 PM
03-25-2010 08:42 PM
03-26-2010 01:14 AM
03-26-2010 02:36 AM
03-26-2010 05:48 AM
Why dont you use another shift register to count the number of minimums (when =0 then add count). Then when this is equal to a value you want to stop at you can use it to stop the loop.
As a side note, if you are working in integers I would change all your control representations to I16 or similar. Sometimes working with an equals and double precision float can throw up anomolies due to rounding errors etc. Not only that but your code will be more efficient too.
Craig
03-27-2010 01:25 AM