LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calculate the number of steps for a step-step motor before finishing the original routine, Labview and Arduino

Hello Everybody,

it is the first i write into the forum, and I feel emotioned about it 😄 

I am building a small rig to move back and forward a bar using a gear and a step motor. I use Arduino to controll the stepper motor, 200 steps/rotation 1.8° per step.

At the end of each stroke I have one proxymity sensor that stops the motor and inverts it for undefined numbers of steps

and it works fine, but I need also to stop the motor half way through the routine at certain numbers of steps that are a % of the total stroke, but i am struggling to calculate the full stroke to half it for the purpose.

I attach the VI, i am also thinking to fit an encoder, with the stepper motor resolution above, which one you may recommend?

Thanks,

Marco

0 Kudos
Message 1 of 14
(4,683 Views)

Sorry, I don't have your hardware or the missing subVIs, but I would recommend to remove all that duplicate code and unneeded sequence structures. I am sure it would be sufficient to have one loop, some state variable and one single place to do the serial setup.

0 Kudos
Message 2 of 14
(4,678 Views)

Hello Altenbach,

thanks for the quick reply, i am aware that the code for the moment is not efficient, and I will spend time to make it leaner.

However, I am still stuck with the question.

How do i calculate the total steps between the two endstops when the routine is halted by the proximity sensor?

Thanks,

Marco

0 Kudos
Message 3 of 14
(4,652 Views)

About the hardware, I use LYNX with Arduino for the PWM signal

0 Kudos
Message 4 of 14
(4,651 Views)

Can't you wire the iteration terminal of the first loop out to see how many times it iterated and derive the number of steps from that.

0 Kudos
Message 5 of 14
(4,647 Views)

i don't think so, because i send a signal with a standard number of cycles, and the loop will repeat it indefinetely until the sensor stops it overriding the last set of standand number of cycles.

this is the problem, because I stop the cycle in the middle of it due to the sensor's intervention.

0 Kudos
Message 6 of 14
(4,642 Views)

Why not...

  1. Starting from zero
  2. Advance the stepper keeping track of the number of steps until you reach the stop (full extension)
  3. Divide the number of steps it took to reach the stop by 2 

 

Won't that give you the number of steps it takes to get half way?

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 7 of 14
(4,634 Views)

probably it's me that is not clear enough.

let make an example with some numbers

i move the motor to the zero position defined by the sensor that change from high to low telling the VI " hello, i am the end stop, please stop, invert the sense of rotation"

from this position i ask the motor to run 200 steps (1 turn) in the opposite way and it does it checking continuously if the other end sensor is activated.

after these 200 steps with no intervention of the sensor, the VI asks to the motor another 200 steps to be completed as above but this time half way through the sensor activated and the cycle stops.

 

in the VI i just set the number of steps and the direction, i don't ask to run a single step each time, and this is the problem.

i don't know how many steps have been done until the sensor is activated

i was thinking to read the digital output of the PWM to count those steps until pulses stop.

0 Kudos
Message 8 of 14
(4,567 Views)

Hi Marckus,

 


@Marckus wrote:

in the VI i just set the number of steps and the direction, i don't ask to run a single step each time, and this is the problem.

i don't know how many steps have been done until the sensor is activated


Is there a need to ask for 200 steps each time?

Why don't you ask for small amount of steps?

 

Suggestion:

Ask for 200 steps, then just 1 step until the end position is found. Now you know how many steps there are between both limit switches…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 14
(4,562 Views)
@Marckus wrote:

 

in the VI i just set the number of steps and the direction, i don't ask to run a single step each time, and this is the problem.

 


You are right, this IS the problem.

 

Why ask the motor to make 200 steps at a time?

 

Why not one step at a time until you figure out how many steps it takes to reach the stop? 

 

Then calculate the half way point.

 

Now you can send the stepper the number of steps to go full stroke or half stroke.

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 10 of 14
(4,556 Views)