08-30-2005 07:22 AM
08-30-2005 07:40 AM
08-30-2005 07:40 AM
08-30-2005 07:43 AM
Hello,
Yes, I use (ofcource) the default close function.
Martin_
08-30-2005 07:54 AM
08-30-2005 08:06 AM
08-30-2005 09:01 AM
OK, this may be a bit of a problem to track down, but let's start.
First, while your front panel looks great, your code is very hard to read. Overlapping elements, multiple nested structures and a liberal use of locals make this a problem. My first suggestion would be to with a massive cleanup operation. Make more room, make wires straight, make sure things are going left-to-right, make subVIs, place some documentation and so on. You won't believe the difference this makes.
After you did that, we can turn to find the problems. Some likely suspects are the local variables and the array functions. You use many local variables and perform resizing operations which are certain to generate copies. If you do this on arrays with dozens of MBs of data, this looks like the most likely source of the problem. Some suggestions to deal with this - if you have repeating code, make subVIs or move the code outside of the structures, so that it only has to be run once. Also, you seem to have some redundant code. For instance, you open the file only to see if you get an error. You should be able to do this with the VIs in the advanced palette without opening it (and you won't need to close it, either). Another example - you check the exit conditions in many places in your code. If your loop runs fast enough, there is no need for it. Some more suggestions - use shift registers instead of locals and avoid setting the same properties over and over again in the loop.
After you do these, it will probably be much easier to find the problem.
To learn more about LabVIEW, I suggest you try searching this site and google for LabVIEW tutorials. Here and here are a couple you can start with. You can also contact your local NI office and join one of their courses.
In addition, I suggest you read the LabVIEW style guide and the LabVIEW user manual (Help>>Search the LabVIEW Bookshelf).
And one last thing - having the VI run automatically and then use the Quit VI at the end is not very nice. Since you are building it, it will run automatically on its own and you can use the Application>>Kind property to quit only if it's an executable.
08-30-2005 09:01 AM
08-30-2005 09:36 AM
Thank you for your fast reply.
I think I poluted the VI to much with trying to find a solution for the problem, that`s why there are so much exit checks. The check on the file is done to see if it is existing, if it is existing it need to be opened anyway. If the selected filename dit not change during the last action the open action will be skipped, but I agree that there is maybe a bit smarter way to do this.
I also agree with the dirty way of programing. It is a subVI of a much larger program and I programed it (to) fast. The quit funcion was first less dirty, but with some tryals to free the memory before exiting I grayed the exit out and made the sequence. Also it,s like: you start smal and then you make a function extra, and extra, .....
I did not pay attention on the fact that local variables are copies. I thought that it was just a pointer to a memory location vallid for the whole (sub)VI. I also thought that the memory is freed by giving the pointer back to the system, an action which is only costing a milisecond, (and overwriting the whole used memory block is only done when needed by the o.s.)
So thank you for your answers and I will try to make more data streaming and shift registers where possible and I hope that this works better.
Martin
08-30-2005 09:39 AM
You came with the same arguments as tst, so It must be true,
tnx