# Thread: Algorithm for G02 / G03 coding

1. Originally Posted by teenrocketnerd
Could someone post the "formula" for cutting circles or circular interpolations. Just What to put in, where it all goes, and what it means. I need to cut circles and arcs.

http://technology.calumet.purdue.edu.../lecture13.pdf

2. James
Did you get what you needed.
I'm working on a program which may be of some help.
Checkout what has been done and advise (errors, improvements, future additions) if you are interested.

3. Thank you!

I do have the routines under control now. My big problem was a basic misunderstanding of degrees versus radians.

-James

4. Originally Posted by teenrocketnerd
Could someone post the "formula" for cutting circles or circular interpolations. Just What to put in, where it all goes, and what it means. I need to cut circles and arcs.
The circular interpolation commands are G02 for clockwise and G03 for counterclockwise tool travel. The commands below work on a Haas, there may be machine related differences.

G91 G03 R1. X0.5 Y0.5 Fffff is the incremental command which tells the machine to cut an arc with a radius of 1.0" from where it is to the point that is 0.5" away on both the X and Y axes. The arc path to be followed is the shortest route, i.e. the arc subtends less than 180 degrees

G91 G03 R-1. X0.5 Y0.5 Fffff is the same command but the arc path to be followed is the longest route, i.e. the arc subtends greater than 180 degrees.

G90 G03 R1. X0.5 Y0.5 Fffff is the absolute command which tells the machine to cut an arc with a radius of 1.0" from where it is to the point that is located at 0.5" on both the X and Y axes using the current Work Coordinate system. The arc path to be followed is the shortest route, i.e. the arc subtends less than 180 degrees.

G90 G03 R-1. X0.5 Y0.5 Fffff is the same command but the arc path to be followed is the longest route, i.e. the arc subtends greater than 180 degrees

G03 I0. J-0.5 tells the machine to do a full counterclockwise circle around a center that is zero distance away along the X axis and 0.5" away in the negative direction on the Y axis. It does not matter whether the command is G91 or G90 this command still generates a full circle.

It is possible to have Z motion during a circular interpolation and this depends on the choice of G91 or G90. The command G91 G02 I0. J-0.5 Z-.2 tells the machine to do a full clockwise circle about the center negative 0.5" along the Y axis and at the same time increment the Z axis down 0.2". A G90 would tell the machine to move to the position Z-.2 in the current Work Coordinate system.

5. hope this info helps.

Stu

6. ## Drawing Circles :)

Originally Posted by jemmyell
Hi,

Can anybody help with an algorithm for generating circular interpolation for ARCs? I know the arc center (X,Y) the radius and the start angle and the end angle.

I want to output either a G02 or G03 gcode line.

TIA,

-James Leonard
'
OK I'm newbie here but i have simply solution for you.
Use simply raster algorithm it's eliminate all sin(x) cosin etc. living just simply adding etc. simply enough to use it on microcontroler..
To calculate it you need create something in way matrix of point each step give you 1 point on matrix. And use this Midpoint circle algorithm.

you can find it on this pages >
http://www.cs.unc.edu/~mcmillan/comp...e7/circle.html
http://en.wikipedia.org/wiki/Midpoint_circle_algorithm

To calculate G02 G03 code you need have in memory last position ( point X Y where you end after last G-command that will be a start point of your arc ) and then depend from what parameters you want get data of circle ( radius R , or I J ) you calculating closed circle and then from G02 (03) you need to take end ( pre-calculate end point ) to finding point on circle when you circle need to stop. Then you need to use jump algo to jump from start point to end and when you jumping from point to point you copping this like result of your calculation and then you can start driving motors.

I hope this hellp you a bit.

7. Ar2uR,

Interesting.

8. ## just a note

Just a note.

This issue was settled for me and successfuly implemented quite a while ago. The problem I was having was trying to work in degrees when all the published algorithms / code I had been looking at needed radians...

-James

Page 2 of 2 First 12

1. ###### What is G02 G03?
03-16-2013, 11:32 AM