LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Setting an OK switch in a sequence structure

My problem is that I have a vi which controls a stepper motor but I want the stepper motor to begin when I click the 'OK' button, not instantly when I run the vi.

I am running a sequence structure of five frames:

1. A Booleam OK control in a while loop set to 'Continue if true'.

2. My vi writing to a digital line, this sends a pulse to the stepper motor.

3. A wait (ms) vi

4. My vi writing to a digital line, this sends a pulse to the stepper motor, this second pulse completes one step of the motor.

5. Wait (ms) vi again.

This sequence structure is enclosed in a while loop, with a Boolean stop button set to 'stop if true'. The vi is also re-entrant as I have incorporated a clockwise/anticlockwise control in
to the vi. The whole thing works fine but I just need to fix the 'OK' button problem. Any ideas?
0 Kudos
Message 1 of 5
(3,221 Views)
Put a case structure inside your while loop. inside that case structure put youe code in the true case and leave the false case empty, Wire your OK button to the case structure for the true or false. inside the last frame of the sequence wire a true output to stop the loop. There are many examples that show this type of coding. If you cannot find one let me kow and i will show you how it is done.


Hope this helps

Joe



Joe.
"NOTHING IS EVER EASY"
0 Kudos
Message 2 of 5
(3,221 Views)
just wanted to say I was having a similar problem but thanks to this thread have gotten it sorted out!

cheers
0 Kudos
Message 3 of 5
(3,002 Views)


rjwilliams wrote:
just wanted to say I was having a similar problem but thanks to this thread have gotten it sorted out!

This is a very old thread. I would strongly suggest NOT to implement such a beast, but use a plain event driven state machine architecture instead.
 
Especially the original question has a few very silly things that make absolutely no sense, for example there is no reason to have this re-entrant, and "stop if true" is not a feature of any stop button, but of a while loop termination terminal. There is probably no sequence needed. You never want to spin an empty loop for no reason.
 
If you don't mind, show us your code and we might be able to suggest improvements to make the code dramatically simpler, more scalable, amd more readable. 🙂
0 Kudos
Message 4 of 5
(2,987 Views)
I ended up using the 'wait for front panel activity' function, just read through this post and decided it best to use case structures to implement the button.
0 Kudos
Message 5 of 5
(2,963 Views)