circular interpolation

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

I'm building a CNC, I want to know if you have any good Idea about circular interpolation?

I love Digital
and you who involved in it!

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

More info? You mean how to draw a circle given a center and radius? Or a number of line segments along the circumference?

Imagecraft compiler user

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

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"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

I wanted to implement the G02 and G03 parts of the G-code,

Basically I have the start and the stop and center points of an arc, and I need to send pulses to the X Y Z steppers,

http://en.wikipedia.org/wiki/G-code

I love Digital
and you who involved in it!

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

There is some open source code on the web that does this.

What did I find:
http://en.wikipedia.org/wiki/Lin...

You can always use Mach3 like most of us to do cnc.

http://www.contraptor.org/grbl-g...

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

I have build my own costume hardware, and software, I do not want to use Mach3 ,etc... I want to do it myself!

I love Digital
and you who involved in it!

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

Google "Bresenham circle".

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"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

Quote:
Google "Bresenham circle".

Thanks, Do you think that algorithm do not pix elate my machined Part? what is it's accuracy?

I love Digital
and you who involved in it!

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

Ali, look at the links I provided. You'll find some real code.

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

Quote:
Ali, look at the links I provided. You'll find some real code.

Thanks for the links, Would you direct me to the right piece of code in LinuxCNC, I think it's very huge code and I think I should spent months to understand it, Please turn the lights on for me!

I love Digital
and you who involved in it!

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

What makes you think i know anything about it? I just googled it. Besides, you'd think the code would be modular so it wouldn't be too hard to zero in on the parts of interest. So don't be lazy.

The grbl interpreter might be more your speed as it runs on an avr.

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

I'm not lazy,I just have the imagination that Linux means lot's of reading... So some Linux expert freaks might come handy?

I love Digital
and you who involved in it!

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

Quote:
Do you think that algorithm do not pix elate my machined Part?

How much have you read about it? E.g. you can not simply take what is here, because it draws a circle by drawing 8 different arcs - each "step" draws one pixel in eah arc. That would make your lathe head move forth and back in a ridiculous pattern. I hinted about "Bresenham" as a starting point - you said you wanted to do it yourself :wink:.

What kind of computing power do you have at your disposal? Could you get off with just using the ordinary "equations of the circle"? Do you have trigonometry functions available? Do you have floating point capabilities within this project?

[EDIT: Added quote so that it is clear what my comment is in response to. High traffic in this thread right now...]

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"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]

Last Edited: Wed. Jun 19, 2013 - 03:01 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

I just have the imagination that Linux means lot's of reading...

You know the procedure/attitude/expectation, Ali. You take a look first - if you get stuck you go for help. Defaulting to "perhaps it's complicated, so I'll just ask right away" does not ++ your karma.

And you said you want to do it yourself! :D

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"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

Quote:

,I just have the imagination that Linux means lot's of reading...

It's not specific to Linux. Anything that is complex will take a lot of explaining and hence reading. If one wants to know about a complex subject then I don't see how getting someone else to read out a short summary to you helps in any way? If you want to learn you have to be prepared to read and that means read ALL the details, there's no magic way to avoid that.

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

"Seems like" you could cut a circle using "turtle graphics". Moveto x,y Set heading 0 deg. Cut to x+dx, y+dy. Set heading 45 deg. Cut to etc etc. Repeat for ea line segment.

Imagecraft compiler user

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

bobgardner wrote:
"Seems like" you could cut a circle using "turtle graphics". Moveto x,y Set heading 0 deg. Cut to x+dx, y+dy. Set heading 45 deg. Cut to etc etc. Repeat for ea line segment.

I'm thinking that you will need to use trig and run a series of computations, each at the fraction of a degree, according to the resolution you require.

After each iteration of calculating the current fraction of a degree (the next new position), you convert the results from polar coordinates to Cartesian or rectangular coordinates (from angular or degree notation to X, Y coordinate notation), which then becomes the tool trajectory for the next line of G-code.

The result will be a sequence of G-code instruction lines that will cause the cutting tool to start at the beginning point, rounding the circle until it reaches the endpoint, which will be a few steps past the beginning point of cutting tool, so as to take into account of the tool diameter, leaving no rough spot where the transition from beginning to end of travel takes place.

Now that was a mouth full!!! :roll:

You can avoid reality, for a while.  But you can't avoid the consequences of reality! - C.W. Livingston

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

Quote:
Do you think that algorithm do not pix elate my machined Part?

Tell me again how a CNC machine with X and Y stepper motors isn't already pixelated.

When the radius is small compared to the pixel size every algorithm's output, when mapped to (X,Y) coordinates, is going to appear pixelated.

Read up on Bresenham's algorithm, as already mentioned above.

JC

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

I use LinuxCNC on a daily basis to control a machine I had built... just use LinuxCNC as is.

On the other hand You can get source files ( C files) from the repository and analyse the code.

Your other option is to look into Arduino community as a variant of G code interpreter was developed for Arduino.

It might give You a few clues.

But seriously why reinvent the wheel?

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

DocJC wrote:
Quote:
Do you think that algorithm do not pix elate my machined Part?

Tell me again how a CNC machine with X and Y stepper motors isn't already pixelated.

When the radius is small compared to the pixel size every algorithm's output, when mapped to (X,Y) coordinates, is going to appear pixelated.

Read up on Bresenham's algorithm, as already mentioned above.

JC

But then too, Doc, if the stepper motor is a 1.8 degree per step motor or 200 steps per revolution and, the lead is, say, 20 turns per inch, that is 4,000 steps per inch.

That translates to 1/4 of one thousanths of an inch per step. For all but the most detailed of machining, the pixelation, as the OP is calling it, will be un-noticable. In fact, the tool chafe will be far more distinctive, I'd think.

Really, the greater issue will be back-lash in the lead-screw and ball-nut or what ever is being used. The back-lash will cause distortion in the circular motion which, may well be far more important than any stepper pixelation. However, Mach3, as well as most other decent software packages will allow for back-lash comepnsation.

If stepper motor pixelation is really that big of an issue, then an actual servo system should be used. But remember, there will still be finite positioning updates in the motion direction, which, when is all said and done, if the updates are too far apart, could have the same effect as stepper motor pixelation.

You can avoid reality, for a while.  But you can't avoid the consequences of reality! - C.W. Livingston

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

Well, Bresenham will give you as close an approximation to a circle as your costume hardware can do. There are also Bresenham schemes for lines and the like.

"Costume hardware" Great typo!

The largest known prime number: 282589933-1

It's easy to stop breaking the 10th commandment! Break the 8th instead. 

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

Torby be nice.. anyway what's costume in Farsi?

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

According to Madam Google:

لباس

They call it "Persian" rather than Farsi.

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

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

Kartman wrote:
You can always use Mach3 like most of us to do cnc.
Kartman, I'm curious, what you have in the way of CNC. (I spent the evening modifying/customizing my custom MACH3 screenset :wink: )

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away. Antoine de Saint-Exupery (1900 - 1944)

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

Quote:
I'm thinking that you will need to use trig and run a series of computations, each at the fraction of a degree, according to the resolution you require.

After each iteration of calculating the current fraction of a degree (the next new position), you convert the results from polar coordinates to Cartesian or rectangular coordinates (from angular or degree notation to X, Y coordinate notation), which then becomes the tool trajectory for the next line of G-code.

The result will be a sequence of G-code instruction lines that will cause the cutting tool to start at the beginning point, rounding the circle until it reaches the endpoint, which will be a few steps past the beginning point of cutting tool, so as to take into account of the tool diameter, leaving no rough spot where the transition from beginning to end of travel takes place.

Now that was a mouth full!!!


It seems that you have done the job before, I did not fully understand your points,Would you explain it more to me,
Also I want you to know that I'm using 2500 pulses servo's for Axis and 5mm ball screws, And I'm using a 100MHz cortex M3, So I think I have enough computational power, I have written a function which will accept X,Y,Z and Feed rate, and will move the servo's with Linear motion on 3 axes,
So can I break the arc to simple lines and use my Move function? what's you Idea? and How should I implement it?

I love Digital
and you who involved in it!

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

Ali_dehbidi wrote:
It seems that you have done the job before,
If he has, he did it in a very inefficient way! I have done a very simple version of this many years ago....

As has been mentioned several times already, the word is BRESENHAM! If you are going to reinvent the wheel, stop avoiding the solution! You have been told many times where to find the answer.

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away. Antoine de Saint-Exupery (1900 - 1944)

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

Ali, seems you need to be lead to the solution:
https://github.com/grbl/grbl
There's no linux involved so don't be scared.

Personally i'd be looking at the linux cnc code as it is probably the most developed codebase for cnc. Thereis probably one page of code that does the math that you want.

Cris, i have a RF30 mill/drill i added stepper motors onto. One day i'll add ballscrews to it so i don't have to keep on adjusting the backlash. Other toys I've got are a ac/dc tig and small lathe. I normally work on two stroke motorcycle engines.

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

how big numbers are we talking about?
Are you using FP for the calcluations?
if computer power is a problem I would go for a sinewave (and calc cosine aswell), OSC, calc the start point in FP, and do the step to step in integer

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

Ali_dehbidi wrote:
It seems that you have done the job before.

To some extent, yes.

Ali_dehbidi wrote:
I did not fully understand your points. Would you explain it more to me.

That would be hard because, if you don't understand the difference between the polar and rectangular co-ordinance systems, it will take more space here and time than I have.

If you don't have a good background in algebra and trigonometry, it would be very difficult to explaine beyond what I already have. That, and to be honest, it's been twenty years since I given these concepts any real thought.

aeroHAWK wrote:
If he has, he did it in a very inefficient way!

I wasn't trying to be efficient, I was attempting to sketch an outline of the most basic properties needed. My first approach is always to take the fundamental or straight forward approach. Then, once understanding of the most direct method is understood, I begin to look at better methods.

My thought on the matter was this... while you can solve many simple math problems with a calculator, not understanding basic addition, subtraction, multiplication and division becomes secondary for those not mathematically inclined.

But if you are going to design algorithms, write the code and embed that code into a microcontroller in which the combined effort results in a functioning 4-banger calculator, you'd better understand the longhand methods of the functions to be incorporated. The shortcuts can be discovered and implemented at a later time.

The same is true here. The OP says he wants to learn Circular interpolation. The learning curve must then incorporate a starting point, that being the basic fundamentals. The fancier and more efficient methods can be built on to the foundation acquired from the basics.

While it is sufficient to cut and paste building blocks, so as to piece together a complete system, there will likely not be any real understanding to be had about circular interpolation.

Prematurely jumping on the "Quick & Dirty" or "Most Efficient" bandwagon, while possibly rendering something approaching a working system, will not provide solid foundation and understanding of the concepts. ...and at what frustration level?

I don't know, maybe I've simply misinterpreted what the OP actually wants to accomplish by undertaking this endeavor.

You can avoid reality, for a while.  But you can't avoid the consequences of reality! - C.W. Livingston

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

Quote:
That would be hard because, if you don't understand the difference between the polar and rectangular co-ordinance systems, it will take more space here and time than I have.

If you don't have a good background in algebra and trigonometry, it would be very difficult to explaine beyond what I already have. That, and to be honest, it's been twenty years since I given these concepts any real thought.


Of course I understand polar and rectangular co-ordinance systems and algebra and trigonometry,But I did not fully understand your last method, would you explain it more?

I love Digital
and you who involved in it!

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

Quote:

Tell me again how a CNC machine with X and Y stepper motors isn't already pixelated.

When the radius is small compared to the pixel size every algorithm's output, when mapped to (X,Y) coordinates, is going to appear pixelated.


Back when I was your age, I worked for a major machine-tool manufacturer, in the electronic/controls area.

There were two or three people in the CNC development area that did nothing but the "move" functions. Full time. For years.

Now, how can one possibly expect to tell someone how to do it in a forum thread? And no relying on prior work...

Anyway, I can chime in on the "pixelated". Are you getting satisfactory results with X+Y movements linear? At all angles? If so, then you should be able to begin to work on circular.

You need to be able to accelerate both axes at the correct ratio and then drive them in proportion until close to the endpoint, then decelerate at the correct ratio to the endpoint and stop.

So much depends on the mechanical systems--inertia and power needed and such. Much depends on how fast the control loop can be closed, new values applied, and the response lag of the new values.

If you are satisfied with the linear performance, then you can move on to other profiles--circular or whatever. The cycle is the same as linear--except that the ratios are constantly changing, instead of being fixed.

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

microcarl wrote:
I was attempting to sketch an outline of the most basic properties needed.
My apologies Carl. My understanding of the OP's question seems to be different than yours. :wink: It appeared that your description was of approximating a circle using a polygon programmed in g code using linear moves. My understanding of the OP's question is that he wants to know how to translate circular g code (G02 G03) into steps.

Also, in my mind, the fundamentals do not involve trigonometry, but rather geometry and algebra - using the equation of a circle (which is essentially the source of trig, also). :wink: It is much less complicated and fits into learning Bresenham algorithms more directly.

Cris

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away. Antoine de Saint-Exupery (1900 - 1944)

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

aeroHAWK wrote:
My apologies Carl. My understanding of the OP's question seems to be different than yours. :wink:

Cris

No apology needed. We all approach problems and solutions from points of view derived from personal experience and educational background.

Lee is correct, though, bringing angular velocity of the cutting tool, as well as acceleration/deceleration only compounds an already complicated subject.

There is another aspect to consider, as well. For a strictly digital command system, there are rounding errors to consider. So, consider that the rounding of each new position calculation causes the LSB to clear. And then, in the next calculation, the LSB is set. But what happens when a series of calculations all happen to round in the same direction? And then on top of that, where does back-lash compensation enter into the process.

I ask this because a common form of back-lash compensation is to always move into final position from the same direction. With the kinds of movement taking place with circular interpolation, how do you accurately perform back-lash compensation.

And then for an analog driven system, will full scale linearity cause too great of an error. That, only compounded by LSB rounding in the digital side of the system.

Here's the deal... Having worked on Milicron, Mazak, Brown & sharp, Pratt & Whitney, Kerny & Treker and a dozen other machine tool controls for many years, there is one thing clearly common with all, that is - the almighty specification.

I think that there is much learning (read, disclosure) as to the scope and accuracy of the OPs design that needs to be realized.

Maybe a person should ask, what are the capabilities of the physical mechanics of this machine. After all, no mater how accurate you make the control, it can never exceed the mechanical properties of the system.

A three axis machine has about 30 places where accuracy can and will be hampered. Just because you have a ball/lead system that is linear to 1/100 of one thousandths of an inch/millimeter and a back-lash of 1/2 of one thousandths of an inch/millimeter, that doesn't begin to take into account the many other places where accuracy can and will be lost.

It's not only about lead screw, digital precision and computational resolution you have to worry about. It's also about the accuracy and tolerances of the machine in places like "Way" slop and how square each axis is throughout it's travel and to each other. And what about how square the spindle is to the existing planes of motion, as well as spindle bearing play?

I think that these are only some of the things Lee was referring to when he mentioned there being a full-time staff where he worked, working to solve the complexities of these type problems.

My point is exactly this... if you don't know the machines mechanical capabilities and tolerances, the most accurate positioning algorithms simply won't live up to expectations.

You can avoid reality, for a while.  But you can't avoid the consequences of reality! - C.W. Livingston

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

Quickdraw for the Macintosh toolbox was highly optimized. It is said that Bill Atkinson independently discovered the midpoint circle algorithm. Source code (Motorola 68K assembly language, nicely commented) is available at http://www.computerhistory.org/a...

Edit to add interesting anecdote from that link:

Quote:
When the Lisa team was pushing to finalize their software in 1982, project managers started requiring programmers to submit weekly forms reporting on the number of lines of code they had written. Bill Atkinson thought that was silly. For the week in which he had rewritten QuickDraw’s region calculation routines to be six times faster and 2000 lines shorter, he put “-2000″ on the form. After a few more weeks the managers stopped asking him to fill out the form, and he gladly complied.