586,068 active members*
3,860 visitors online*
Register for free
Login
Results 1 to 9 of 9
  1. #1
    Join Date
    Jul 2011
    Posts
    0

    Programming a Display Program for GCode

    Hi,
    I'm currently a software engineering for a laser company and am programming a GCode display program in C#. How would I go about displaying arcs using I/J values?

    As far as drawing arcs goes here are my options:
    x, y, width, height, startAngle, sweepAngle
    Rectangle, startAngle, sweepAngle

    How would I gather the startAngle and sweepAngle from the GCode? Another option would be just to draw an arc using straight lines... How should I approach this?

  2. #2
    Join Date
    Jan 2010
    Posts
    2141
    There is some info here that may give you some ideas:

    http://www.cnczone.com/forums/austra...e_indexer.html

  3. #3
    Join Date
    Jul 2011
    Posts
    0
    Don't think that's what I'm looking for...

  4. #4
    Join Date
    Jun 2008
    Posts
    128
    The best place I found that describes the different methods of arcs in G code is the Mach3 manual.
    It can be found at http://www.machsupport.com/docs/Mach3Mill_1.84.pdf
    Look at section 10.7.3.1 and 10.7.3.2

    George

  5. #5
    Join Date
    Jul 2011
    Posts
    0
    Quote Originally Posted by george4657 View Post
    The best place I found that describes the different methods of arcs in G code is the Mach3 manual.
    It can be found at http://www.machsupport.com/docs/Mach3Mill_1.84.pdf
    Look at section 10.7.3.1 and 10.7.3.2

    George
    Thanks I'll take a look! If anyone else has any input I'd love some more help, I'm fairly new to the GCode scene (Only been working at this job for a few weeks).

  6. #6
    Join Date
    May 2005
    Posts
    1662
    Quote Originally Posted by ZSamuels28 View Post
    Hi,
    I'm currently a software engineering for a laser company and am programming a GCode display program in C#.
    A graphical display, what most of us here would call a backplotter ?
    Example NCPlot.
    NCPlot.com - Tools for CNC Programmers

    How would I gather the startAngle and sweepAngle from the GCode?
    Arc Buddy is a simple python script that does what you want in reverse. I'm not sure if it helps at all but the code won't cost much time to read.
    EMC Documentation Wiki: Simple EMC G-Code Generators

    "Axis" does the backplotting for EMC2. It's open source but wading through the code will take a lot of effort. More python.

    Another option would be just to draw an arc using straight lines... How should I approach this?
    No idea.
    G02 and G03 defines arcs so why go there ?

    edit/ G02 and G03 use 'start point/end point/distance from center' (or alternatively R). If sweep is needed the program will need to make the calculation, it helps to think in quadrants.
    Anyone who says "It only goes together one way" has no imagination.

  7. #7
    Join Date
    Jul 2011
    Posts
    0
    Quote Originally Posted by cyclestart View Post

    Arc Buddy is a simple python script that does what you want in reverse. I'm not sure if it helps at all but the code won't cost much time to read.
    EMC Documentation Wiki: Simple EMC G-Code Generators

    "Axis" does the backplotting for EMC2. It's open source but wading through the code will take a lot of effort. More python.


    No idea.
    G02 and G03 defines arcs so why go there ?

    edit/ G02 and G03 use 'start point/end point/distance from center' (or alternatively R). If sweep is needed the program will need to make the calculation, it helps to think in quadrants.
    Thank You! Looks good! I'll have to test it out and see if it does what I need.

  8. #8
    Join Date
    Sep 2010
    Posts
    1230
    Quote Originally Posted by ZSamuels28 View Post
    Hi,
    I'm currently a software engineering for a laser company and am programming a GCode display program in C#. How would I go about displaying arcs using I/J values?

    As far as drawing arcs goes here are my options:
    x, y, width, height, startAngle, sweepAngle
    Rectangle, startAngle, sweepAngle

    How would I gather the startAngle and sweepAngle from the GCode? Another option would be just to draw an arc using straight lines... How should I approach this?
    Using the X,Y plane as the example, circular interpolation (G02, G03) is coded using I,J or R. In some controls the I and J values describe the Absolute coordinates of the arc center point and in others, the Incremental distance from the start point of the arc. When using R in the circular interpolation coding, the R value is passed to the control where the arc center is calculated based on the start and end point of the arc.

    When writing software to display the tool path, you can:
    1. Easily calculate the arc center point in systems using I and J to describe the center point incrementally, by applying the I and J values to the arc start point.
    2. In systems using I and J to describe the arc center in Absolute terms, the center requires no calculation.
    3. In systems using R, the center point is calculated using the Start, End points and the R value. I can give you the algorithm for this if its a help to you.

    Once the arc center is known the Start and End angle of the arc is calculated using simple trigonometry.

    If the software is to display the cutter path of a laser machine (top view of XY plane) then using arc center, start angle, sweep angle, and radius is the best solution. If the display is an Isometric view, then the properties of the arc will still have to be calculated based on the G code data, but the acr will be drawn using short, straight lines because the representative curve drawn in the display will not be a true arc.

    Regards,

    Bill

  9. #9
    Join Date
    May 2005
    Posts
    2502
    ZSamuels, if I understand your question correctly, you're trying to write a g-code simulator in C++ to be used with your laser. Is that correct?

    If so, there's quite a lot for you to consider. I've got a simulator in Beta Test called G-Wizard Editor:

    GWizard Editor: A G-Code Editor and Simulator

    Something you may find useful about GWE is it has a facility called "Hints" for folks that are not dyed in the wool g-code experts (actually it is helpful to many experts too, LOL). It pumps out a lot of information about each line of g-code in easy to understand English.

    Here is a typical hint with information on an arc, for example:



    You might find it useful just because it provides a lot of information about the arc that is not immediately obvious just looking at the raw g-code.

    As for the other considerations of a g-code simulator, the language has all sorts of ways to modify what's going on that you'll need to be aware of depending on which dialect your laser's controller plans to support.

    For example, you'll need to be prepared to plot the arc when scaling, work offsets, coordinate rotation, and various other factors are in play. Quite a bit of work required to build a general purpose simulator, LOL.

    Probably the best place to drill down and see at least one way things are done is to go check out the source code for EMC2.

    Best,

    BW
    Try G-Wizard Machinist's Calculator for free:
    http://www.cnccookbook.com/CCGWizard.html

Similar Threads

  1. 4th-Axis GCode Programming
    By twehr in forum G-Code Programing
    Replies: 10
    Last Post: 02-19-2023, 11:02 AM
  2. Gcode sub program example needed
    By MrWild in forum LinuxCNC (formerly EMC2)
    Replies: 14
    Last Post: 09-03-2010, 11:51 PM
  3. Newbie Q: (Mach/Gcode/Tormach?) display vars?
    By rc33 in forum Tormach Personal CNC Mill
    Replies: 10
    Last Post: 11-18-2008, 10:16 PM
  4. Replies: 15
    Last Post: 11-27-2007, 09:27 PM
  5. Toolchanging and offsets gcode programming
    By ddanutz in forum G-Code Programing
    Replies: 12
    Last Post: 11-04-2006, 11:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •