element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
element14's The Ben Heck Show
  • Challenges & Projects
  • element14 presents
  • element14's The Ben Heck Show
  • More
  • Cancel
element14's The Ben Heck Show
Forum Coordinated Stepper Motor motion factoring Aceel/Decel for arduino
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join element14's The Ben Heck Show to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 5 replies
  • Subscribers 32 subscribers
  • Views 976 views
  • Users 0 members are here
Related

Coordinated Stepper Motor motion factoring Aceel/Decel for arduino

timryder
timryder over 12 years ago

Ok so I'm creating a machine for myself and its going to be like an X,Y CNC with a possible A axis rotary.

What I want to do with it is write the code from scratch to so it's lean and fast. I might not be able to achieve this but it's going to serve as both a learning tool and a functional product for me to use.

 

I've been doing some experimenting controlling stepper motors with an Arduino Mega 2560 and I've had some success with an Arduino Library called "AccelStepper".  This is a pretty handy library which allows me to control multiple steppers and many types of drivers or direct. What it lacks however and is the most important is a canned function  which would allow me to coordinate motion of multiple axis factoring in their Accel and Decel profiles. If you haven't dealt with this at all it's a huge pain in the but because stepper motors unlike a dc brush less motor are digital, that is they can't take an analog motion profile.  Given their digital nature the standard trapezoid model of accel/decel won't work as each step of the stepper motor will/may be greater than the distance over time desired to match the rise/run profile of the accel/decel.  So what I usually end up with is the axis with the shorter move finishes it's motion faster than the longer motion axis.

 

Does anyone out there have any experience solving this dilemma?  I've tried some simple equations all of which would work for an analog device but I'm not gaining any ground on this battle at the moment.

 

If anyone needs more information I can do a video or some sort of diagram.


Thanks!

  • Sign in to reply
  • Cancel
  • Former Member
    0 Former Member over 12 years ago

    If you are using arduino, then is shouldn´t be a problem.Try to write some examples first, to drive steppers, then try to write all logic that it needs to preform tasks.

    At the end, combine all those into one .ino file. Write a function for all axis and then try to combine all together. image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • ckraft
    0 ckraft over 12 years ago

    Wish I could help but If I need lean/decent stepper control on an Arduino I usually use grbl (Bengler: GRBL) which is very nice and very lean, even runs on a standard Arduino.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • timryder
    0 timryder over 12 years ago in reply to ckraft

    Chris!

     

    You nailed it with GRBL, I took sections from it's AVR_C and made my own using it as inspiration. Very cool program.

    Now when you write a program with AVR_C and compile it, does it run faster than using one written through the Arduino IDE?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • ckraft
    0 ckraft over 12 years ago in reply to timryder

    If you write the C-code yourself it has the potential to be faster than the Arduino code but it is not a guarantee. Ultimately the Arduino code at some point ends up compiled code so there is not an obvious difference in performance. Plus odds are that you and the Arduino code are compiling in/linking the same libraries from Atmel/AVR so there won't be much difference there.

     

    That said when you write the code yourself you have the ability for tighter control over what code is there and how it is structured. So if the Arduino tool is doing something stupid for the sake of consistency between platforms you can make your code more efficient.

     

    It is a great exercise to learn more about the platform. That's why I encourage people using the Arduino tool to dig under the surface and take a look at the code it generates to better understand what is going on.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • pfrantz
    0 pfrantz over 11 years ago

    The trick is to use the same method that is used by the bresenham line drawing algorithm.  Look it up on the web.  Consider using an add statement instead of the x2 multiply that you will generally find to boost motor max slew speed.  You will write 8 different subroutines per the algorithm (2 per quadrant).  This method will ensure that both motors start and stop at the correct locations at the same time.  The motors will track each other within about one step of error and you can do any angle.  Write your code to pace the entire algorithm at your desired accel, decel and slew rate.  The motor with the longest travel will be limited by this speed.  The motor with the shortest (or equal) travel distance will run at the same speed or slower.  I did this years ago and it worked fine.  Max motor slew speed is a bit slow due to the calculations involved but they are all integer math and compares.  No floating point required. 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube