10-05-2012 02:06 PM
Hi Everyone,
I am using Labview 2009.
I want to change the value of a variable using both Knob or Keypad.
So I downloaded a multi-rotational Knob and Keypad VIs which suits my requirements from the forum.
Both the VIs are running inside a WHILE loop. Since I would be continously updating the variable I will run my main VIs which houses these both the VIs also in a WHILE Loop.
Problem is that while loop inside a while loop 😞 I couldnt run my main VI because of this issue.
I tried in 2ways
1. Including them as sub-VIs in my main VI but as the both VIs contains some other variables inside the inner while loop Labview pops up error as sub-VIs wont work 😞
2. I also tried copy paste the both VIs as it is in my main VIs but could only end up in heap of errors.
How to deal with this issue of nested while loops?
Please guide me.
Regards,
Manoj
Solved! Go to Solution.
10-05-2012 02:25 PM
I have not looked at the attached VI's.
Have you tried removing the while loops in the new VI's and then put the left over code into the while loop in your program?
10-05-2012 02:40 PM
If you put these both in a VI, you can only call one at a time.
If you put the code from both into a VI you have to deal with the Event Structure, and there is no timeout state. You have to put the keypad into the event structure. The keypad is polling, the knob is eventing 🙂
If you want to control a variable by using either a keypad or a knob, you will have to use the concept both of these VI's are based on, and you will have to either ditch the event structure or incorporate the keypad into the event structure.
Now, you could launch both VI's to display, and then have them communicate back to the launcher, which seems a bit excessive, there are a lot of details that would have to be used in the Launching VI with the variable in order to control both VI's.
I would suggest incorporating a knob into the keypad polling loop.
Please describe a bit more what you are trying to achieve. Why not just use one or the other?
Two Cents 🙂
10-05-2012 03:56 PM - edited 10-05-2012 04:01 PM
You can easily put both codes in one VI, but you need to do some patching and mending, of course. Don't be afraid of temporarily broken wires.
Create an event structure with two events, one for the knob change and one for the keypad change, the use whetever the latest entered value is and write it to the other control.
You could even incorporate both into a single X-control where you can select one or the other input method as desired. Look for the shipping example of the thermometer x-control that can switch between two units. Same thing!
(Also, if you attach code by others, please quote the source for reference. This knob is my code!)
10-09-2012 09:48 PM
Bryan
Please have a look at my main VI.
I have tried to insert to both VIs in my main VIs which is error free but it isnt working.
The keypad vi keeps on polling and the whole VIs wont execute properly.
10-09-2012 09:55 PM
Mark
I am just giving user more options of controlling/updating a variable using both keypad and knob.
I know at a time I can call only 1 VI.
I do agree your 2 possiblities but the question is how do you incorporate a knob into keypad polling loop since i cant add it literally.
10-09-2012 10:04 PM - edited 10-09-2012 10:05 PM
Altenbach
In my main VI i ve added both VIs which is error free but not executing 😞
there is already event structure for keypad with multiple events, do u mean to add knob vi into this event structure and make appropriate changes?
10-09-2012 10:22 PM - edited 10-11-2012 02:36 PM
You are making a dataflow mistake. The outer loop can only spin if all code in it has completed. The event structure cannot complete because the inner while loop does not complete, and if the inner while loop completes, the loop cannot spin because the event structure stalls. You can only go to the next iteration once both have completed, starting the mess all over.
All you need to do in incorporate ALL code inside the event structure. Attached is a simple draft (LV 9.0), modify as needed.
See if it makes sense to you. (there are probably minor bugs)
10-09-2012 11:26 PM - edited 10-09-2012 11:27 PM
Try this. This has both the keypad and the knob in the event structure.
10-09-2012 11:34 PM - edited 10-09-2012 11:36 PM