LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can i execute in the same block diagram two separate labview codes each one with diferent execution timings?

Hello guys. I have been trying to solve this by a long time now...but i cant solve it....

 

I have my main code in labview beying executed in one timed loop of 1second.....but now i need to pulse a lazer very fast than one second...

my ideia was like executing the lazer pulse code in paralel with the main code but with a mutch faster timed loop....but when i put the second timed loop outside of the main one....it hapens that the aplication keeps runing only the faster loop and the main loop doesnt run....

 

I really dont know how to solve this....

 

many thanks

 

 

JOSE

 

0 Kudos
Message 1 of 12
(5,207 Views)
Your faster loop must be starving the main loop. Can you post an example VI so we can understand how you have configured this?
Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 2 of 12
(5,198 Views)

000000001 wrote:

when i put the second timed loop outside of the main one....it hapens that the aplication keeps runing only the faster loop and the main loop doesnt run....


In addition to what was said above, your two loops may not be truly independent, and thus the second loops never runs (it's waiting on the first one to complete). Post a screen shot of how the loops are setup.

Richard






0 Kudos
Message 3 of 12
(5,189 Views)

Hello...i solved my problem but created another one :(.....ive created two while loops, one around the main aplication and the other around the VI that represents the other part of the code that i want to run faster....but now when i have 3 stop butons and when i try to stop the program it doesnt stop...

 

Is there a way to conect all the stop buttons to only one?

 

thank you

 

JOSE

0 Kudos
Message 4 of 12
(5,176 Views)
The simplest way would be to have only one "master" stop button, the create two local variables from it, using them in the other loops. One worry, if you have different loop speeds, is that the stop button's state remains "stopped" long enough for the other loops, particularly a slower one, to detect it and stop. This can be done with the "mechanical action" selection of the button.
Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 5 of 12
(5,171 Views)

First, you're going to have to press the 3 stop buttons to get it to stop.  (Actually, only 2 of them since 1 isn't connected to anything.)

 

What is happening inside the subVI that is in its own while loop?  Does that have a loop inside of it that keeps it from stopping?

 

Why do you have a while loop with a False wired to the Continue terminal?  You have shift registers on that loop, but it serves no function since there is always a value initializing the while loop.  And the while loop only runs once.

0 Kudos
Message 6 of 12
(5,168 Views)

JOSE,

 

your code is really difficult to read. Please do some cleanup work, your diagram should be only little larger than an average computer screen. What I have glanced so far is that your code has a lot of beginner mistakes (overuse of local variables).

 

For multi-loop applications, you shoul have a look at the tutorials concerning Producer-Consumer design pattern. The quick and dirty approach is to use locals (a bit contradictonary to suggest using locals here after I stated an overuse of them). The drawback will be, that you lose the latch mechanism of the button and must code it on your own (and make a big set of mistakes, using locals always attracts race conditions). Most important is that you write to your button only once, after all loops have finished spinning.

 

Felix

0 Kudos
Message 7 of 12
(5,167 Views)

It may be possible to change the while loops to timed loops...in the timed loops, there is a priority setting that would let you assign a higher priority for the process you wanted to run the fastest.  If you have a multicore machine, you could also suggest that the code us processor 1 for one loop and 2 for the other...

 

If your code needs to run all the time, then the loop is fine.  If it only needs to run when something changes, you might consider using the event structure, inside the while loop.  As the forum is teaching me, once you kick off one event, nothing else much happens till it finishes...

 

Hope this is useful.

 

Hummer

0 Kudos
Message 8 of 12
(5,157 Views)

A short illustration of my post

 

Felix

 

Multiloop Stopping.png

Message 9 of 12
(5,152 Views)
I cleaned your code a little. I did fix a couple of things but there is a lot of work to do to make your code better. It is in LabVIEW 2009. Let me know if you need a different version.
Tim
GHSP
0 Kudos
Message 10 of 12
(5,122 Views)