01-06-2015 10:35 AM
Hello guys,
So I have this Vi designed to aquire 5 voltage inputs and also control 3 brooks mass flow controllers via a 0154 control box. After the VI runs for about 30 minutes there is a noticeable slow down in the operation (front panel updates are choppy, if I hit the switch there is a delay before anything happens). At this point if I hit the stop button the VI closes without any errors, it just takes a while.
Any ideas what could be causing this or how to avoid this slow down phenomena? I am using labview 2012 on an old pentium IV with upgraded RAM. Attached is the main subvi (MergedInterface) and two of the subVIs, I have left out the subVIs which control the Brooks instruments.
Thank you,
Luca
01-06-2015 10:40 AM - last edited on 08-19-2024 02:17 PM by Content Cleaner
Your problem is your constantly growing arrays that you use for the logs. Constantly building arrays uses a lot of memory. Once they get large enough, the memory allocation can slow you down to a crawl.
I recommend looking into a Producer/Consumer. The idea here is to use a queue to send the data to another loop. The other loop just reads the data in the queue and writes it to the file. So the file is constantly being written to. This will free up a lot of your memory and allow your program to run faster.
01-06-2015 10:43 AM - edited 01-06-2015 10:45 AM
1) In your digital_output - you are opening/closing the DAQ device every 100ms. You should initialise the device before the loop runs and close it when the loop ends.
2) You're repeatedly building a larger and larger string array and then writing at the end. It would be more memory efficient to write a single row to the text file each time the loop runs rather than at the end. It also means if you have to abort your application for any reason you don't lose any data.
3) (the most likely cause) You have no execution timing in your bottom loop - meaning it will run as fast as your CPU/DAQ hardware will allow. This also means that the data array in that loop will grow very quickly. Nevermind - i've just seen you have the timeout of the DAQ task.
4) Avoid using the dynamic data type wherever possible - try to use the numeric functions rather than DDT's and express VIs as this will improve performance.
01-06-2015 12:38 PM
Thank you both for these suggestions, I will let you know how I get on.