09-30-2013 08:42 PM
Hi!
I've been struggling with this for a while an reading in forums but still haven't found a good solution.
I'm going to make it simple:
I have a main vi with 3 leds and a subvi inside a while loop.
The sub vi has a Horizontal Pointer Slide (0-1000) inside a while loop (let's call it while2)
I need to turn on the leds in main vi while monitoring the slide ranges every 100ms:
0-500 led1 on
500 - 750 led1 & led2 on
750 - 1000 all three leds on
I've tried local variables, global variables, shared variables... but data is only actualized when while2 finishes.
How can I pull data from while2 without stopping it so I can make my leds function as described?
Thanks!!
09-30-2013 08:49 PM
I can only guess from your description, but it seems like you may need to change your architecture significantly to get what you want.
Please zip and attach your main and sub VIs. Then we can take a look and give some solid suggestions.
09-30-2013 09:22 PM
How do you stop the while loop that is inside the subVI?
The loop the subVI is in won't iterate again until the subVI finishes. And the subVI won't finish until the while loop inside of it ends.
You should turn on highlight execution so you can understand how your VI's work.
09-30-2013 10:39 PM
This is what while loop do. It will hold the control untill it finishes. Hence untill it wont stop it won't pass the data.
10-01-2013 10:34 AM
Hello smurillo,
As the community said, we need more information about your application. For example, what are you going to connect in the horizontal slide??? just a time checker or you have an external data???
The while loop retains the values until it finishes its cycles. If you want to view the slide filling up in "real time", i recommend you to change the second while loop to another structure, just like a case structure. With this case structure you will able to see how the slide is filling up as the program is running.
I'm sending you an example where we can monitoring the time elapsed using the while counter, the cycle time is determined in Wait Untill Next ms Multiple.vi. To turn off/on the leds indicator, we can send a boolean constant to each led, the value depend on the time range the program is.
This is just an example...
I hope this information help you to develope your application...
Omar I.
10-01-2013 07:02 PM
Hi Omar!
There's a screenshot of my program. As I said, this is a simplification of my problem. I need to turn on the leds in the main.vi with the slider in the testleds subvi.
In the example you can see a variable Stop I'm using from the main.vi to stop all the loops, so I thought the same principl was going to work for my leds but aparently is not.
Thanks for your help!
10-01-2013 08:36 PM
The second while loop in main.vi will never update the boolean indicators until it's subvi (testleds.vi) has finished executing.
Even though your global variables have the same name as the boolean indicators on main.vi, they are not linked. It's just a name
May I please strongly recommend that you complete the online LabVIEW tutorials.
Then you will understand why this doesn't work. That is more important than having a solution handed to you.
Does the code in testleds.vi have to be a subvi? Does it have to be in it's own while loop?
http://www.ni.com/gettingstarted/labviewbasics/
https://decibel.ni.com/content/docs/DOC-13978
10-02-2013 04:45 PM
Hello smurillo,
Thanks for share your applications, is very useful to reccomend you some tips. Exactly, the while cycle throw out the results until the cycle is finished, thats the reason you will never see leds changing. I recommend you to delete the while cycle in the subvi, so each time the main while completes its cycle you can see how the value in leds is changing.
Also you can have the stop button in the main while, this is just for better practicing...
I also Recommend you to give a quick view to basis in labview, just like this document or help section in labview.
http://digital.ni.com/manuals.nsf/websearch/4ECC47F63A6C58B686257B7A0070104B
I'm sending you some images with this modifications...
Good Luck!
10-02-2013 09:54 PM
If you want to extract the data then remove while loop.
10-02-2013 11:43 PM
If you want to extract the data then remove while loop.
from the subvi
and then you can directly wire stop button to main vis while loop