Need Help! How ARC center, start angle, and sweep are calculated?


Page 1 of 3 123 LastLast
Results 1 to 20 of 41

Thread: How ARC center, start angle, and sweep are calculated?

  1. #1
    Registered
    Join Date
    Apr 2017
    Location
    Turkey
    Posts
    8
    Downloads
    0
    Uploads
    0

    Question How ARC center, start angle, and sweep are calculated?

    Hi,

    I'm trying to get my head around the gcode and I have been playing with gWizard and CamBam for that reason. Both of them are great programs to learn more about gCode and how a line of code might look like in real time, without risking machines and parts.

    Well, I can understand most of the commands and how they are interpreted, except those for ARCs. I don't know, but when it comes to arcs and circular interpolation, things are really ambiguous and difficult to digest.

    I have created an arc with CamBam and attached the generated gcode here. Could you please tell me how the software/interpreter calculates the start angle, sweep, and the coordinates of the arc's center based on the given data in a line of gcode, (X, Y, I, J). I know that the angle for the end/target point can be calculated by tan^-1(y/x), however, I just don't know how to get that of the start point, especially when that point lies somewhere in the third or fourth quadrant and how to get the sweep (angular travel) out of that, as well?

    Thank you in advance!


    Zaher

    Similar Threads:
    Attached Files Attached Files


  2. #2
    Member ger21's Avatar
    Join Date
    Mar 2003
    Location
    Shelby Township
    Posts
    35538
    Downloads
    1
    Uploads
    0

    Default Re: How ARC center, start angle, and sweep are calculated?

    The start point of a G2/G3 arc is the current position.

    The center of the arc are the I and J coordinates, relative to the start point.
    I=X
    J=Y

    Since your start point is 0,0, and your IJ coordinates are 2,2, the center is at 2,2 (0+2)
    The end point is specified in the G2/G3 move, in this case, 4,4.

    So, you're cutting an arc that starts at 0,0, and ends at 4,4, with the center at 2,2.

    Say you wanted to move the circle 2 units to the right, and 1 unit up. You just need to change the start and end points.

    G0 X2.0 Y1.0 (arc starts at 2,1)
    G0 Z1.0
    G1 F300.0 Z-0.4
    G3 F800.0 X6.0 Y5.0 I2.0 J2.0 (arc ends at 6,5)

    Note that the center is relative to the start point, so the center is now at 4,3, even though the I and J coordinates are still 2.
    X center = 2+2 = 4
    Y center = 1+2 = 3

    So you now have an arc that starts at 2,1, ends at 4,4, with the center at 4,3.

    Forgot to mention that G2 arcs are CW, and G3 are CCW.

    Gerry

    UCCNC 2017 Screenset
    [URL]http://www.thecncwoodworker.com/2017.html[/URL]

    Mach3 2010 Screenset
    [URL]http://www.thecncwoodworker.com/2010.html[/URL]

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

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


  3. #3
    Community Moderator Jim Dawson's Avatar
    Join Date
    Dec 2013
    Posts
    5717
    Downloads
    0
    Uploads
    0

    Default Re: How ARC center, start angle, and sweep are calculated?

    The ATAN2 function returns the quadrant.

    https://en.wikipedia.org/wiki/Atan2

    The sweep is the difference between the start and end points. Sweep direction is determined by the G-code, G02 or G03

    Can you post your G-code file as a text file rather than a rar.

    Last edited by Jim Dawson; 04-25-2017 at 08:22 AM.


  4. #4
    Member handlewanker's Avatar
    Join Date
    Sep 2006
    Location
    Australia
    Posts
    6463
    Downloads
    0
    Uploads
    0

    Default Re: How ARC center, start angle, and sweep are calculated?

    Hi......just getting to grips with G code too........isn't there another way using R for the radius of the arc and the diam of the circle with it's centre position?

    According to my notes on circular interpolation with a circle of 20mm radius and to create a full 90 degree arc segment ...........
    G02 X20 Y0 R20.........

    That seems to be more logical and simpler than using the I and J in a sequence.

    My notes also state that you can't create a full circle using the R notation....... but I have a G code sequence from CNC Cookbook where the thread milling sequence uses the R notation.

    Correct me if I'm wrong please.
    Ian.



  5. #5
    Member ger21's Avatar
    Join Date
    Mar 2003
    Location
    Shelby Township
    Posts
    35538
    Downloads
    1
    Uploads
    0

    Default Re: How ARC center, start angle, and sweep are calculated?

    IJ is a better method, because the R method can be ambiguous in some cases, which is why some controls don't allow full circles with the R method.

    The R method does not specify the center, just the start, end, and radius, so in some cases you can get two different arcs.

    Gerry

    UCCNC 2017 Screenset
    [URL]http://www.thecncwoodworker.com/2017.html[/URL]

    Mach3 2010 Screenset
    [URL]http://www.thecncwoodworker.com/2010.html[/URL]

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

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


  6. #6
    Member KH0UJ's Avatar
    Join Date
    Jul 2016
    Location
    Philippines
    Posts
    660
    Downloads
    0
    Uploads
    0

    Default Re: How ARC center, start angle, and sweep are calculated?

    I never thought making a simple arc had so much calculations and transport it on cambam is so hard, or is it? for all I know is I can do it with just drawing a precised arc then transport it in cambam then I can start at any point on the arc, so if a simple arc is so hard with all the calculations and stuff how much more if the model is like this?







    im guessing 2 pages of calculations? no just kidding

    im using cambam without any calculations at all. just a precised measurements that`s all

    Attached Thumbnails Attached Thumbnails How ARC center, start angle, and sweep are calculated?-plain-right-left-hand-grip-2-jpg   How ARC center, start angle, and sweep are calculated?-df-jpg   How ARC center, start angle, and sweep are calculated?-fvgb-jpg  


  7. #7
    Member KH0UJ's Avatar
    Join Date
    Jul 2016
    Location
    Philippines
    Posts
    660
    Downloads
    0
    Uploads
    0

    Default Re: How ARC center, start angle, and sweep are calculated?

    is this what you mean by start cutting at the center of the arc?

    Code:
    ( T0 : 0.0 )
    G21 G90 G91.1 G64 G40
    G0 Z10.0
    ( T0 : 0.0 )
    T0 M6
    ( 1 )
    G17
    M3 S1000
    G0 X-35.3553 Y-35.3553
    G0 Z1.0
    G1 F1000.0 Z0.0
    G1 X-36.9816 Y-33.6506
    G1 X-38.5257 Y-31.8712
    G1 X-39.9842 Y-30.021
    G1 X-41.354 Y-28.1042
    G1 X-42.632 Y-26.1249
    G1 X-43.8153 Y-24.0877
    G1 X-44.9014 Y-21.997
    G1 X-45.8877 Y-19.8574
    G1 X-46.7722 Y-17.6737
    G1 X-47.5528 Y-15.4508
    G1 X-48.2279 Y-13.1937
    G1 X-48.7958 Y-10.9072
    G1 X-49.2555 Y-8.5965
    G1 X-49.6057 Y-6.2667
    G1 X-49.8459 Y-3.923
    G1 X-49.9753 Y-1.5705
    G1 X-49.9938 Y0.7854
    G1 X-49.9013 Y3.1395
    G1 X-49.698 Y5.4867
    G1 X-49.3844 Y7.8217
    G1 X-48.9611 Y10.1394
    G1 X-48.4292 Y12.4345
    G1 X-47.7897 Y14.702
    G1 X-47.044 Y16.9369
    G1 X-46.194 Y19.1342
    G1 X-45.2414 Y21.289
    G1 X-44.1883 Y23.3965
    G1 X-43.0371 Y25.4521
    G1 X-41.7904 Y27.4511
    G1 X-40.4508 Y29.3893
    G1 X-39.0215 Y31.2621
    G1 X-37.5056 Y33.0656
    G1 X-35.9063 Y34.7956
    G1 X-34.2274 Y36.4484
    G1 X-32.4724 Y38.0203
    G1 X-30.6454 Y39.5078
    G1 X-28.7503 Y40.9075
    G1 X-26.7913 Y42.2164
    G1 X-24.7729 Y43.4316
    G1 X-22.6995 Y44.5503
    G1 X-20.5757 Y45.5702
    G1 X-18.4062 Y46.4888
    G1 X-16.1959 Y47.3043
    G1 X-13.9496 Y48.0147
    G1 X-11.6723 Y48.6185
    G1 X-9.3691 Y49.1144
    G1 X-7.0451 Y49.5012
    G1 X-4.7054 Y49.7781
    G1 X-2.3553 Y49.9445
    G1 X0.0 Y50.0
    G0 Z10.0
    G0 X50.0 Y0.0
    G0 Z1.0
    G1 Z0.0
    G1 X49.9445 Y-2.3553
    G1 X49.7781 Y-4.7054
    G1 X49.5012 Y-7.0451
    G1 X49.1144 Y-9.3691
    G1 X48.6185 Y-11.6723
    G1 X48.0147 Y-13.9496
    G1 X47.3043 Y-16.1959
    G1 X46.4888 Y-18.4062
    G1 X45.5702 Y-20.5757
    G1 X44.5503 Y-22.6995
    G1 X43.4316 Y-24.7729
    G1 X42.2164 Y-26.7913
    G1 X40.9075 Y-28.7503
    G1 X39.5078 Y-30.6454
    G1 X38.0203 Y-32.4724
    G1 X36.4484 Y-34.2274
    G1 X34.7956 Y-35.9063
    G1 X33.0656 Y-37.5056
    G1 X31.2621 Y-39.0215
    G1 X29.3893 Y-40.4508
    G1 X27.4511 Y-41.7904
    G1 X25.4521 Y-43.0371
    G1 X23.3965 Y-44.1883
    G1 X21.289 Y-45.2414
    G1 X19.1342 Y-46.194
    G1 X16.9369 Y-47.044
    G1 X14.702 Y-47.7897
    G1 X12.4345 Y-48.4292
    G1 X10.1394 Y-48.9611
    G1 X7.8217 Y-49.3844
    G1 X5.4867 Y-49.698
    G1 X3.1395 Y-49.9013
    G1 X0.7854 Y-49.9938
    G1 X-1.5705 Y-49.9753
    G1 X-3.923 Y-49.8459
    G1 X-6.2667 Y-49.6057
    G1 X-8.5965 Y-49.2555
    G1 X-10.9072 Y-48.7958
    G1 X-13.1937 Y-48.2279
    G1 X-15.4508 Y-47.5528
    G1 X-17.6737 Y-46.7722
    G1 X-19.8574 Y-45.8877
    G1 X-21.997 Y-44.9014
    G1 X-24.0877 Y-43.8153
    G1 X-26.1249 Y-42.632
    G1 X-28.1042 Y-41.354
    G1 X-30.021 Y-39.9842
    G1 X-31.8712 Y-38.5257
    G1 X-33.6506 Y-36.9816
    G1 X-35.3553 Y-35.3553
    G0 Z10.0
    M5
    M30




  8. #8
    Member ger21's Avatar
    Join Date
    Mar 2003
    Location
    Shelby Township
    Posts
    35538
    Downloads
    1
    Uploads
    0

    Default Re: How ARC center, start angle, and sweep are calculated?

    is this what you mean by start cutting at the center of the arc?
    Not sure who you are replying to, but there are no arcs in your code. It's all straight segments, which is typical of 3D g-code.
    And this has nothing to do with the original question.

    Gerry

    UCCNC 2017 Screenset
    [URL]http://www.thecncwoodworker.com/2017.html[/URL]

    Mach3 2010 Screenset
    [URL]http://www.thecncwoodworker.com/2010.html[/URL]

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

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


  9. #9
    Member
    Join Date
    Nov 2008
    Location
    Austria
    Posts
    110
    Downloads
    0
    Uploads
    0

    Default Re: How ARC center, start angle, and sweep are calculated?

    Quote Originally Posted by handlewanker View Post

    My notes also state that you can't create a full circle using the R notation....... but I have a G code sequence from CNC Cookbook where the thread milling sequence uses the R notation.

    Correct me if I'm wrong please.
    Ian.
    Take a piece of paper. Mark two points - one for arc start, one for arc end. Then tak a compass and set it to "R". Now use the compass to find arc center - draw circles around your points. Center if your arc lies where the circles cross. In most cases there will be 2 cross pints - one for "right" arc one for "left" arc. If your point are near to each other you will have problem to find center point cause instead of nice cross point you get overlapping lines (due to finite width of pencil line). If the points lie in the sane spot (full circle arc) there is no defined center point anymore.
    G-code interpreter makes basically the the same - with the difference that instead of paper and pencil numbers are used. Computed numbers are finer than any pencil - but due to the way computers are working not infinitely fine. Thats why you cannot get full circle in r notation and it's bad idea to use it when endpoints are near in comparison to R.



    Wysłane z mojego GT-N7100 przy użyciu Tapatalka



  10. #10
    Member handlewanker's Avatar
    Join Date
    Sep 2006
    Location
    Australia
    Posts
    6463
    Downloads
    0
    Uploads
    0

    Default Re: How ARC center, start angle, and sweep are calculated?

    Quote Originally Posted by ger21 View Post
    IJ is a better method, because the R method can be ambiguous in some cases, which is why some controls don't allow full circles with the R method.

    The R method does not specify the center, just the start, end, and radius, so in some cases you can get two different arcs.
    Hi.....not sure what the "some cases" applies to for the R notation method.........using hand written G code and Mach3, if you have a square plate with an external radius on the corner making it a 1/4 of a circle, how would you get 2 different arcs.......doesn't the cutter move round the radius from the horizontal plane to the lower vertical plane and so you have one arc?
    Ian.



  11. #11
    Member handlewanker's Avatar
    Join Date
    Sep 2006
    Location
    Australia
    Posts
    6463
    Downloads
    0
    Uploads
    0

    Default Re: How ARC center, start angle, and sweep are calculated?

    Quote Originally Posted by grg12 View Post
    Take a piece of paper. Mark two points - one for arc start, one for arc end. Then tak a compass and set it to "R". Now use the compass to find arc center - draw circles around your points. Center if your arc lies where the circles cross. In most cases there will be 2 cross pints - one for "right" arc one for "left" arc. If your point are near to each other you will have problem to find center point cause instead of nice cross point you get overlapping lines (due to finite width of pencil line). If the points lie in the sane spot (full circle arc) there is no defined center point anymore.
    G-code interpreter makes basically the the same - with the difference that instead of paper and pencil numbers are used. Computed numbers are finer than any pencil - but due to the way computers are working not infinitely fine. Thats why you cannot get full circle in r notation and it's bad idea to use it when endpoints are near in comparison to R.



    Wysłane z mojego GT-N7100 przy użyciu Tapatalka
    Hi.....if you use that method you will get an arc centre somewhere on the paper and not relating to the two points..........I think that the radius and the start and end points must be in relation to one another and the radius so that the arc starts and finishes where you want it to.

    It is logical to assume that if you are going to make an arc on the corner of a plate.....which is a common occurrence..........the start point on the X axis and the end point on the Y axis would be one 1/4 of the circle and half the circle diam and the R is the centre point of the arc which gives you the exact radius on the corner.....please correct me if I'm wrong.
    Ian.



  12. #12
    Registered
    Join Date
    Apr 2017
    Location
    Turkey
    Posts
    8
    Downloads
    0
    Uploads
    0

    Default Re: How ARC center, start angle, and sweep are calculated?

    Well, making that "simple" arc might not be that simple when you are making it an an embedded application. It's way different from your own perspective!
    Quote Originally Posted by KH0UJ View Post
    I never thought making a simple arc had so much calculations and transport it on cambam is so hard, or is it? for all I know is I can do it with just drawing a precised arc then transport it in cambam then I can start at any point on the arc, so if a simple arc is so hard with all the calculations and stuff how much more if the model is like this? im guessing 2 pages of calculations? no just kidding im using cambam without any calculations at all. just a precised measurements that`s all




  13. #13
    Registered
    Join Date
    Apr 2017
    Location
    Turkey
    Posts
    8
    Downloads
    0
    Uploads
    0

    Default Re: How ARC center, start angle, and sweep are calculated?

    Hi Gerry,

    Thank you very much for your prompt and excellent follow up. In fact, I intended to start at (0,0) to make things easier for me to understand how the software/interpreter calculates these coordinates based on the given line of gCode. I picked up the center format from the beginning because it's the preferred method and that's what I wanted my controller to support. Radius format is easier to understand, but I believe center format is less prone to mistakes.



  14. #14
    Registered
    Join Date
    Apr 2017
    Location
    Turkey
    Posts
    8
    Downloads
    0
    Uploads
    0

    Default Re: How ARC center, start angle, and sweep are calculated?

    Hi Jim,

    You got to the point. At an earlier stage of my code, I had a function that returns theta of start and end angle based on atan() and some other if conditions. However, I modified the function recently to use atan2(). I'm on a different workstation now so I don't have the stuff next to me, but I will get back to them and see where exactly my problem lies and will get back to you then. I will post te gcode as a text over here, as well!

    Thank you again for your help!


    Zaher

    Quote Originally Posted by Jim Dawson View Post
    The ATAN2 function returns the quadrant.

    https://en.wikipedia.org/wiki/Atan2

    The sweep is the difference between the start and end points. Sweep direction is determined by the G-code, G02 or G03

    Can you post your G-code file as a text file rather than a rar.




  15. #15
    Registered
    Join Date
    Apr 2017
    Location
    Turkey
    Posts
    8
    Downloads
    0
    Uploads
    0

    Default Re: How ARC center, start angle, and sweep are calculated?

    Quote Originally Posted by handlewanker View Post
    That seems to be more logical and simpler than using the I and J in a sequence.
    Of course, and in my situation, I was better off with the radius format, but because I J K (center format) is preferred over the radius format, I thought I would rather have that supported in my controller.



  16. #16
    Member
    Join Date
    Nov 2008
    Location
    Austria
    Posts
    110
    Downloads
    0
    Uploads
    0

    Default Re: How ARC center, start angle, and sweep are calculated?

    Quote Originally Posted by handlewanker View Post
    Hi.....if you use that method you will get an arc centre somewhere on the paper and not relating to the two points..........
    Im not really sure what do you mean? You get arc connecting those 2 points.

    Quote Originally Posted by handlewanker View Post
    It is logical to assume that if you are going to make an arc on the corner of a plate.....which is a common occurrence..........the start point on the X axis and the end point on the Y axis would be one 1/4 of the circle and half the circle diam and the R is the centre point of the arc which gives you the exact radius on the corner.....please correct me if I'm wrong.
    Ian.
    Yes - but that's one, very special, case. You assume that radius goes smoothly into plate side wall. You assume that walls are perpendicular and so on. But try to calculate arc for something lhat looks like a lolipop, or the "bite" on apple logo



  17. #17
    Community Moderator Jim Dawson's Avatar
    Join Date
    Dec 2013
    Posts
    5717
    Downloads
    0
    Uploads
    0

    Default Re: How ARC center, start angle, and sweep are calculated?

    Quote Originally Posted by e-music View Post
    Hi Jim,

    You got to the point. At an earlier stage of my code, I had a function that returns theta of start and end angle based on atan() and some other if conditions. However, I modified the function recently to use atan2(). I'm on a different workstation now so I don't have the stuff next to me, but I will get back to them and see where exactly my problem lies and will get back to you then. I will post te gcode as a text over here, as well!

    Thank you again for your help!


    Zaher
    It sounds like you have a similar problem to what I had with my Galil controller that only accepts Radius (in encoder pulses or steps), Start (in degrees), and Sweep (in degrees).

    The return from the ATAN2 function is not always correct, sometimes you have to add something like 0.001 degrees to get things to work correctly, especially if the end point is 360 or 0 degrees. I wrote 2 modules in VB.net to handle the errors for G2 and G3. Many times it's easier to do the math in radians, then convert to degrees for the output, but you have to be careful of the rounding errors.



  18. #18
    Member handlewanker's Avatar
    Join Date
    Sep 2006
    Location
    Australia
    Posts
    6463
    Downloads
    0
    Uploads
    0

    Default Re: How ARC center, start angle, and sweep are calculated?

    Hi, just had another in depth look at the notes I made regarding the creation of an arc on the corner of a square plate .....for example.

    It appears that it's not just a simple walk in the park with arc dimensions etc.........the I and J notations are in incremental dimensions whereas the required tool path is to the eye in an absolute mode.

    For example, a tool path left to right along the X axis is a positive move with a radius on the corner sending the cutter around the arc to change direction to a Y negative move.

    The cutter diam plays an important part in the I and J calculation as it determines the values of the X and Y moves........the radius of the arc on the part is different to the radius of the cutter tool path etc., but both have the same arc centre point.

    For instance, and I quote,........a square plate 5" X 5" with a radius on the top right side corner of 1.5" and a cutter diam of .5" diam.........

    The code would be..... starting from the left corner as 0 0.

    G02 X5.25 Y-1.5 I0 J1.75.......according to the notes I have......you would have to know precisely the diam of the cutter and also that it is not running out of round and so giving you a different cutter radius.

    This is a confusing complication to me for an apparently simple process as the simple R notation method is......

    G02 X5 Y-1.5 R1.5.

    The cutter diam is what you have written in the tool register for the particular cutter used......Mach 3 would adjust the tool path automatically to suit that cutter diam.

    I assume that without the R1.5 on the end.....(even with G02?)...... you would just get an error message not a straight line 45 degree angle move as opposed to a curve.......therefore the R tells Mach 3 that it must move in variable steps to create a radius.......that is a complicated move, but devilishly clever and simple to envisage.

    The example I'm quoting would be a very common rounding of the corners of a piece of plate.

    Am I missing something in interpretation as I'll be in deep poo poo otherwise.
    Ian..

    Last edited by handlewanker; 04-25-2017 at 10:19 PM.


  19. #19
    Registered
    Join Date
    Apr 2017
    Location
    Turkey
    Posts
    8
    Downloads
    0
    Uploads
    0

    Default Re: How ARC center, start angle, and sweep are calculated?

    Quote Originally Posted by Jim Dawson View Post
    The return from the ATAN2 function is not always correct, sometimes you have to add something like 0.001 degrees to get things to work correctly, especially if the end point is 360 or 0 degrees.
    Hi again,

    Yes, you are correct. I believe the same applies to the start point. That's why I intended to start the arc at (0,0), in this case, the atan2() returns a theta of 0, and this is where the problem lies. Working with degrees is much easier, however, because most of the trigonometric functions I wrote take radians, I decided to avoid conversion in order to save CPU time in the calculations involved. Now, adding (-0.001, -0.001) to the start point, the atan2() returns the correct theta for start point, 5pi/4 (225 in degrees). Do I have to do this only when the coordinates of start point are (0,0) or you think there are other occurrences where this addition might be required? Adding (0.001, 0.001) returns the opposite theta in the first quadrant. For this arc, it is theta of end point.



  20. #20
    Registered
    Join Date
    Apr 2017
    Location
    Turkey
    Posts
    8
    Downloads
    0
    Uploads
    0

    Default Re: How ARC center, start angle, and sweep are calculated?

    And this is the gcode for the arc created with CamBam.

    Code:
    ( Made using CamBam - http://www.cambam.co.uk )
    ( Untitled 4/23/2017 5:00:39 PM )
    ( T0 : 0.0 )
    G21 G90 G64 G40
    G0 Z3.0
    ( T0 : 0.0 )
    T0 M6
    ( Engrave1 )
    G17
    M3 S1000
    G0 X0.0 Y0.0
    G0 Z1.0
    G1 F300.0 Z-0.4
    G3 F800.0 X4.0 Y4.0 I2.0 J2.0
    G0 Z3.0
    M5
    M30




Page 1 of 3 123 LastLast

Tags for this Thread

Posting Permissions

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


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

How ARC center, start angle, and sweep are calculated?

How ARC center, start angle, and sweep are calculated?