LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

extract data from while loop while running

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

0 Kudos
Message 1 of 16
(5,324 Views)

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.

Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
0 Kudos
Message 2 of 16
(5,323 Views)

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.

0 Kudos
Message 3 of 16
(5,312 Views)

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.

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 4 of 16
(5,301 Views)

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.

Omar I.
Applications Engineer
National Instruments
0 Kudos
Message 5 of 16
(5,265 Views)

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!

 

0 Kudos
Message 6 of 16
(5,241 Views)

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

 

Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
Message 7 of 16
(5,229 Views)

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!

 

 

Omar I.
Applications Engineer
National Instruments
0 Kudos
Message 8 of 16
(5,202 Views)

If you want to extract the data then remove while loop.

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 9 of 16
(5,184 Views)

If you want to extract the data then remove while loop.


from the subvi Smiley Wink

and then you can directly wire stop button to main vis while loop

0 Kudos
Message 10 of 16
(5,175 Views)