Draw a circle using 2 stepper motors

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
quazar
Posts: 11
Joined: Sun Jun 04, 2017 6:27 am
Has thanked: 11 times
Been thanked: 2 times
Contact:

Draw a circle using 2 stepper motors

Post by quazar »

Hello all,
Could someone, please, indicate on how to control 2 stepper motors synchronously to draw a circle.
I did check the "linear interpolation" in the forum, thank you, however, the curved lines would require more variables...
I would appreciate any Flowcode examples, or a link to an application note.
I am not planning to use a G-codes, just to use a radius variable to be entered on the display and a start button to execute the circular motion with predetermined ramping and feedrate.
Any help would be greately appreciated.
If anyone could indicate a link for a good book on the above subject (control phylosophy and math) that would be great!
Thank you very much!
Vasile.

mnf
Valued Contributor
Valued Contributor
Posts: 1071
Joined: Wed May 31, 2017 11:57 am
Has thanked: 65 times
Been thanked: 414 times
Contact:

Re: Draw a circle using 2 stepper motors

Post by mnf »

That's an interesting idea.
Of course the simplest way to draw a circle with two motors is to just use one of them :D
If you use two motors you will have to combine horizontal and vertical steps - using an algorithm such as https://www.google.com/url?sa=t&source= ... D_bW224dx1
Which is fairly easy to use - I used it for an LCD display..
So you have the option of drawing a horizontal line and then moving vertically to draw a filled circle or stepping around the outside of the circle?
Have a look at the etch a sketch mechanism for a way to control the pen.

Martin

quazar
Posts: 11
Joined: Sun Jun 04, 2017 6:27 am
Has thanked: 11 times
Been thanked: 2 times
Contact:

Re: Draw a circle using 2 stepper motors

Post by quazar »

Thank you for the link, Martin.
I did check the Bresenham algorithms, they do look promising. They are great for drawing on the displays but, there are some other issues when it comes to the mechanical implementation: acceleration/deceleration, linear speed when following a curve etc. I did also noticed that the "lookup" algorithm is used but could not find details about it.
Now, regarding the hardware and Flowcode.
I am planning to use my old 3 axis CNC machine as a test bed.
I would like to make a stand alone (usually called offline) 3 axis controller with a local display (HMI) to be able to select shapes and enter sizes and execute. So far I am looking for:
1. Circles (contour and mill)
2. Rounded rectangles (contour and mill).
My next question is on how to handle the micro controller outputs in real time. Looks like I will have to generate pulses simultaneously on at least 2 outputs and taking in consideration the ramp up/down dynamics and some compensation to have consistent linear speed when following an arc.
What would be the best approach, using interrupts, multi thread, etc.?
I am sure that something would be done before me, just cannot find the right material.
It would be great to find a programming example out there.
I do need to educate myself in this field first, but, unfortunately, I could not find yet any literature describing this multi axes stepper motors control philosophy specifically for microcontrollers. Lots of articles with general information, but nothing to use as a proven reference.
Any input would be greatly appreciated.
Thanks again.
Looking forward for more info.
Have a great day!
Vasile.

User avatar
Benj
Matrix Staff
Posts: 15195
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4761 times
Been thanked: 4296 times
Contact:

Re: Draw a circle using 2 stepper motors

Post by Benj »

Hello,

Some G code converters will simply use linear interpolation making the circle up of lots of individual straight lines.

However some more advanced G code converters will use circular interpolation. It's very similar to linear interpolation but uses SIN and COS with a radius and a central offset to provide a circular motion path. Its a lot more advanced but it certainly can be done.

https://www.cnc.com/circular-interpolation-cnc/

Post Reply