LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

multiple input and nested while loop problem

Solved!
Go to solution

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

Download All
0 Kudos
Message 1 of 11
(3,293 Views)

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?

0 Kudos
Message 2 of 11
(3,287 Views)

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 🙂

 

 

 

 

-------
Mark Ramsdale
-------
0 Kudos
Message 3 of 11
(3,279 Views)

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!)

0 Kudos
Message 4 of 11
(3,267 Views)

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.

0 Kudos
Message 5 of 11
(3,220 Views)

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.

0 Kudos
Message 6 of 11
(3,217 Views)

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?

0 Kudos
Message 7 of 11
(3,216 Views)
Solution
Accepted by topic author Manoj90

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)

Message 8 of 11
(3,212 Views)

Try this. This has both the keypad and the knob in the event structure.

 

 



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 9 of 11
(3,199 Views)

Mark, he needs LabVIEW 2009.

 

(yours is not that different to mine right above)

Message 10 of 11
(3,194 Views)