[TUT] [C] Stepper motors - real time dynamic ramping

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

I came across a nice article about dynamic ramping with some PIC example code, and got to playing with it. One thing led to another, and here is a restatement of the paper's premise and a port to an ATmega16.

Basically the physics and geometry of the motor system is reduced to two integers, one for acceleration/deceleration and the other for maximum speed. The move function does the rest. It generates constant acceleration and deceleration, imposing the maximum speed if necessary, all in the requested number of steps.

Special thanks to those who helped smooth out the rough draft - pradheep, Smiley, and Randy (rstahlhu).

The code is in ImageCraft C (don't forget that free 45 day demo version before you sneer), but Smiley has threatened to port it to IVC (Infinite Value Compiler) when he gets a chance.

The original document had a small error in Table 1. The corrected version has an additional column (labeled "Hex").

Attachment(s): 

Chuck Baird

"I wish I were dumber so I could be more certain about my opinions. It looks fun." -- Scott Adams

http://www.cbaird.org

Last Edited: Mon. May 11, 2009 - 06:56 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Mighty fine document, should be in pdf form and not word.

REgards,

Alan To

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

toalan wrote:
Mighty fine document, should be in pdf form and not word.

Great idea, Alan. If someone can convert if for me and send me the pdf, I'll add it to the zip file.

Chuck Baird

"I wish I were dumber so I could be more certain about my opinions. It looks fun." -- Scott Adams

http://www.cbaird.org

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

Chuck,

Here's the PDF - if you don't already have "Cute PDF" then Google it and install it - as you can see it does a great job of creating .PDF files.

Cliff

EDIT: out of date PDF removed.

Last Edited: Sun. May 10, 2009 - 07:14 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Listing 2: The Big Enchilada
...minus circuit diagram. As we all know diagrams are VERY bad for your health and therefore not included in this tutorial ...BUT... everyone knows how to wire them up, therefore superflous.

And if if don't like it ask for you money back and it will be cheerfully :evil: refunded.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

Chuck!

I saw the original paper by D Austin, and printed it out immediately. I will finish the motor drive for my astronomical telescope any decade now, and this ten-year-ongoing project is highly stepper motor oriented. Anything stepper, and I'm your huckleberry! I fount the subject matter of the original paper extra interesting as this is exactly what I need for fast moves (slewing) over the sky. This adoption of yours seems to be a mighty fine work, although I have only browsed parts of it so far. I thank you for this work!

I hope I get the time this summer to play with this, and make it work for microstepping.

Happy 75th anniversary to one of the best movies ever made! Rick Blane [Bogart]: "Of all the gin joints, in all the towns, in all the world, she walks into mine."

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

There is a small error in Table 1, in that I got the stepping sequence wrong. It is correct in the code; I just typed it into the table and a Gray Code jumped in the place of the (similar) stepper sequence. Thanks to eagle eyed Bob for catching this.

I've corrected it, made a pdf (thanks, Cliff, for the suggestion and the [now incorrect] pdf) and updated the files. Sorry for any trouble.

Chuck Baird

"I wish I were dumber so I could be more certain about my opinions. It looks fun." -- Scott Adams

http://www.cbaird.org

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

Quote:
ask for you money back and it will be cheerfully refunded.

OK, for you I'll double your money back. Nobody else, though.

The I/O bits are specified in the comments. In this particular case I used an ere controller - the BD298 (Bob finally convinced me to order from them). It connects directly to PORTA as noted.

The motor's two coils go to the two pairs of coil outputs on the board. Which way you get the wires oriented determines which rotation is positive and which is negative.

It's the Mona Lisa of schematics. As such I have to protect it from unkind eyes.

And how do I rate ere? Fast, cheap, slightly terse documentation, and my first buy (this controller board) had a bad IC on it. Fortunately it was an inverter on the input lines, so a little brute force removal and soldered in jumpers and all was well. I'd buy from them again since Bob seems so happy.

Chuck Baird

"I wish I were dumber so I could be more certain about my opinions. It looks fun." -- Scott Adams

http://www.cbaird.org

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

@Johan

in case you're interested...

re microstepping with the AVR
Lady Ada has code in "Arduinese" here
http://www.ladyada.net/make/mshield/use.html

...and this guy has released the asm code for his microstepper board
http://avrstmd.com/

Randy

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

When it comes to motors I'm a TIP and just showing my TIPpiness. :oops:

I did play with a 6 wire type and OC outputs a few years back but obviously this will not work with the same hardware and I will have to invest some money in new hardware. This may stop me from driving my Ferrari or even my private jet for a while, so it may have to wait.

(TIP=Totally Ignorant Person..or any other word one may want to substitute for the P. :? )

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

The original code that went with the D Austin article seems to have disappeared off the face of the 'net but, with the original authors permission, here it is.

Original filename "motor.c" or "01austin.zip".

Attachment(s): 

'This forum helps those who help themselves.'

 

pragmatic  adjective dealing with things sensibly and realistically in a way that is based on practical rather than theoretical consideration.