07-29-2011 04:26 AM
Hello!
Ive a little problem. I aquireing data from a sensor, via VISA VIs, and i display them on a chart. The measureing VI also generates a report, to Excel, from every second, and an average in every minute. When the program saves the report, the charts are frozen for a 6-8seconds and in that time no data is incomeing. Can anybody tell me what can be the problem? Thank you for any answer
Regards,
M. Gabor
Solved! Go to Solution.
07-29-2011 05:15 AM - edited 07-29-2011 05:18 AM
Hey M. Gabor,
Would you be able to show me your code so I could take a look at it? Could you please take a screenshot, or preferably attach your VI?
Is there any other information you can provide, such as error messages that you may be receiving during program operation?
What kind of file access method are you using? For a continuous measurement process, you should use file streaming when writing the measurements to avoid constantly opening and closing a particular file. If you are using another method this will incur a delay in your process, however nowhere near to the extent that you're describing; but it may give us some hints.
07-29-2011 05:23 AM
Thank you for ur answer. I attached my code below. I hope u can help me.
M. Gabor
07-29-2011
06:29 AM
- last edited on
07-09-2025
06:40 PM
by
Content Cleaner
@MGabor wrote:
Thank you for ur answer. I attached my code below. I hope u can help me.
M. Gabor
Hey M. Gabor.
I've taken a look at your VI and I believe that the problem is that the single while loop you have implemented to do the acquisition and processing is just too large for LabVIEW to handle. It's processor intensive and no timing has been implemented, which is generally a requirement for loops because they will otherwise attempt to iterate as fast as it possibly can and use up at lot of your CPU. What I believe to be happening is this loop has just so many tasks to do as fast as it possibly can, that upon each iteration that it just can't cope and slows itself down. This is what I suspect would be the reason why your VI slows down so much when you're trying to write data.
What you should try to do is really take advantage of LabVIEW's ability for concurrency through the use of multiple simultaneously operating While Loops. A good software design pattern for the acquisition and processing of data (Therefore you'll see it used in plenty of LabVIEW applications) is the Producer Consumer Loop design. The idea behind it is you have multiple loops operating simultaneously that perform their own individual functions to make an entire program operate a lot faster and more efficiently; this sort of design would be ideal for your program because you have to acquire and then process large amounts of data. Through the producer loop, you could assign measurement tasks and after the measured data is acquired, you could perform processing tasks in the consumer loop. As you have a pretty detailed Front Panel, you could implement another daisy-chained consumer loop to process GUI related data. For more details on the Producer Consumer Loop, click here.
I can see that the while loop also has build path functions that produce a constant path; these can be taken out of the while loop because you could just build them once and the while loop would then simply just decide when to use them rather than when to use them and then build them all over again; easy fixes like this will make your while loops as processor friendly as possible! It's always best to go through a While Loop and try to determine whether a task to be repeated over and over again is truly necessary or not.
Hopefully if you make these changes to your VI, it will be much more streamlined and I'm fairly sure your freezing error will be eradicated.
Please keep me updated with how you get on!
07-29-2011 07:11 AM
Thank your for your helpness, i try to solve this producer-customer programming.
07-29-2011 07:47 AM - edited 07-29-2011 07:47 AM
@MGabor wrote:
Thank your for your helpness, i try to solve this producer-customer programming.
That's great. Keep me updated!
08-01-2011 02:46 AM
Thanks for your idea, there is no frozen panel. In the block diagram exist two parallel while loops, but I didnt do the producer/customer method with queses. I made a global variable for all the data, that the excel report generator section needs. The second while loop reads all data from the global. Thanks for this method, there gives not any frozen panel or anythink. Again thank you, for your helpness. If you want i can post the new VI.
M. Gabor
08-10-2011
10:22 AM
- last edited on
07-09-2025
06:40 PM
by
Content Cleaner
@MGabor wrote:
Thanks for your idea, there is no frozen panel. In the block diagram exist two parallel while loops, but I didnt do the producer/customer method with queses. I made a global variable for all the data, that the excel report generator section needs. The second while loop reads all data from the global. Thanks for this method, there gives not any frozen panel or anythink. Again thank you, for your helpness. If you want i can post the new VI.
M. Gabor
That's great! I'm glad I could be of some use to you.
I'd like to see how you implemented your design because it could be a little risky; in LabVIEW you should try to avoid the use of Local Variables as much as possible as you can implement Race Condition situations with their use; this is where some data can be lost or overwritten because the same memory location is being accessed at different points in time by different areas of your code. You can help synchronise the access of a shared memory location by the use of Semaphores or Functional Global Variables.
However, in a Data Acquisition application like yours, you don't want to risk the loss of any data; and when acquiring at a high speed, you'd need to implement some form of buffer to hold unprocessed data; this is why the Queue is so useful; it will queue up all of your new data which is ready to be processed!
Here's an example on avoiding race conditions, to give you an idea of how this can be affecting your code.
08-11-2011 01:27 AM
Hello!
I attach the VI ive built as u request:). Ther project become week by week more complicated. You know, this VI measures the fuel tanks fuel level. Now i need to send the calculated fuel level to another PC via internet. Can you help me how to start this? Shall i send the calculated litre datas or, the continuesly saved excel files?
Thank you, for your help.
08-14-2011 11:49 AM - edited 08-14-2011 11:54 AM
@MGabor wrote:
Hello!
I attach the VI ive built as u request:). Ther project become week by week more complicated. You know, this VI measures the fuel tanks fuel level. Now i need to send the calculated fuel level to another PC via internet. Can you help me how to start this? Shall i send the calculated litre datas or, the continuesly saved excel files?
Thank you, for your help.
Hey M. Gabor,
Sorry it has taken a while for me to get back to you, I've been doing a lot of training recently!
If you know the IP of the computer you want to communicate the data with, then it's a snap; try out the Simple Client.vi and Simple Server.vi found in the example finder of LabVIEW under LabVIEW > Help > Find Examples... They're found under Data Communication.
Try running the Client and Server at the same time communicating with the same port on your computer and check out the block diagrams to see how they operate; you'll be surprised by the simplicity of it!
I usually find it's best that whenever you're wanting to learn something completely new in LabVIEW, it's always worth checking the Example Finder. There are so many solutions and it's a rare occasion that you can't find an example code for what you want.
If you have any more troubles with the code that you're implementing and they don't fall under this now resolved topic, it'd be best to create an entirely new forum question for everyone to answer. This will keep everything well categorised and will help people find solutions to their problems easier when they try searching for them here.
Best of luck with your code!
Regards,