LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble in pausing a stepper motor through LIFA

Hi,

I have been working on a project which involves labview controlling an arduino UNO which in turn controls a stepper motor driven by a Big easy driver. I used one of the examples that come in with the LIFA toolkit and made some modifications for my requirement to run the motor in a continuous loop because the maximum number of steps i can give it at an instance is just 32767. The Dial which comes in with the VI actually could pause the stepper intitally but after i used the while loop to run the motor in a continuous loop, the dial no longer works. This is because the control doesnt come out of the loop unless it finishes the iterations. I tried using a stop button but it wont work. I have also found example vis' where i could pause while/for loops but here in this instance i am unable to use them. Please help me out, im running on a very tight schedule. I shall attach my VI for reference.

Thanks in advance,

Venky

0 Kudos
Message 1 of 4
(4,074 Views)

I'm a bit confused on what you are trying to accomplish here.  Could you explain what you are wanting to input and what you are expecting the motor to do?

As far as the code, the PAUSE 2 button will not be able to stop the loop if the loop starts when it is false because it is never read in the while loop (the while loop to which I am referring is the one in the OK Button value change event).  If you want to be able to stop that particular loop with that button, you would need to move it inside the loop.

0 Kudos
Message 2 of 4
(3,014 Views)

Nathan,

Thanks for the reply. I am trying to move an actuator that is connected to the stepper motor. I need to make the stepper move long distances and also pause its motion sometimes which can be accomplished only if i run the stepper write in a while/for loop. But when im doing this, the dial which was working as another event will not fire up until the control comes out of the while/for loop which gets triggered by the OK button.

So i am now trying to use a pause button so as to stop the while loop during its execution which im failing to achieve. I tried moving the PAUSE2 button inside the while loop too but to no avail.

I am attaching the modified VI.working model2.jpg 

0 Kudos
Message 3 of 4
(3,014 Views)

To get the pause button to work appropriately (purely code-wise), you needed to simply move it into the while loop without changing any of the other logic.  Chaning the stop condition to "Run while true" and using the OR is causing it to not work.  However, as far as I understand, this won't actually stop the motor because it should continue until it has turned 30,000 steps once you leave that loop unless given another command.  So, if after stopping this loop, you use the dial, I believe it should obey the dial again.

I still feel that having this loop in the event structure is not the way to do this.  Could you give more details about what you are doing?  Please give me numbers (steps: max, min, etc.) and context; as much as possible.

0 Kudos
Message 4 of 4
(3,014 Views)