LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to shut down my VI?

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?

0 Kudos
Message 1 of 15
(3,617 Views)

Hi SalehRyerson,

  I think you have to change the architecture of your program and use some design patterns like event structure,because probabbly in your program when you press the stop button,your CPU is busy in logging to the file .

 

 

Thanks and regars,

srikrishna

Regards,
Srikrishna


0 Kudos
Message 2 of 15
(3,603 Views)

No.. it waits for the trigger.. i tried event structures but didn't help

0 Kudos
Message 3 of 15
(3,600 Views)

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?

0 Kudos
Message 4 of 15
(3,587 Views)

What do you mean by the loop rate? 

0 Kudos
Message 5 of 15
(3,585 Views)

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.


 

0 Kudos
Message 6 of 15
(3,583 Views)
So what you said is not accurate. The stop button is actually working the way it is supposed to. Your expectation of an instant stop is wrong.
0 Kudos
Message 7 of 15
(3,570 Views)

So what do you think I should do for an instant stop?

0 Kudos
Message 8 of 15
(3,550 Views)

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

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 9 of 15
(3,545 Views)

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.

 

- tbob

Inventor of the WORM Global
Message 10 of 15
(3,503 Views)