Page 1 of 2 12 LastLast
Results 1 to 12 of 20

Thread: Algorithm for G02 / G03 coding

  1. #1
    Registered
    Join Date
    Mar 2003
    Location
    Orange County, California
    Posts
    322
    Downloads
    0
    Uploads
    0

    Algorithm for G02 / G03 coding

    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
    '
    James Leonard - www.DragonCNC.com - www.LeonardCNCSoftware.com - www.CorelDRAWCadCam.com - www.LeonardMusicalInstruments.com


  2. #2
    Community Moderator ger21's Avatar
    Join Date
    Mar 2003
    Location
    Shelby Twp, MI....USA
    Posts
    22,289
    Downloads
    0
    Uploads
    0
    Are you just looking for a formula to find the start and endpoints? That's all you'll need to write G2 or G3 code.
    Gerry

    Mach3 2010 Screenset
    http://home.comcast.net/~cncwoodworker/2010.html

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)


  3. #3
    Registered
    Join Date
    Mar 2003
    Location
    Orange County, California
    Posts
    322
    Downloads
    0
    Uploads
    0

    I need to calculate X, Y, I and J

    Quote Originally Posted by ger21 View Post
    Are you just looking for a formula to find the start and endpoints? That's all you'll need to write G2 or G3 code.
    Hi,

    I need to calculate X, Y, I and J (relative) for both G02 and G03, do you have formulas to do that based on the arc center, radius and start and end angles? These are values from a DXF file.

    Thanks!

    -James Leonard
    James Leonard - www.DragonCNC.com - www.LeonardCNCSoftware.com - www.CorelDRAWCadCam.com - www.LeonardMusicalInstruments.com


  4. #4
    Community Moderator ger21's Avatar
    Join Date
    Mar 2003
    Location
    Shelby Twp, MI....USA
    Posts
    22,289
    Downloads
    0
    Uploads
    0
    You just need to find the start and endpoints using trig. I and J are the center point relative to the start point. From the little research I just did, arcs are always CCW in a dxf. It looks like you'd take the sine of the start angle times the radius will give you the Y value of the start point (relative to the center of the arc). for the X, take the sine of 90°- start angle times the radius (again relative to the center of the arc). You probably need to convert the angles from (or to) radians.

    Your previous line of code needs to get you to the start point. Do the same thing to find the endpoint, which is the X,Y in your G2/G3 line.


    I wrote an AutoCAD macro that outputs g-code, but it doesn't do arcs. But It will do G2 and G3 from polyline arcs. A polyline gives you the start and end points, and radius (bulge) but not the center. I find the center using a chord, and the rest is easy.
    Gerry

    Mach3 2010 Screenset
    http://home.comcast.net/~cncwoodworker/2010.html

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)


  • #5
    Registered
    Join Date
    Mar 2003
    Location
    Orange County, California
    Posts
    322
    Downloads
    0
    Uploads
    0
    Quote Originally Posted by ger21 View Post
    You just need to find the start and endpoints using trig. I and J are the center point relative to the start point. From the little research I just did, arcs are always CCW in a dxf. It looks like you'd take the sine of the start angle times the radius will give you the Y value of the start point (relative to the center of the arc). for the X, take the sine of 90°- start angle times the radius (again relative to the center of the arc). You probably need to convert the angles from (or to) radians.

    Your previous line of code needs to get you to the start point. Do the same thing to find the endpoint, which is the X,Y in your G2/G3 line.


    I wrote an AutoCAD macro that outputs g-code, but it doesn't do arcs. But It will do G2 and G3 from polyline arcs. A polyline gives you the start and end points, and radius (bulge) but not the center. I find the center using a chord, and the rest is easy.

    Hi again,

    Thats good info, but I was hoping for explicit formulas. I really don't see how to calculate I and J, my math skills are not that good.

    Yes, DXF ARCs are always CCW, but for CNC purposes I may need to flip them to CW. I already know how to do this and how to derive the ARC center, radius and start and end angle from three points on the ARC (begin, end and middle) but I still don't see how to do the G02 / G03 stuff.

    -James Leonard
    James Leonard - www.DragonCNC.com - www.LeonardCNCSoftware.com - www.CorelDRAWCadCam.com - www.LeonardMusicalInstruments.com


  • #6
    Community Moderator ger21's Avatar
    Join Date
    Mar 2003
    Location
    Shelby Twp, MI....USA
    Posts
    22,289
    Downloads
    0
    Uploads
    0
    Find the start point of the arc using the sin method like I said. You already know the centerpoint.

    I = Centerpoint X - Startpoint X
    J= Centerpoint Y - Startpoint Y
    Gerry

    Mach3 2010 Screenset
    http://home.comcast.net/~cncwoodworker/2010.html

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)


  • #7
    Registered
    Join Date
    Mar 2003
    Location
    Orange County, California
    Posts
    322
    Downloads
    0
    Uploads
    0
    Quote Originally Posted by ger21 View Post
    Find the start point of the arc using the sin method like I said. You already know the centerpoint.

    I = Centerpoint X - Startpoint X
    J= Centerpoint Y - Startpoint Y
    OK!

    I will give it a fly tomorrow.

    -James
    James Leonard - www.DragonCNC.com - www.LeonardCNCSoftware.com - www.CorelDRAWCadCam.com - www.LeonardMusicalInstruments.com


  • #8
    Registered WayneHill's Avatar
    Join Date
    Mar 2004
    Location
    Michigan
    Posts
    780
    Downloads
    0
    Uploads
    0
    Here is an open source program to convert DXF to G-Code:

    http://www.dakeng.com/ace.html

    Here is my program to convert G-Code to DXF:

    G-Code to DXF
    Wayne Hill


  • #9
    Registered
    Join Date
    Mar 2003
    Location
    Orange County, California
    Posts
    322
    Downloads
    0
    Uploads
    0
    Quote Originally Posted by WayneHill View Post
    Here is an open source program to convert DXF to G-Code:

    http://www.dakeng.com/ace.html

    Here is my program to convert G-Code to DXF:

    G-Code to DXF
    Hi,

    The ACE converter source code is the most difficult I have ever read. I had a LOT of trouble trying to follow the DXF load and conversion process. Also ACE won't process my DXF files (from the DXFTool for CorelDraw). So, I am trying to come to a deeper understanding of this.

    -James Leonard
    James Leonard - www.DragonCNC.com - www.LeonardCNCSoftware.com - www.CorelDRAWCadCam.com - www.LeonardMusicalInstruments.com


  • #10
    Registered WayneHill's Avatar
    Join Date
    Mar 2004
    Location
    Michigan
    Posts
    780
    Downloads
    0
    Uploads
    0
    James,

    Can you post a short file of the DXF format that will not work with ACE ?

    Line,circle and a point.
    Wayne Hill


  • #11
    Registered
    Join Date
    Mar 2003
    Location
    Orange County, California
    Posts
    322
    Downloads
    0
    Uploads
    0

    Here is a DXF that ACE will not process

    All of these DXF files are pure LINE and ARC entities. This is to improve cutting over the many shortline segments CorelDraw generates for a polyline.

    Here is a circle, ellipse, star and rectangle. Both LazyCAM and SheetCAM are very happy with these DXF files.

    -James
    Attached Files Attached Files
    James Leonard - www.DragonCNC.com - www.LeonardCNCSoftware.com - www.CorelDRAWCadCam.com - www.LeonardMusicalInstruments.com


  • #12
    Registered
    Join Date
    Jun 2007
    Location
    USA
    Posts
    30
    Downloads
    0
    Uploads
    0
    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.


  • Page 1 of 2 12 LastLast

    Similar Threads

    1. Algorithm?
      By CNCgr in forum OpenSource Software
      Replies: 16
      Last Post: 12-07-2009, 06:23 PM
    2. XY positioning algorithm needed
      By Tracid in forum PIC Programing / Design
      Replies: 4
      Last Post: 11-28-2006, 11:26 AM
    3. Need Help With Circular Pocketing Algorithm
      By lerman in forum G-Code Programing
      Replies: 9
      Last Post: 11-20-2006, 05:41 PM
    4. Blending algorithm of EMC2
      By Hebert in forum LinuxCNC (formerly EMC2)
      Replies: 1
      Last Post: 10-21-2006, 11:22 AM
    5. Adaptive clearing algorithm video
      By davidmb in forum DIY CNC Router Table Machines
      Replies: 3
      Last Post: 05-02-2006, 02:13 PM

    Posting Permissions


     


    About CNCzone.com

      We are the largest and most active discussion forum from DIY CNC Machines to the Cad/Cam software to run them. The site is 100% free to join and use, so join today!

    Follow us on

    Facebook Dribbble RSS Feed


    Search Engine Friendly URLs by vBSEO ©2011, Crawlability, Inc.