LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabView Loop Performance


The code I am having problem with is reading data from a com port at 10x per second. For each com port data an image is captured and a measurement is taking from this image. All these happens in a while loop with 5ms delay. When the program is executed the loop time is about 80ms. What I am seeing is that if the mouse is moved quickly or a web browser is opened or another program is open for that matter, the while loop time spikes to as high as 300ms. On the front panel I have an image, array indicators and two charts.

 

My question is what is causing this behaviour and what is the best way to prevent? The computer I am using has 4GB of RAM.

0 Kudos
Message 1 of 8
(2,414 Views)

Moving the mouse or similar causes windows to redraw the panels, that could be a reason. You can defer panel updates to avoid this. Apart from that i think the cause is blue.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 8
(2,407 Views)
If you want to prevent Windows from interrupting your program, you need to stop using Windows. You can move to LabVIEW real time. Windows is simply not deterministic.

There are things you can do to minimize the problem. If your serial buffer is big enough, you won't lose any data.
0 Kudos
Message 3 of 8
(2,395 Views)

The delay is caused by the operating system, the serial read, your GUI being updated, etc.  Remember, unless you're using RT the operating system is not deterministic and will go off and do other things as needed and slow down your program.  If it's important to have this operate as quickly as possible on the existing system you should not use it for anything else while the VI is running.  Also look at what services are running on that system and disable any that are not needed.

 

Kelly Bersch
Certified LabVIEW Developer
Kudos are always welcome
0 Kudos
Message 4 of 8
(2,392 Views)

If you get 10 messages per second from the com port and one image and measurement per message, then it seems that you only need to accomplish everything within 100 ms. So what is the purpose of the 5 ms delay?

 

Consider a Producer/Consumer architecture. By using parallel loops the time critical code can be put into a loop with no front panel interface. That makes it far less susceptible to delays from the OS. Depending on exactly how your program is set up you might need two Producer loops, one for the com port and another for the image.

 

Posting your code will allow us to better determine what might be going on.

 

Lynn

0 Kudos
Message 5 of 8
(2,387 Views)

 

Before the computer locks up due to other activities, the total time per loop is about 80ms, I agree the 5ms doesn't make any sense. However it doesn't matter what the loop delay is, the effect is similar when other activities are carried out during vi execution. The requirement is that when I get location data from com port, I must take an image; these two actions must go together so I am not sure if  Producer/Consumer architecture will meet this requirements. Thanks.

0 Kudos
Message 6 of 8
(2,321 Views)

VIs which have do not use the User Interface thread (meaning, generally, that there are no control or indicator terminals, property nodes or local variables in them), can usually run without much interference from user activities.  That is one of the advantages of a parallel loop architecture like Producer/Consumer. All the UI activity is in one loop and the other is free from that interference.

 

There may be some delays between reading the com port and sending the image capture command.  You did not specify how the program communicates with the image capture device. Most likely that involves calls to the OS (as does the com port).

 

How much delay can you tolerate between receiving a com port message and capturing the image?  As others have mentioned you may need to go to a real-time system for tight timing requirements.

 

If this data is important and you can get adequate perfromance from a desktop operating system, then you should absolutely prohibit the users from doing things like opening other programs or mousing around. If you cannot train and control the operators, you will probably need some kind of real-time system.

 

Lynn

0 Kudos
Message 7 of 8
(2,309 Views)

Probucer/consumer should work well for your needs, but you probably need an RT system if you need more determinism.

 

Kelly Bersch
Certified LabVIEW Developer
Kudos are always welcome
0 Kudos
Message 8 of 8
(2,308 Views)