LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Steppermotor count steps and speed controll

Hey Guys,

i have two problems. I use MyRio,  Stepper motor (42BYGHW811) and a TB6600 Stepper Motor Driver

 

  1.  I'm trying to count the steps with a timer by counting my steps/sec ( PWM frequency) with the running time of the engine. multiply, but it's inaccurate. How do I get my steps directly from my motor
  2. I want my stepper motor to have this speed profile. If you manually accelerate quickly, this motor will stall. The profile simulates my press as it has the same speed profile                                                   

Stepper example.png

Best grades

Akbaba

 

0 Kudos
Message 1 of 6
(2,117 Views)

Long ago, I worked with steppers quite a bit.

 

I'll assume that you're doing position control so you'll want an exact # of steps in your motion profile, right?  Well, that can be a little tricky to get exactly right.  The theoretical math for the time it takes to get from low freq to high freq at a specific accel rate won't match up exactly with what you *actually* end up doing with an integer # of steps.  The quantization error can be fairly significant at higher accel rates -- I recall using a commercial stepper controller that had implementation flaws such that it reached the target # of total steps after just barely starting down the decel ramp.  It would immediately stop issuing step pulses, but the motor's speed & momentum were such that it coasted well beyond the intended stopping position.

 

I think you'll find that trying to do all the calcs on the fly will leave you more vulnerable to these things.  (But on the other hand, if you're *generating* the step pulses, your first question about counting them becomes trivial.)

 

A few tips:

1. You *can* work your way up the accel ramp by doing calcs on the fly.  Just be prepared to store all the interval timing information so you can use it in reverse for the decel ramp.

2. Remember that your starting frequency isn't defined until you've issued the 2nd step.  It takes 2 steps to define the very first frequency, each frequency thereafter requires only one more step.

3. So, for a given # of frequencies in your accel and decel ramps, accel will use up 1 more step than decel.

4. All remaining steps can be issued at your constant high speed.

5. Actual motion time may not match up with simple trapezoidal calculations, particularly the accel / decel portions.

6. When moving short distances, you may not make it all the way up the accel ramp before it's time to transition to decel.  This is one of the gotchas to watch out for.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 2 of 6
(2,091 Views)

Thanks Kevin,

the problem is, i have no idea how to do such a ramp. 

i use the stepper motor for a linear drive, The function of it, is to drive back an forth with this trapezoidal speed. that's the most significant function that i need.

 

 

For the positioning i use now an encoder, so i gone try with that

 

-Akbaba

0 Kudos
Message 3 of 6
(2,073 Views)

What are the specific motion requirements?

(Note: these are not all independent of one another.  Choices for some will constrain others)

- Total # steps

- Starting step rate

- Top speed step rate

- Desired motion time

- Allowed acceleration rate (the slope of the accel/decel ramps)

 

And then, how about more details about your system?

- what size / kind of stepper?  A hybrid with 1.8 deg steps?  Do you know the NEMA size?

- what kind of load are you driving with it?

 

Here's a start on the math:

A = acceleration (steps/sec^2)

F = next freq in accel ramp (steps/sec)

Fp = prev freq = 1/previous interval

dt = next time interval

 

A = (F - Fp) / dt

dt*A = (F - Fp), but note that dt = 1/F, so

A/F = (F-Fp)

F^2 - Fp*F - A = 0

 

Now you have a quadratic formula to solve and you get:

F = (Fp + sqrt(Fp^2 + 4*A)) / 2

 

So your next interval dt is just 1/F, and that tells you when the next ramp step should be issued.  When you calculate a value higher than your top speed, ignore it, your ramp is done, then just use the interval associated with the top speed  until it's time to decel.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 4 of 6
(2,065 Views)

I've worked with stepper motors that require a specific acceleration and positioning. We've used the a NEMA 17 stepper motor with a uStepper S controller. This little board can run Arduino code and has a quite intuitive library ready to use. You can simply specify the acceleration and velocity. It does require some microcontroller programming though.

0 Kudos
Message 5 of 6
(2,025 Views)

I Use myrio for my system. i cann controll also my stepmotor

. But not whit the funktion of the speed

 

0 Kudos
Message 6 of 6
(1,993 Views)