fast stepper motor driving

Go To Last Post
19 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm trying to figure out a good way to drive a stepper motor's step input fairly quickly (due to a large gearing ratio that has to be used). This is on a board with an atmega64 running at 16 MHz. I've tried two ways so far, both with timer/counter 1 in CTC mode. Using the "Toggle OCnA/OCnB/OCnC on Compare Match" option, I can get it to operate very quickly, up to a few MHz stepping frequency. But the problem is that I need to know how many steps have happened. To facilitate this, I added an interrupt on the CTC match to increment a volatile global integer, and performed the actual toggling of the bit during this interrupt. Unfortunately, this can only run up to around 150 kHz. The only other possibility that I can think of is not counting steps directly, but timing it with another counter to calculate steps from the frequency, but this kind of sucks. If the frequency changes during a timing cycle, or if something was reset oddly, it would become inaccurate. Any suggestions on getting a fast, countable frequency output? At the current motor settings and gearing ratio, there are 4915200 steps/revolution. At 150 kHz, it would take about 32 seconds to make a full revolution, which is a bit slower than I would like.

Edit: I just realized that this isn't necessarily AVR GCC related... I guess I posted this here out of pure habit. Not sure how to change its location now.

Edit: I guess a possible solution could be to decrease the stepper motor driver board's number of steps per revolution. It's currently set to 51200, which is multiplied by 96 by the gearing. If I set this to 25600 instead, 150 kHz means 16 seconds per revolution. I should only need so much resolution anyways. If I'm able to move about 0.01 degrees per step, I'll be good.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What about feeding back the pulse output to an another timer set for external clock?

JW

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

wek wrote:
What about feeding back the pulse output to an another timer set for external clock?

JW

Dang, that seems like a good plan. Thanks for the tip, that might do the trick.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi there, maybe you are looking for a solution to a problem you don't have. I know of no stepper motor that can step at the MHz rate. I also seem to remember that steppers loose torque at higher stepping rates up to the point they start skipping / loosing steps. What is the max step rate that your stepper will comply with? Answer this first.

Regards
Johan

Edit: Just read your edit above - If you are micro-stepping, the picture changes a bit. However, your physical stepper still have a finite max step rate, which will put a ceiling on your total step rate - even if you are micro-stepping. For most steppers the max step rate is probably in the low kHz?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I would uptimize a timer interrupt, and use a DDS
calc. for the speed. (keep timer interupt constant).
In ASM 100KHz+ interrupts is no problem.
So in that interrupt I will put the step counter,
that way it's easy to count both up and down, if you need the position.
Remember CLI, SEI round the code in the main that read to count.(or wait until there just have been a interrupt!).

If you can then don't use the gear. and use micro steps for precision, that way you can get high speed when you need to move quickly.

Jens

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

In ASM 100KHz+ interrupts is no problem.

OBHWGA ... :twisted:

(however, if the DDS is done 24-bit or 40-bit or 18-bit or like that, I'll give ASM the nod as C has no concept of say 24-bit arithmetic)

((Note that I posted my most time-critical ISR written entirely in C that runs less than 40 cycles including in/out of ISR overhead in a previous sparrow2 thread. I'm still waiting for the answers to my challenge questions.
https://www.avrfreaks.net/index.p...
40 cycles at 20MHz is 2us or 500kHz. Still over 100kHz at a more sedate AVR clock rate, and still all in C.))

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Lee :
You are in the wrong forum this is GCC

And this link you have is about ASM that you was
trying to hijack over to 8051, and C, so natualy no response from me in that thread.

Jens

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Johan: This project uses the MD2S microstepping motor driver, which can step up to 2 MHz.

I'll look into implementing a DDS, as well.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As I exepected, Jens--you like to make grand pronouncements and then when asked for backing information the airwaves go very silent.

"The Emperor has no clothes!"

And now we hear that

Quote:
You are in the wrong forum this is GCC

when all I did was directly comment on >>your<< post in this very forum. Tell me which forum I should use to respond to your comment?

And as with the right-wing radio personalities that are popular in some circles in the US, instead of a direct response all that is seen is unrelated attacks.

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

But can your motor step that fast ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

First I don't want to hijack this thread so this is the last non step motor related chact from me.
Lee

Quote:
and then when asked for backing information the airwaves go very silent

If you read before the question you would know that I don't have and 8051 tools any more, so of course I give no code.
But if you want some challenge try to make a ultoa for
CV (ltoa take more than 23000 clk!). And I will give you 20% for do it in C.(but as allways you can do it within 10% I guess).
In ASM less than 300clk with ajust less than 350clk
in worst case.

Lee if you want to continue please do it in the thread
you linked to (it's dead anyway)

Jens

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sparrow2 wrote:
But can your motor step that fast ?

I'm not entirely sure... we're using the MS23C motor, which is "performance matched" to this driver board, whatever that means.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A normal step motor can't go to fast, if you need speed
you will need to use a PM motor.
A step motor and PM motor is basicly the same but a stepmoter has point field, and a PM motor has SIN field
(like a AC motor) so it has constant torque.

Jens

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Lets make some assumptions and do some math. Lets say the physical max step rate for your stepper is 1K steps per second for the torque you need in your application. (There should be step rate / torque curve for your stepper available). Lets also assume that you can do an 8 bit micro-step - giving 256 micro-steps per physical step. Then, theoretically, you can do 1K*256 = 256000 steps per second maximum. In reality, I believe you lose some torque when micro-stepping - so the real practical figure is lower. That's why I do not belief you will be able to use your 2.5Meg step rate in practice.

Start with a lower step rate and get your hardware working first. A possible simple experiment is to drive whatever you are driving between two endpoints back and forth many times. Slowly increase the step rate and when you do not reach the endpoints any more you have started to loose steps. This will give you a feeling for the real-world parameters for your system. Remember that you must do the above under real-world maximum load on your system, otherwise the test is of no value.

Regards
Johan

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I googled for said motor and found
http://www.casa.co.nz/Motors/Ste...
Strangely this motor is not mentioned on the USDigital site itself...

Datasheet claims max. revs 3000rpm, which at 200 full steps per rev gives 10kstep/s capability; then the 256-microsteps per step require the said 2.56M pulses/s.

I am only quoting from the datasheet. Draw your own conclusions.

JW

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Good for taking the trouble to find the data sheet!

It confirms my suspicions.
Note that the torque of this stepper is stated as 110oz-in. Then look at the data sheet page 2 which gives the RPM/Step rate versus torque. It shows that torque peaks at 800RPM, then starts falling with only 40oz-in at 3000RPM, this is almost a third of the rated torque. 800RPM=2666steps/sec, with 256 microsteps this gives only 682K microsteps/s. I still think you don't get full torque when micro stepping, but my memory is a bit vague here. Also, this torque is only available when you are driving the stepper at the rated 48V/4Amps.

I still suggest doing some practical experiments to get an Idea of torque requirements - get the thing working before you refine the code capabilities to the max.

I am expecting to get rapped soon for this thread in the GCC forum :)

Johan

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The micro step if only at low speed, final possition.
At higer speed the motor will see normal steps.

Just to put real numbers into the pot.
I have used a 200 step motor that was rated for MAX 7500 step/s but over about 5K there was no real torque left.

Jens

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Johan Hartman wrote:
[...]then starts falling with only 40oz-in at 3000RPM, this is almost a third of the rated torque[...] Also, this torque is only available when you are driving the stepper at the rated 48V/4Amps.

I said, draw your conclusions.

Johan Hartman wrote:
I am expecting to get rapped soon for this thread in the GCC forum :)

Why?

I am relatively new here: are these folks religious straight-looking programmers, sorry, software engineers, who can't recognize the tight interconnection between microcontrollers and hardware (including electromechanics)?

I hope not.

JW

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Why?

I am relatively new here: are these folks religious straight-looking programmers, sorry, software engineers, who can't recognize the tight interconnection between microcontrollers and hardware (including electromechanics)?


Nope but they are simply software engineers who can read:

https://www.avrfreaks.net/index.p...

As that suggest this thread IS off-topic for this particular forum though, admittedly, bobasaurus recognised in the first edit of his first post. Those guidelines clearly state the purpose of this forum:

Quote:
- The AVR GCC compiler,
- Code compiled by the AVR GCC compiler,
- Any of the related Open Source AVR tools (such as: avrdude, uisp, GDB, AVaRICE, SimulAVR, MFile, etc.)