LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to automatically stop the VI?

Solved!
Go to solution

It is an example of running a stepper motor. In the attached VI, after I press run button VI starts. Motor starts moving after I press the "START" button given in the front panel. But I want to stop the whole program after the value in the "CURRENT POSITION" equals the value given in the "DESTINATION POSITION" control. Please tell me how to do it?.

I am attaching the VI.

0 Kudos
Message 1 of 8
(3,482 Views)

1. You really should have an event for your Quit button.  A simple Boolean out of the structure to tell the loop to stop.

2. In your timeout case, you can add simple logic and use the same tunnel as 1) to tell the loop to stop.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 8
(3,473 Views)
Solution
Accepted by topic author canzie07

Hi canzie,

 

I want to stop the whole program after the value in the "CURRENT POSITION" equals the value given in the "DESTINATION POSITION" control. Please tell me how to do it?.

So you want to compare "current position" with "destination position" and use the result of this comparison to stop your while loop?

Why don't you program it exactly this way?

Use a comparison and wire the result to the stop condition terminal…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 8
(3,462 Views)

Thank you for your valuable suggestion.

I worked on it, but there is an issue.value in the 'CURRENT POSITION' is only changed until I press the 'START' button and after that whole program is stopped.

I want to do it without any manual control.

0 Kudos
Message 4 of 8
(3,405 Views)

you might want to check whether your "Start (uSMC).vi" returns an error on pressing the "start" button, drop a probe (right mouse on the error out wire).

 

edit: or perhaps you get into an infinite loop inside the "Start (uSMC).vi", so you never get to the next "Timeout" event case

 

regards


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 5 of 8
(3,399 Views)

Thank you for your valuable suggestion.

I worked on it, but there is an issue.value in the 'CURRENT POSITION' is only changed until I press the 'START' button and after that whole program is stopped.

I want to do it without any manual control.

I tried it, but unable to do it. please help me. I am attaching the picture of the program.

0 Kudos
Message 6 of 8
(3,356 Views)

attach your vi not pictures plz

 

clean up your vi:

don't have cables under things, don't have cables going the wrong way, don't overlap stuff

get rid of sequence structure (use only if you cannot guarantee execution order with cables)

 

how does your "start smc" vi react to incoming errors?

do you really need a global variable?

 

example:

clean vi example.png

 

note that the image above is a snippet, which can be dropped onto a block diagram,

you can create this yourself by going to "Edit" -> "Create Snippet from Selection"


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 7 of 8
(3,348 Views)

I have attached VI in my first post

0 Kudos
Message 8 of 8
(3,342 Views)