LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stop Button in While Loop Not Working

Solved!
Go to solution

Hi everyone,

 

I am attempting to control a stepper motor using some code attached. Right now I am able to send a pulse signal and have the motor rotate (still figuring out the direction signal but that is a problem for a different day). My current problem is stopping my program. I am only able to get the motor to turn off if I click the Abort Execution button. I made sure my stop button is inside the loop and the properties on the button are set to "switch when pressed". Any ideas on why my stop button is not having my motor turn off?

 

Much appreciated.

0 Kudos
Message 1 of 5
(1,143 Views)

It is too bad that you failed to wire the Error Line in your Express VIs.  We don't know what hardware you are using, and can't tell if perhaps one of these VI's is "hanging".  Have you tried running the VI with the Block Diagram visible to you and "Highlight Execution" (the little light-bulb on the Menu Bar) turned on?  You might be able to see where the Execution stops and "hangs" ...

 

Bob Schor

0 Kudos
Message 2 of 5
(1,113 Views)

Thank you for your reply!

 

I wired an error line between the Simulate Signal block and the DAQ Assistant block but do not seem to be running into any errors there (I could have done this wrong, I do not have much experience using the LabVIEW error lines). I ran the VI with the Highlight Execution turned on and while doing this, I can see the Stop Button signal to the loop to stop and it looks like the data stops being sent out. This leads me to think that it is a hardware issue.

 

The devices I am using are the NI 9264 voltage module with a Nema 23 stepper motor and the M542T driver. I attached their spec sheets here.

Download All
0 Kudos
Message 3 of 5
(1,060 Views)
Solution
Accepted by topic author NZ14

LabVIEW is a Data Flow language.  The Principle of Data Flow says (basically) that given a "structure" (a VI, a While Loop, a Frame Sequence, a Case Statement), the following three things hold:

  1. You cannot enter the Structure until every input to it has data expressed on the input.
  2. You remain in the Structure until every element in the Structure finishes executing.
  3. If there are outputs from the Structure, none of them will have values until the Structure exits.

There are some special cases where this doesn't apply, but you're not ready for that yet.

 

So you have basically 5 obvious "Structures" on your program:  A Simulate Signal Express VI, a (Dreaded) DAQ Assistant, the While Loop that encloses them, a second DAQ Assistant, and the Case Structure that encloses it.  Of these, only one has anything resembling an "exit" condition, namely the While Loop when the Stop button is True.  However, if Dreaded DAQ Assistant 2 is still running, your program will still be running ...

 

I'm not sure what you mean when you say "the data stops being sent out" --makes me think you are talking about Simulate Signal.

 

I'm going to "guess" that the problem is the Dreaded DAQ Assistant in the While Loop.  Try removing it (just delete it) and see if your program runs and also stops.  I'd also suggest setting the frequency to something other than 0.

 

Bob Schor

 

 

0 Kudos
Message 4 of 5
(1,050 Views)

I switched from the DAQ Assistant to using DAQmx blocks and was able to get the loop to work correctly. Thanks for your help!

0 Kudos
Message 5 of 5
(1,014 Views)