588,049 active members*
4,245 visitors online*
Register for free
Login
IndustryArena Forum > Machine Controllers Software and Solutions > G-Code Programing > General formula using I and J for a circle, please.
Page 1 of 2 12
Results 1 to 20 of 28
  1. #1
    Join Date
    Jun 2005
    Posts
    1436

    General formula using I and J for a circle, please.

    Could anyone give me a general case using the diagram I have attached for the values of I and J in coding for a circle, if the tool start position is Xb,Yb ?

    As my software seems to run into problems if I enter zero for the value for I, I've located the tool start position at 45 degrees from the circle center.
    The value of sq.rt. 2 is permanently etched in my brain, so I have no problem in locating the tool, given the position of the center.

    I'm looking for a general formula primarily to help me get a better grasp of this command, as I have found a lot of 'explanations' ambiguous.
    Many thanks,
    John
    Attached Thumbnails Attached Thumbnails G-code circle.jpg  
    It's like doing jigsaw puzzles in the dark.
    Enjoy today's problems, for tomorrow's may be worse.

  2. #2
    Join Date
    Jul 2005
    Posts
    12177
    Half the square root of two comes into it.

    If the radius is 1.0000 the X and Y distances from the start point at 45 degrees are 0.7071 which is half the square root of two. Your I and J would be the same and the +/- sign is determined by the direction of your 45 degrees; in your diagram J is positive and I negative.

    This presupposes your software treats the I and J as incremental distances from the start point to the center; I believe some controllers treat the I and J as the absolute position of the center.
    An open mind is a virtue...so long as all the common sense has not leaked out.

  3. #3
    Join Date
    Jun 2005
    Posts
    1436
    Quote Originally Posted by Geof View Post
    ......This presupposes your software treats the I and J as incremental distances from the start point to the center; I believe some controllers treat the I and J as the absolute position of the center.
    Hi Geof, and thanks. This is where I think my problem lies, and perhaps just trying each would show me how my controller reacts.
    Is ther any possibility that it might treat I and J differently, one as absolute and one as incremental ?
    Sounds a nightmare, but I need to consider it !
    John
    It's like doing jigsaw puzzles in the dark.
    Enjoy today's problems, for tomorrow's may be worse.

  4. #4
    Join Date
    Feb 2007
    Posts
    20
    Mathematically, you can calculate I and J as:
    I = XArcCenterPoint-XArcStartPoint
    J= YArcCenterPoint-YArcStartPoint

    0, 90,180, and 270 degree arcs always have either I or J as zero.

    Hope this helps,
    Jimmy

  5. #5
    Join Date
    Jul 2005
    Posts
    12177
    Quote Originally Posted by greybeard View Post
    ......
    Is ther any possibility that it might treat I and J differently, one as absolute and one as incremental ?
    Sounds a nightmare, but I need to consider it !
    John
    You never know with pointy headed software types.
    An open mind is a virtue...so long as all the common sense has not leaked out.

  6. #6
    Join Date
    Jun 2005
    Posts
    1436
    Thanks Geof. Now I know why my hat stays on in high winds.:cheers:


    Quote Originally Posted by jimalb View Post
    Mathematically, you can calculate I and J as:
    I = XArcCenterPoint-XArcStartPoint
    J= YArcCenterPoint-YArcStartPoint
    Thanks Jimmy. So on my diagram, I = (Xo - Xb), and J = (Yo - Yb).

    Quote Originally Posted by jimalb View Post
    0, 90,180, and 270 degree arcs always have either I or J as zero.
    Unfortunately this is a problem for my set up - the controller seems to have a problem with a vaue of zero for I or J, and just tries to drill a hole radius = 0 :tired:

    John
    It's like doing jigsaw puzzles in the dark.
    Enjoy today's problems, for tomorrow's may be worse.

  7. #7
    Join Date
    Mar 2003
    Posts
    35538
    Jimmy's giving you incremental IJ. Is your control looking for absolute? Absolute IJ specify the actual center coordinates.
    Gerry

    UCCNC 2017 Screenset
    http://www.thecncwoodworker.com/2017.html

    Mach3 2010 Screenset
    http://www.thecncwoodworker.com/2010.html

    JointCAM - CNC Dovetails & Box Joints
    http://www.g-forcecnc.com/jointcam.html

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

  8. #8
    Join Date
    Jun 2005
    Posts
    1436
    Hi Gerry,

    Quote Originally Posted by ger21 View Post
    Jimmy's giving you incremental IJ. Is your control looking for absolute? Absolute IJ specify the actual center coordinates.
    I quote from the user manual - "G02 Arc clockwise, X,Y, ending coordinates, I,J, center offsets from beginning location."

    So do I assume this for incremental or absolute coordinates ?
    Regards
    John
    It's like doing jigsaw puzzles in the dark.
    Enjoy today's problems, for tomorrow's may be worse.

  9. #9
    Join Date
    Jul 2005
    Posts
    12177
    Quote Originally Posted by greybeard View Post
    Hi Gerry,



    I quote from the user manual - "G02 Arc clockwise, X,Y, ending coordinates, I,J, center offsets from beginning location."

    So do I assume this for incremental or absolute coordinates ?
    Regards
    John
    I interpret this as incremental. Have you done a successful circle using non-zero values in both I and J?
    An open mind is a virtue...so long as all the common sense has not leaked out.

  10. #10
    Join Date
    Mar 2003
    Posts
    35538
    Looks like incremental to me too. Not sure why it won't work with a zero coordinate.
    Gerry

    UCCNC 2017 Screenset
    http://www.thecncwoodworker.com/2017.html

    Mach3 2010 Screenset
    http://www.thecncwoodworker.com/2010.html

    JointCAM - CNC Dovetails & Box Joints
    http://www.g-forcecnc.com/jointcam.html

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

  11. #11
    Join Date
    Mar 2003
    Posts
    4826
    What comes to my mind, is that the TAN90° or TAN270° are undefined. So perhaps whatever formula the controller uses incorporates this trig function somehow, so it craps out when these particular angles are involved.
    First you get good, then you get fast. Then grouchiness sets in.

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

  12. #12
    Join Date
    Jul 2005
    Posts
    12177
    Here is a technique to test.

    Position the tool at what will be the hole center.

    Move the radius distance in Y and something like 0.1 in X.

    Now program the G02 using I-0.1 Y-(radius distance).


    EDIT: Your radius comes out wrong of course with the mov e of X0.1 but if this works see if it will accept an X move of 0.001 with a corresponding I-0.001; this will have negligible affect on the true radius.
    An open mind is a virtue...so long as all the common sense has not leaked out.

  13. #13
    Join Date
    Jun 2005
    Posts
    1436
    Geof - yes, I did one circle correctly, but only in MDF as a 1st test - not something I could measure up, but was 'fit for purpose'.
    I take your idea of creeping up on the zero problem, and I'll give that a go.

    HFD - I always like to come across a logically simple solution to an odd problem, and you may have given me one.

    Thanks all
    John
    It's like doing jigsaw puzzles in the dark.
    Enjoy today's problems, for tomorrow's may be worse.

  14. #14
    Join Date
    Jun 2008
    Posts
    1511
    When I program to spin a circle typically for making a counter bore on a part I use incremental.

    You can as Geof said creep up on the X. However I either move straight to the X radius and spin from there or arc into the X radius and Y radius at the same time.

    If you want to spin a .75 dia. Hole with a .5” dia endmill you can first position your tool to X0Y0 center of the hole. Move in X.125” this brings the edge of your tool to the edge of the hole. Now if you program G3X0Y0I-.125 this should spin around X0Y0 at a distance of .125 from center back to your starting point.

    I by no means clam to be very knowledgeable on the I’s and J’s this is just how I have done it. I do know that the I is suppose to be related to X and J is related to Y somehow.

    I don’t know if I contributed or am telling you guys stuff you already know but just wanted to throw my 2c in.

    Stevo

  15. #15
    Join Date
    Feb 2007
    Posts
    20
    Just another thought--
    have you tried doing circles in halves or quadrents--
    I've read about some controller software that has to have circles be cut in halve or in quadrents to cut correctly.
    ie... will not go past 180° or 90° per G02 or G03 move
    might be worth looking into ?
    Jimmy---

  16. #16
    Join Date
    Jun 2005
    Posts
    1436
    Quote Originally Posted by jimalb View Post
    Just another thought--
    have you tried doing circles in halves or quadrents--
    I've read about some controller software that has to have circles be cut in halve or in quadrents to cut correctly.
    ie... will not go past 180° or 90° per G02 or G03 move
    might be worth looking into ?
    Jimmy---
    I see what you mean, but that wasn't really the problem, only my own lack of understanding

    I was looking for a way of calculating the I and J values that would get it right each time using a formula that even I could manage !
    This is now ok, but I wonder why my controller will accept a G03 command and cut a circle, but not a G02 command - doesn't seem to understand the idea of going the otherway round
    But that's for another thread when I've got a bit more info on just what it does and doesn't do.
    But it does give you some idea of what I'm up against. :drowning:
    At least the software allows me to run a cutting path simulation on screen, so I can see what happens before I destroy any wood.
    John
    It's like doing jigsaw puzzles in the dark.
    Enjoy today's problems, for tomorrow's may be worse.

  17. #17
    Join Date
    Dec 2008
    Posts
    3136

    Cool

    My turn, Hi
    What machine is this ?

    Machines require code in a certain format
    Okuma use incremantal I J from the start of the arc to arc centre, if doing full circles, quite often both I & J are required to be stated.
    Some, the I & J are reverse ( arc centre to start of arc )
    Others have absolute I & J ( X0Y0 to arc centre )

    ( set X0Y0 near table centre, Z0 well above table )
    G94= feed per minute, Fcode required as the code is not as rapid, sometimes the spindle also needs to be running

    G0 X0 Y0
    G94 G2 I-1. J0. F1. ( full CW arc around a point 1" to the left of current position) ( this code is OK, but if you put an X or Y value in the block it will error trying to go from the current position to that XY using a radius of 1" )
    ie
    G0 X1. Y0
    G94 G2 X.5 Y0. I-1. J0. F1.

    examples using I & J
    G0 X0.5 Y0.
    G94 G3 X-1. Y0. I-1. F1. ( 180 deg CCW arc around X0Y0 )
    G0 X0.5 Y0.
    G3 X-1. Y0. I-1. ( same as above ) ( 180 deg arc )
    G0 X0.5 Y0.
    G3 X0. Y1. I-1. ( same as above ) ( 90 deg arc )
    G0 X0.5 Y0.
    G3 X0. Y-1. I-1. ( same as above ) ( 270 deg arc )

    -- they can also use an R for any arc less then 180 deg, and R- for greater than 180 deg ( this can make programming easier )

    examples using R
    G0 X0.5 Y0.
    G94 G3 X-1. Y0. R1.0 F1.0 ( 180 deg CCW arc around X0Y0 )
    G0 X0.5 Y0.
    G94 G3 X0. Y1. R1. F1.0 ( same as above ) ( 90 deg arc )
    G0 X0.5 Y0.
    G94 G3 X0. Y-1. R-1. F1.0 ( same as above ) ( 270 deg arc )

    example of ramping a flat bottom circle, feed to the centre and rapid retract
    G0 X1. Y0.
    Z1.
    G94 G3 Z.9 I-1. J0. F1.
    Z.8 I-1. J0.
    Z.7 I-1. J0.
    Z.6 I-1. J0.
    Z.5 I-1. J0.
    I-1. J0.
    G1 X0. Y0.
    G0 Z1. ( note, if g-code has modality, it doesn't need restating )

    Ideally, we may program full circles for ease, but with CAM software this may get broken down to half-circles or quadrents as this tends to control the cutter paths better when feedrates are increased ( full circles done too fast may make make them oval, or you may find a big hole done to correct size and a small hole undersize )

  18. #18
    Join Date
    Jun 2005
    Posts
    1436
    I'm sorry Superman, but your flying well over my head.

    This is a diy router using SuperCam 3.5, which has limited ability to recognise G code.
    It's limited to G00, G01, G02, G03, G90 and G91: I & J, F, M00, M03, M05, M08, M09 and M30, and might be considered to be a 2.5D machine.
    I certainly doesn't recognise R or G94.
    However, my exploring so far suggests I might push it further towards 3D for the sort of simple work I have in mind.

    I'm currently exploring it's capability by hand writing small bits of code, and came up against this arc/circle problem.
    Getting clear in my mind what the software expects, and then seeing the result seemed to be the most sensible approach.

    John
    It's like doing jigsaw puzzles in the dark.
    Enjoy today's problems, for tomorrow's may be worse.

  19. #19
    Join Date
    Dec 2008
    Posts
    3136
    Do you have a good list of G and M codes ?
    The list should be in 3 columns minimum , ie group,code,description

    The codes you suggest is a generic list, suitable to nearly all CNC machines

    G1=G01 & M03=M3 etc , you can remove the leading 0 , It's a shorter way of programming, N123 is only a line numbering system ( some machines use this to restart after an interruption, it has no effect on the machine, and may be omitted )

    Your list should have these and some "extras" on it , maybe inch(G20)-metric (G21), feed per minute(G94)-feed per revolution(G95), absolute(G90)-incremental(G90)

    These codes are seperated into groups where one specific G-code only affects another belonging in the same group.
    Say you set the machine to run in inch (G20 or it may be G70), any other G-code will not effect this setting unless it is a G21/G71 (metric), same goes for G0,G1,G2,G3 or M3,M4,M5 or G40,G41,G42. All these are examples of groups , G1 does not affect G41

    These codes above, I believe is only some of the basic set for a 2.5D machine, in saying this, try running the code with I & J in your machine before canning it, you may be surprised, then step up to the code with R, this may not run on your machine ( but then you will know it won't work ).

    The code I have given is not 3D , G94 is just put in case you run at feed / rev and can be omitted if not compatable. These are basic circles, arcs and lines

    I assume you are just beginning to learn NC ?
    You should experiment / investigate what codes your machine uses, all the codes above this point should be able to run on the most basic machine.

    A general rule of thumb when programming is never assume anything, start your program by setting the machine in a safe, ready to run state. If you turn it on, then turn it off before ending the program, you may run a different program with unexpected results

    example of a generic program
    N1 G00 G20 G40 G90 M5 ( set Rapid, Inch, Cutter Compensation Off, Absolute, Spindle Off )
    N2 Z10 ( retract off the part )
    N3 G28 X0. Y0. ( go home )( or similar code )( yours different )
    N4 M00 ( pause the program )
    N5 G15 H1 ( set a co-ordinate system )( yours different )
    N6 G0 X0. Y0. ( goto your part datum )
    N7 S1234 M3 ( set spindle speed, start spindle CW )
    N8 ...
    .......
    N300 M5
    ( spindle off )
    N301 Z10. ( retract )
    N302 G28 X0. Y0. ( go home ))( yours different )
    N303 M2 (or M30 ) ( rewind program to beginining )
    %

    N1 to N4 is a safety "header" - if you reset the program with the tool in / near the part - these lines when run, will take the tool away from your part safely ( obviously , you will customise to suit your machine )
    N300 to N303 is the "footer"- when finishing the part , we park everything before removing the tool or part.
    % is usually used by a transfer program to know when the end of file has been reached and to close the file and to stop the transfer program

    Have I gone too deep for you ?

  20. #20
    Join Date
    Jun 2005
    Posts
    1436
    No you haven't gone too deep for me Superman, but it would be reasonable to assume that when I state that my software/controller only recognises the list I gave, it's because I'm quoting directly from the manufacturer/designers manual.

    I can look and wonder at any list of G codes, as I have done, but if my machine manual says that it is not capable of recognising them, who am I to argue ?

    I was taught logic 50 years ago, and I find it still works pretty well.
    John
    It's like doing jigsaw puzzles in the dark.
    Enjoy today's problems, for tomorrow's may be worse.

Page 1 of 2 12

Similar Threads

  1. formula?
    By JOptionPane in forum CNC Machining Centers
    Replies: 2
    Last Post: 06-23-2008, 07:52 PM
  2. need a formula
    By gravy in forum MetalWork Discussion
    Replies: 4
    Last Post: 03-29-2008, 01:38 PM
  3. looking for a Formula
    By rusticr6 in forum Haas Mills
    Replies: 29
    Last Post: 10-18-2007, 04:23 PM
  4. What is the Formula?
    By widgitmaster in forum Uncategorised MetalWorking Machines
    Replies: 6
    Last Post: 03-24-2006, 05:35 AM
  5. Formula
    By CNCRob in forum Uncategorised CAM Discussion
    Replies: 3
    Last Post: 07-01-2005, 03:18 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
  •