07-04-2011 10:55 AM - edited 07-04-2011 10:58 AM
I am having problems closing the VI. The STOP button doesnt work for some reason. And if I try to close down LabVIEW, the computer freezes.
I am attaching my LabVIEW file. Can someone please take a look at it and fix this?
07-04-2011 01:18 PM
07-04-2011 01:22 PM
No.. it waits for the trigger.. i tried event structures but didn't help
07-04-2011 03:22 PM
Your stop button gets read as a first step with each iteration, meaning the loop will most likely spin once more, executing all code in the loop.
I don't have any of your "scope" subVIs, so I cannot really judge the inner code. What determines the loop rate of the while loop?
07-04-2011 03:31 PM
What do you mean by the loop rate?
07-04-2011 03:36 PM
I also tried enclosing the STOP button in a continuous loop so the value can be updated at every step. But the problem persists. It waits for the trigger and then after getting the trigger it executes the whole cycle and then the program ends.
07-04-2011 04:59 PM
07-05-2011 12:34 AM
So what do you think I should do for an instant stop?
07-05-2011 01:15 AM
There's ofcourse lots of questions like: Why do you initialize, reset and setup you NI equip every loop? How fast to you try to spin the loop (Looks like 20 million times per second approx).
What's this trigger you mention? What generates it? What's listening to it?
What you're experiencing is the program waiting forever for the signal.
/Y
07-05-2011 07:13 PM
Here are some things you should do to help you get a better stop performance:
1. Remove the sequence structure, it serves no purpose. The error wries will dictate execution flow.
2. Move everything before the ni Scope Read WDT to before the loop. The setup should only be performed once, not on every loop.
3. Move the ni Scope Close to after the loop. Use shift registers for Error In and Error Out on the loop borders.
4. Wire the data out of Fetch to the loop edge and set indexing enabled to create a 2D array. Move all of the write to file stuff to after the loop. Your loop will run until you click stop, then all of the data will be written to the file just once. The way you have it, you are creating a file and writing to it every loop iteration. Just create and write once after all data has been gathered If you need to write data to a file on every loop iteration, then create the file once before the loop and pass the file reference to the loop. Put only the write function inside the loop. Close the file after the loop.
5. Put a small delay, even 0 mS, inside the loop to keep the vi from chewing up all processing time.
Your architecture should look like this:
Scope setup, file setup --> Loop to gather data and write to file --> Close file, close scope
With this architecture, when you press Stop, there is much less code to be executed on the final loop so you will see a quicker stop.
One more thing, clean up your wiring so that it is easy to see where things come and go. You have wires hidden by other wires, too many wire bends, which makes it difficult to read. Put controls to the left and indicators to the right. Data flow should always be from left to right when possible.