06-30-2010 04:05 PM
This is supposed to be very easy but I can't figure it out. Here's what I wanna do in labview:
if (variable == 0){
x = x - 5;
}
else if (variable == 1){
x = x + 5;
}
This looks very simple but I'm just not good enough with the whole "graphical programming language" concept.
I'm attaching what I came up with but that seems to keep two different "x"s. Every time I switch "variable" from 0 to 1, x resets to zero; it shouldn't.
Any help is appreciated.
Solved! Go to Solution.
06-30-2010 04:22 PM
Don't use those hard to read feedback nodes. They are too confusing. Use shift registers instead. Look at the attached vi. The add function is common to all cases so pull it out. Use the case to just select the number to be added. Also put a delay in your main loop to avoid using 100% CPU time.
06-30-2010 05:22 PM
Your problem is that each case has its own feedback node. They don't share data, each one keeps its own history!
All you need to do is move the feedback node outside the inner case so it is shared by all cases.
(And please put a small wait in the UI loop).