LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stepper Motor Problem - stopping a pulse train

Hello everybody,

I have a problem with the control of a stepper motor.

Here is what I want to achieve:

I want to turn the stepper motor to a certain position, where it is supposed to stop.

Therefore, I output a continuous pulse train to turn the motor. In order to make sure the motor turned to the desired position, I receive a counter signal from the encoder, that tells me the actual position.

When this actual position is >= the desired position, the  pulse train is supposed to stop!

 

So far, most things work well, the motor turns to the desired position, when the change is completed, a certain Boolean turns true.

In my stripped down version attached, this boolean stops the while loop, and the motor stops at the desired position.

However, in my actual program, I do not want to stop the whole loop, as different measurements are executed within the loop that I don't want to stop.

All I want to stop is the output of the pulse train.

 

I hope the problem is understandable.

 

Best regards & thanks for any hints

 

 

0 Kudos
Message 1 of 9
(3,454 Views)

Hi Jack,

 

Could you use two separate loops?  Once the motor gets to the right position, just tell the loop that is outputting the pulse train to stop.  You could use a notifier?

 

See the attached VI.  I also added some error checking, the way you had it configured, the loops would keep running even if errors had occurred.

 

 

Lewis Gear CLA
LabVIEW UAV

0 Kudos
Message 2 of 9
(3,435 Views)

Hi Lewis,

thank you for your reply!

The bad error handling is just the result of me creating a very stripped down VI of my actual program 😉

Some questions are remaining however.

I had the same idea before, output the pulse train in a separate while loop and stop it whenever I reach my desire position. The idea still makes sense to me, however, I face the same problem I have when I try to open you VI.

 

The Boolean wires going from loop a to loop b are "broken wires". Context help says that they are "members of a circle".

 

So I suppose you don't have this problem opening the VI you posted?

 

cheers,

Jack

0 Kudos
Message 3 of 9
(3,425 Views)

Hey Jack,

 

I have not seen this error before?  Could you screen shot it and give more info?

 

You could also try using Local Variables.  See this for the differences between Local Variables and Notifiers.

 

The first VI I sent wasn't runable because I saved it for previous version and there was a feature missing (wiring error cluster directly to boolean functions).  I have attached the VI again without it which is runnable on my system.

 

Let me know how you get on.

 

 

Lewis Gear CLA
LabVIEW UAV

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

Another possiblility is to latch the complete value using a shift register or a feedback node. Once the output is complete, you don't need to do it again. I don't know if this is quite the way you want to do it, but here is a modified version of your VI that stops the DAQmx task when complete is true. It will not run teh stop case again until the program is restarted (you could build a change into the loop to re-run the task if you need to).

 

Rob

 

0 Kudos
Message 5 of 9
(3,398 Views)

Thank you for the replys!

 

Rob, could you maybe post the VI as Labview2009 Version? Thank you.

Here are two screenshots, the first one indicating what I want to connect, the second with the error when I actually do it.

 

Thanks again for the help

 

 

Download All
0 Kudos
Message 6 of 9
(3,385 Views)

Hey Jack,

 

There are broken arrows because while loop 1 will not run until while loop 2 finishes and while loop 2 will not run until while loop 1 finishes.  You have a circular dependency.

 

"LabVIEW follows a dataflow model for running VIs. A block diagram node executes when it receives all required inputs. When a node executes, it produces output data and passes the data to the next node in the dataflow path. The movement of data through the nodes determines the execution order of the VIs and functions on the block diagram."

 

http://www.ni.com/gettingstarted/labviewbasics/dataflow.htm

 

Why is the first bit of code inside a while loop? What is it doing?

Lewis Gear CLA
LabVIEW UAV

0 Kudos
Message 7 of 9
(3,376 Views)

I didn't realize from your example VI that you wanted to control the pulse generation in a separate VI. Notifier or queue to send infromation from one loop to the other would be the way I would code that.

 

Here is the VI, saved for LV2009.

 

Rob

0 Kudos
Message 8 of 9
(3,366 Views)

Robert, thanks for the VI, I think that solves the problem! I have to wait until tomorrow to actually test it with the stepper motor however.

 

Lewis, thanks for the hint! I am not sure which while loop you mean. If it is the one at the top left corner:

 

The whole program is to control a wind turbine model as well as the wind tunnel it is operated in. Also, it should measure certain data such as windspeed, power output.

With for example one configuration of wind speed,... values are measured for a certain time. After that, the windspeed of the windtunnel is increased the the next value. The while loop runs for a certain amount of time in order to wait for the windtunnel to adjust to the new speed before the measurement starts again. Maybe this is not the most elegant way to realize the "waiting", but it works 😉

0 Kudos
Message 9 of 9
(3,359 Views)