Tuesday 19 January 2021

Arc-fitting and Arc-breaking with bCNC

 How does CAM deal with constant radius arcs and near-arcs ?  Fusion 360 has smoothing and tolerance settings in the general operation (pre-post process) dialogue box which determines how splines are treated in terms of tangent arcs or line segments. The actual post process may make additional changes.  It will attempt to do arc-fitting if told to do so.  FreeCAD doesn't have an exact equivalent to the best of my knowledge.  It does have a user settable geometry tolerance setting but I haven't found any documentation that describes what this does in any detail.  It does do some arc-fitting as will be described further down this page.  True arcs are output as G2/G3 in both Fusion and FreeCAD although Fusion 360 includes at least one post process that posts all arcs as line segments.

This topic was prompted by a couple of things.  First was an earlier post about nesting and discovering Deepnest can do bad things to arcs.  Second was seeing the elimination of G2/G3 as a recurring topic on the FreeCAD forums.

Among the many interesting things bCNC can do with existing g-code are the tools Linearize and ArcFit.  Arc fitting will attempt to replace a series of line segments that approximate an arc with G2/G3 arcs.  Linearize does the opposite, replacing G2/G3 arcs with line segments.

The image to the left is the QCAD property editor looking at a dxf exported from Deepnest.  A 50mm circle has a circumference of 157mm and with a 0.050mm curve tolerance set in Deepnest there are only 144 segments ? Curve Tolerance doesn't work exactly as I expected.  No problem as this dxf resulted in FreeCAD posting G2/G3 arcs.  It appears FreeCAD does arc-fitting even if the setting is not visible to the user.

Click on any image to enlarge

 

 

 

 

 

In another case Deepnest has broken a 38.1mm circle into 40 segments.  FreeCAD's g-code output has refined the arc by increasing the number of segments to 74.  No G2/G3 arcs were produced.  The tool used was 6.35 diameter.

Using the settings seen on the left bCNC replaced the 74 line segments with 6 arcs.  The maximum deviation from the true diameter was 0.03mm compared to the 0.17mm deviation found in the original FreeCAD output.  Setting a finer arc precision in bCNC creates more arcs and may reduce deviation even more.  My testing didn't explore this further.


  The image on the left is the bCNC editor displaying the results of arc fitting.  This 12 line block will replace the 77 line block created by FreeCad.  The 77 line block is listed directly above the expanded 12 line block.

 

Below is the exported file from bCNC is 21 lines replacing the original 105 line FreeCAD file.  Somehow the 5mm Z cut depth was lost,  possibly due to user error.

G17 G54 G40 G49 G80 G90
G21
G54
M5
M6 T1
G43 H1
M3 S0
G0 Z5.000
G0 Z3
G0 X15.705 Y15.705
G0 Z0
G2 X20.584 Y8.357 I-15.222568 J-15.40144 Z0 F400
G2 X21.695 Y-4.781 I-21.577207 J-8.440627 Z0
G2 X-1.383 Y-22.197 I-21.894967 J5.014727 Z0
G2 X-22.197 Y1.382 I1.67678 J22.456271 Z0
G2 X8.931 Y20.344 I22.263697 J-1.517216 Z0
G2 X15.705 Y15.705 I-8.605303 J-19.831003 Z0
G0 Z3
M05
G17 G54 G90 G80 G40
M2


 

On the left is FreeCAD g-code displayed in the bCNC editor.  The next block in the editor is the output of Linearize which broke the G2/G3 arcs into many straight segments.  Notice the block of linearized g-code is 1045 lines.  Click to enlarge the image.

 


   The image on the left shows the settings that created the large number of straight segments.

 


Linearize could be useful foe Easel users or others unable to use G2/G3 in the g-code.  ArcFit could be more universally useful.  For example g-code created using  files made in Inkscape from photo or pdf  are possible candidates.

 

 

 

 

   
   

No comments:

Post a Comment

Note: only a member of this blog may post a comment.