LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

ncWaitForState thread blocking affect other while loops

I've already run this question by NI tech support and we've achieved an improvement, but not a final solution.  The question posted here is more about my understanding about the internal working of Labview.

 

I'm using ncWaitForState.vi to listen to six CAN ports simultaneously, (each CAN port is separate and distinct using 3 PXI 8464).  The App works fine for 2 CAN ports, but an high level GUI VI starts to bog-down as I add additional CAN ports each having its own while loop in a separate VI.

 

I was under the impression that ncWaitForState.vi would block the thread and that each While loop in Labview acts within it's own independent thread, but now this doesn't appear to be the case which has thrown into question my understanding of how Labview works.  In the documentation for ncWaitForState, it mentions, "The thread of a VI can be changed in the Priority control in the Execution category of VI properties", which implies that the while loop doesn't control the execution thread. Also I built the executible and looked at the task manager while the EXE is running and the number of threads indicated isn't the same as the number of While loops that are running.

 

Originally I had the timeout for ncWaitForState set at 500ms, but this causes a noticable delay in the GUI VI when I attempt to run with 3 CAN ports.  I set the timeout to 50ms and I was able to run with 4 CAN ports, but changing to 5 ms didn't improve the operation with six CAN ports.  I thinking of doing away with ncWaitForState altogether to achieve the performance that I need.  This would basically be polling which I wanted to avoid, but will do to make it work.

 

But my real questions are:

1) is my impression that each While loop runs in its own separate thread incorrect?

2) is there any Labview document that discusses the details of Labview implementation that a software engineer experienced with multithreaded programming could use to come up with an appropriate design in Labview?

3) What's the preferred/recommended way to listen to multiple CAN ports without having any interaction between them in terms of calling or sharing the same functions whiles would cause delays as each CAN port has to wait its turn.

4) I did open ncWaitForState and it's just a call to DLL ncWait.  If multiple CAN ports are sharing this same DLL, are then then inter-twinded?

5) Is there a way to identify what VI's are grouped together within the same thread and is there any control over this bundling?

 

I have attempted to change the reentrant exectution properties of the VI's that I'm using and it didn't make a significant different.  I'd like to better understand WHAT this actually does before I start changing a ton of VIs.

 

I can't reproduce the results using the two simulated CAN ports (256/257).  The current software was written in labview 8.6.1, but I suspect I would have the same issues in Labview 2009.  I'm using a current license of the Labview NI Developer's Suite.

 

0 Kudos
Message 1 of 4
(2,963 Views)

On page 39 of the NI-CAN Programmer Reference Manual for Win32, it states:

 

"While waiting for the desired states, ncWaitForState suspends only the current
execution. For C, other Win32 threads in your application can still execute. For
LabVIEW, functions that are not directly connected to ncWaitForState can execute
. "

 

For LabVIEW, what does it mean,

"functions that not directly connected to ncWaitForState"?

Does that just mean other blocks that are wired to this once specific block,

or something else?

 

 

 

0 Kudos
Message 2 of 4
(2,940 Views)

I believe that I solve the GMPT CAN communication problem that I was having with ncWaitForState, (no help from this forum...not even a reply).  I had to set the VI properties under Category: execution, Preferred Execution Systems to "data acquisition".  This appears to have solved the problem and now the 6 CAN ports no longer interfer with the GUI while loop.  I have no idea why this worked and I'm trying to find out why this made a difference.

 

 

0 Kudos
Message 3 of 4
(2,919 Views)

Hi PointOnePa, 

 

You are correct in your understanding of ncWaitForState in LabVIEW.  LabVIEW uses the dataflow paradigm and the help is stating that all functions that are not wired to the output of ncWaitForState are able to continue executing.

 

For more information on Execution Systems, please see  Multitasking in LabVIEW

0 Kudos
Message 4 of 4
(2,895 Views)