LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Multithreading in Labview 2014??

To be clear I don't need these two processes to run in parallel, I think they should, but I don't need that.  The real program will have pulses sent out continuously which once set up requires no input from labview.  Really I just need to understand the behavior of the read process so I can account for it when I code.

0 Kudos
Message 11 of 17
(1,105 Views)

UPDATE:

 

I think I understand what some were trying to tell me here.  When I see this code:

3.PNG

My fist thought is these two read commands are independant.  They both wait for the same error line, and will start at the same time but should run in parallel.  It turns out though that labview runs these in series.  I had to separate them into two different while loops in order for them to run in parallel.

4.PNG

Even though they both wait on the same event to happen (my button press) labview runs them in parallel.

 

Now my question is this: How do I know when Labview will run a set of commands together or in parallel?  Is there any kind of post-compile tool that can report this?  I will post this as a new question as well since it is beyond my originall question that started this discussion.

 

Thank you all for the feedback!

0 Kudos
Message 12 of 17
(1,082 Views)

@fsTAS wrote:

I think I understand what some were trying to tell me here.  When I see this code:

3.PNG

My fist thought is these two read commands are independant.  They both wait for the same error line, and will start at the same time but should run in parallel.  It turns out though that labview runs these in series.  I had to separate them into two different while loops in order for them to run in parallel.


I still think they cannot run completely in parallel due to the .NET interface.  If those were reentrant VIs, I would expect them to run in parallel.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 13 of 17
(1,078 Views)

I'm lacking enough information to know for sure, but one potential problem is that I don't think the two .NET references you are acting on are actually seperate references based the image you attached. If you look to the initialize flame subVI  you get an array of .NET references but then feed the first index into both sets of initialization methods (it doesn't look like you intended to do this). You build the array and index them properly when you feed them into the get spectrum methods they are both acting on the same object which may explain why they are not able to run in parallel. In the example you show us that works you are acting on two separate references so that could be it.

 

I'm guessing based on context clues but the methods may be forced to run in serial because they are sharing a single hardware resource.

Matt J | National Instruments | CLA
0 Kudos
Message 14 of 17
(1,064 Views)

@fsTAS wrote:

UPDATE:

 

I think I understand what some were trying to tell me here.  When I see this code:

3.PNG

My fist thought is these two read commands are independant.  They both wait for the same error line, and will start at the same time but should run in parallel.  It turns out though that labview runs these in series.  I had to separate them into two different while loops in order for them to run in parallel.

 

Even though they both wait on the same event to happen (my button press) labview runs them in parallel.

 


If you look just a bit farther back in your code you will note that the .NET referance is 1 branched wire (Test this by seeing it the referances are equal, I would bet that they are)  So, even if the .NET code is multi-threaded, you are involking the same instance of the object.

 

In your two-loop example you instantiate the .net object in each loop. What do you think would happen if you dropped the .net ref outside the for loops and branched it into the loops?  Try it! what happened?  Tricky


"Should be" isn't "Is" -Jay
0 Kudos
Message 15 of 17
(1,052 Views)

Thank you for the replys, unfortunatelly there is only one .net refference.  I'm including the Init file that generates the .net refference for clarity.  Ocean Optics only want one instance of its 'wrapper' object created even when using multiple spectrometers.  The array is built because the guy who wrote it before me thought he needed to, but in fact it's the same .net refference.  

 

I've included the two peices of code that illustrate the issue I was having the best, along with screenshots of the oscilloscopes.  I don't have a four channel oscilloscope and had to use two two channels instead.  In these pitures I read two spectrums from both spectrometers and send ten hardware triggers to the spectrometers.  In the twoWhile set they both read at the same time.  The third feedback is due to the spectrometer reading one more spectrum because its output buffer is empty.  In the oneWhile set you can see that each read happens on different hardware triggers.  Again extra feedback pulses are seen due to the spectrometers reading an extra spectrum because their output buffers are empty.

0 Kudos
Message 16 of 17
(1,041 Views)

In the twoWhile set they both read at the same time.  The third feedback is due to the spectrometer reading one more spectrum because its output buffer is empty.  In the oneWhile set you can see that each read happens on different hardware triggers. 


I goofed, the names are switched.  The picture labeled "oneWhile" is the output when running the VI with 2 while loops.  The "twoWhile" picture is when running the VI with 1 while loop.  I apologize for any confusion this may cause.

 

 

0 Kudos
Message 17 of 17
(1,015 Views)