LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Repeatable different steps of a stepper motor

Hello everyone,

 

I am working on a project where i have a stepper motor moving a plate and a signal sensor who measures a distance. I managed to initialize the signal so my initial position is the position where the sensor gives me the minimum value (Voltage).Each time the stepper motor moves, i define it from the front panel. My question is, how can my stepper motor moves automatically for e.g. 8000steps then without define it again for another 5000 steps or whatever i want with a time delay. The definition of the steps now is being done from DAQmx Timing>Samples per channel. I want to run the program and the steps to be already defined wihtout change them again and again from the front panel. I attach my current VI.

 

Thank you in advance

 

 

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

Hi,

 

not directly an anser to your question, but here are a few suggestions to improve your program (that might finally end up solving your initial problem):

 

  • There is no dataflow between the different DAQmx Tasks. This means that they will be executed whenever LabVIEw gets around to it. If that's OK for you that's not a problem, but as your program grows it might be, so it's good practice to generate some order between the different actions.
  • Your are starting your Dev1/ai1 Task twice, which is unnecessary
  • Your loops are running, as far as I can see, without any timing. This is dangerous.
  • And finally: This does nothing, except mess up your data:

Dynamic.PNG

 

To repeat the same action multiple times qould require passing the same data you use for passing it the first time to the output at the right time. Which output do you use to control the stepper motor?



Remember Cunningham's Law
0 Kudos
Message 2 of 8
(3,567 Views)

Hi Peter Foerster

 

Thanks for your answer.

Firstly, as i am new to labview programming i have no experience how to set dataflow between the different DAQmx Tasks. For now, my code is working but i understand that it's good practice to generate some order between the different actions.

The second thing you said, i dont exactly understand where  i am starting my Dev1/ai1 Task twice.

The third thing, my loops are running without any timing because the need of my project is on defining the number of the steps (which are synchronized with the signal sensor <voltage> to take 1 measurement (voltage) per 1 step). But maybe you are right , its dangerous but i ve been told to do it this way.

Dynamic.PNG  

I thing you are right for this. i will change this.

Finally if i understand correctly, the output i use to control the stepper motor you mean the step signal output line which is the PFI output line.

So to repeat the same action multiple times, could you be a little more specific how this could be happen? 

i apologize if i am comfusing you, but as i already told you i am new to labview programming.

 

Thank you in advance

 

 

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

Hi Chris,

 

not a problem, we all were new at some point. In case you don't know there are boatloads of classes you can access online with your License or even without one:

Here's a small collection (courtesy of crossrulz):

3 Hour Introduction
6 Hour Introduction
LabVEW Basics
Self Paced training for students
Self Paced training beginner to advanced, SSP Required
LabVIEW Wiki on Training
Learning NI
Getting Started with NI Products

And if you are a student you can take a real class with NI for a ridiculously small amount of money (say, 93%) discount).

With start twice I mean that I was wrong in believing you did so, when I fact you started two different tasks, so: nevermind.

 

PFI stands for Programmable Function Input, which is confusing because it is probably assigned to an I/O line. I just asked to find out what section of your code I have to look at. I'm still not quite sure about this, butI understood you want to move the motor, when you push a button. The only part of your code, where you even read a button within a while loop is for the Direction Line. Apart from that you just write the inputs once and then forget about the tasks (not even stopping them sometimes). I suggest moving the button that should move the motor into a while loop. 



Remember Cunningham's Law
0 Kudos
Message 4 of 8
(3,547 Views)

Hi Peter Foerster

 

Thanks for your help and the information about the classes. I really appreciate that. I agree what you suggest but i think the way i have set up the current VI, it would be very difficult to create a while loop. Maybe you are right but if i create a while loop i believe that i have to change all the current VI. I set this up with this way and it seems very complex in order to synchronize {analog input-digital output} frequency taking as a result 1 voltage measurement( signal sensor) per 1 microstep (stepper motor). My VI was based on: http://www.ni.com/product-documentation/4322/en/ .

 

My last thought is to change the way i define the steps and stop defining from the DAQmx Timing>Samples per channel and to define them from a script like the VI i am attaching now. I think that if this works it would be more easier the motor to do repeatable steps from the script. There was no error but the motor never moved. Do you know if something like that (define steps through the script) could be work??

 

Thank you in advance

0 Kudos
Message 5 of 8
(3,531 Views)

I don't see this different from the VI you posted before expect for the feedback node which will only be useful if you execute the VI several times, which is bad design. You should avoid using the run continously button.

 

I don't think that it has to be as complicated as you describe it. Can you describe what signals your stepper motor needs to move?



Remember Cunningham's Law
0 Kudos
Message 6 of 8
(3,525 Views)

What i am trying to do in the second VI is to define the steps of the motor from the MATLAB script and not directly from the DAQmx Timing node (Samples per channel) as i did it before. I think that it would be easier to make the stepper motor moves for some steps then stops then moves again and so on...with MATLAB script. Of course i am not sure about that.

Because i didnt explain before, my stepper motor moves a plate in a circular movement and there is an optoswitch sensor in a place where it measures the distance from the plate. There are two specific positions that i want from my plate as it moves circular so from the sinusoidal signal from the sensor i know the steps of the min value (initial position) , the steps of the first position and the steps of the second position. I did it with analyzing the sinusoidal signal before.

 

Thanks again for your help. 

 

 

0 Kudos
Message 7 of 8
(3,497 Views)

My question is: What signal does your stepper need to be moving? Since it does not move, maybe we should start there.



Remember Cunningham's Law
0 Kudos
Message 8 of 8
(3,485 Views)