Author Topic: Discussion of doing CAM for/in AngelCAD and similar tools  (Read 554 times)

WillAdams

  • Newbie
  • *
  • Posts: 11
    • View Profile
Here's my understanding of this, and some thoughts on the potential possibilities.

First, the typical approaches:

 - export an STL and process in a 3D CAM tool --- this works well for many 3D designs, but one is limited to the tooling supported by 3D CAM tools, and the precision allowed by a conversion to a tessellation of triangles and the CAM tool's analysis and parsing of the geometry and rendering tool movement around it

 - flatten the design and export a 2D file such as DXF or SVG and process in a traditional CAM tool (often 2.5D) --- one is limited to designs which can be represented as outlines, and to the capabilities of extant CAM tools

 - import the design into a 3D CAD tool (FreeCAD will for example import OpenSCAD files) --- this works within the limits of the CAD/CAM tools

 - import the presets and develop the design in a parallel programming tool --- worked out doing this using lualatex and METAPOST for last year's TUG conference: http://tug.org/TUGboat/tb40-2/tb125adams-3d.pdf

I have come up with some joinery designs which simply are not supported by typical workflows, so have been investigating and experimenting with creating 3D models in programmatic tools using subtractive methods which mimic tool movements --- this then allows exporting the tool movement model simulation as G-Code. The first prototype has been done in OpenSCAD, a relieved fingerjoint box:

Overview/discussion: https://community.carbide3d.com/t/doing-cam-in-openscad/25214

Photo showing proof of concept cut: https://community.carbide3d.com/t/design-into-3d-boxes-magazine-storage/16238/58

Currently looking into coding up a suitable design and doing a customization tool (supporting something like to the Customizer in Thingiverse/OpenSCAD would be a welcome feature for AngelCAD).
« Last Edit: 2020-08-26, 07:06:34 by WillAdams »

Carsten Arnholm

  • Administrator
  • Newbie
  • *****
  • Posts: 49
    • View Profile
Re: Discussion of doing CAM for/in AngelCAD and similar tools
« Reply #1 on: 2020-08-26, 15:49:57 »
You raise many points Will, good stuff. I guess we can address them one by one.

Just to make a quick demo of simulated CNC simulation in AngelCAD, I threw together the following code. See attached image for what it looks like when run. Obviously, it is conceivable to use the same paths to generate CNC G-code

Code: [Select]
// AngelCAD code.
// Simulating CNC with AngelCAD

// signature of a function returning the path of a single character
funcdef array<pos2d@> letter_func(double height);

// the path for engraving the letter 'C'
array<pos2d@> letter_C(double height)
{
   array<pos2d@> path;
   for(double angle=PI/2; angle<3*PI/2; angle+=PI/18) {
      double x = 0.75*height*0.5*cos(angle);
      double y = height/2 + height*0.5*sin(angle);
      path.push_back(pos2d(x,y));
   }
   return path;
}

// the path for engraving the letter 'N'
array<pos2d@> letter_N(double height)
{
   array<pos2d@> path = {
        pos2d(0,0)
      , pos2d(0,height)
      , pos2d(0.75*height,0)
      , pos2d(0.75*height,height)
   };
   
   return path;
}

// function to create the solid for a single character
solid@ letter(letter_func@ f, double height)
{
   // we use a spherical engraving tool
   solid@ s = sphere(8);
   
   // get the 2d path and the start position
   array<pos2d@> path = f(height);
   pos2d@ p0 = path[0];

   // place the engraving tool in the start position
   solid@ tprev = translate(p0.x(),p0.y())*s;
   
   // 'body' will contain our letter
   solid@ body  = null;

   // traverse the path and build the whole letter body
   for(uint i=1; i<path.size(); i++) {
      pos2d@ p = path[i];
      solid@ t = translate(p.x(),p.y())*s;
     
      // create a straight segment using hull3d
      // from previous and current position bodies
      solid@ edge = hull3d(tprev,t);
     
      // update the previous body
      @tprev = t;

      // add current segment into body
      @body = (@body == null)? edge : body+edge;
   }
   
   // letter is complete
   return translate(0,height/2)*body;
}


shape@ main_shape()
{
   // create a metal work-piece
   double thickness = 30;
   solid@ metal_piece = translate(0,0,-thickness)*cuboid(dx:280,dy:180,dz:thickness);
   
   // define height/with of letters
   double h = 80;
   double w = h*0.75;
   
   // create the letter bodies
   solid@ C1 = translate(w,0)*letter(letter_C,height:h);
   double dx = w + C1.box().dx();
   solid@ N  = translate(dx,0)*letter(letter_N,height:h);
   dx += w + N.box().dx();
   solid@ C2 = translate(dx,0)*letter(letter_C,height:h);
   
   // engrave 'CNC' into the metal piece
   return metal_piece - (C1+N+C2);
}

void main()
{
   shape@ obj = main_shape();
   obj.write_xcsg(GetInputFullPath(),secant_tolerance:-1.0);
}
« Last Edit: 2020-08-26, 15:53:46 by Carsten Arnholm »

raymw

  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: Discussion of doing CAM for/in AngelCAD and similar tools
« Reply #2 on: 2020-08-26, 21:46:56 »
Hi Will, I see you took on board my suggestion of the sort of tool bit that would at least give you a fighting chance of making finger joints, without tool changing, moving work piece etc. If your carbide machine/whatever does not like the ball end, then you can get flat ended ones. If you want small, cheap and cheerful, then the single flute carbide pcb milling cutters will do. They may tend to burn the wood, and you'll need to take baby steps. As you need to bevel off the surface of the tongues, then the ball end will give a smother surface, but if you want dead smooth, then you'll need a number of passes, and as always it's a trade off. Luckily, if you're working in wood, it can need fewer passes than getting a smooth surface in metal.

Of course, if you want to adapt AngelCad, to be any real help, you'll have to pass additional information to the g-code generation, info. that is not encoded in the drawing. For example, in 2.5 d, dxf files, the dxf lines have direction, if you can actually specify that detail consistently in cad. But, then, if you are profiling, you need to go to the left of that line, by the radius of the tool, more or less, but if pocketing, you have to go to the right (or vice versa). Then you have to also remove the rest of the unwanted material. Generally, that is defined in the machine code. If you want that, then you'll have to invent special surfaces/whatever, to communicate that information from AngelCad, or hand craft it as is normally done. Either way, it is not going to happen by magic, and in reality, the actual cad drawing, whether using aurtocad, openscad, or AngelCad, is the trivial aspect. Alternatively, for thin wood, use a laser cutter, all that has to do is follow a path. (Or use a o.5mm carbide end mill).

One other thing, most CNC machines have G02 and GO3, I don't think that openscad or AngelCad generate smooth arcs, which may or may not be important to you. It will be a compromise. I think you could get good results by interpreting the xcsg file that Angellcad produces, directly into G-code, all the numbers are there.

Best wishes,

Ray

WillAdams

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Discussion of doing CAM for/in AngelCAD and similar tools
« Reply #3 on: 2020-08-27, 02:34:14 »
It's easy to make multiple passes by doing a loop.

Directionality is an interesting point --- will definitely be keeping it in mine.

Laser isn't an option for my workshop setup, and not wild about the machining time of a tiny endmill.

Being able to use G2 and G3 arcs in G-Code is a huge thing and one which I think will help surface finish quite a bit.

raymw

  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: Discussion of doing CAM for/in AngelCAD and similar tools
« Reply #4 on: 2020-08-27, 14:13:39 »
Going back to the tapered cutter with a ball end, what you can do, is treat it as a tapered cutter, for profiling, and a ball end for surfacing. I think I posted an image over on the openscad forum of the sort of carving it can do, the ball end is 0.25mm radius, and with a 0.35mm step-over, it is difficult to see the tool paths in the finished piece, certainly good enough for glued joints. It depends on the type of wood, and grain/tool path direction of course. What it means, for your finger type joints, is that you end up with 0.25mm radius corners internally, but on the tongue that fits, you can compensate by rounding one edge, the one that shows, possibly all the edges, with a number of passes . Since the edges of the cut will be tapered, you will end up with a sort of dovetail. It would be quite possible to make joints that could not be assembled, or ones with huge tapered gaps (maybe turn the gaps into features, and use wedges).

If you are only concerned with profiling sheet material, then knowing the taper of the tool, then it is a 2d drawing needed, the line being the tool path. The drawing for the two parts may be similar (assuming two parts fitted at  right angles using 'sort of' box joints). Then you need to bevel off the top of the fingers, to compensate for the slope of the back of the slot, hence the ball end, although fine passes of a sharp pointed tool may do. The quickest way would be to change the cutter, for one with a blunter V (i.e. if original cutter has a 10deg taper, - 5 deg each side of axis - the second cutter will need an 170 deg angle at the point. But if you are changing cutters, then get a pointed V cutter for the first one).  I am only considering using your carbide3d type router, without tool changing, replacing the sheet, whatever, by suggesting the V with ball end tool bit. It is purely a mental exercise, there being better methods of making this type of joint, using specialised jigs, etc., which is not your objective.

There are obvious constraints on what you are trying to do, and with constraints, you have to make compromises. From a cad drawing, i.e. a representation of an object given by 3d points, there has to be another communication method to pass the information that the cnc machine requires. If you restrict the material, and tool profiles, etc, then that amount of additional communication is reduced. The problem becomes much simpler, or at least you may quickly discover it is not solvable. What I'm trying to say, your machine most like can not machine 5 inch steel plate, but you could generate G-code to drive a machine that could, and with minor alterations, the same shape (albeit smaller, and in wood,) could be produced on your machine. The difference, other than in the machine, is all the extra stuff not communicated by the cad drawing.

The communication additions to any drawing that I am making, e.g. the ridgy ballend milled finish, is OK for me and my machine, but it maybe not what you want, but within the limits of your mill, it may be a compromise you have to make. It's all a rich playground!


WillAdams

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Discussion of doing CAM for/in AngelCAD and similar tools
« Reply #5 on: 2020-08-28, 15:33:18 »
I don't see how treating one tool in two different ways helps --- yes, using it differently at need works (and I've done that, using the ball-nosed in the kerfing test cut and the taper in the lid angle of the relieved finger joint).

I've tried a lot of different geometries for joinery, and suspect that there are many more --- we'll have to see.

I've never been good at compromises --- a tool should do what I want it to do, and if I can't reasonably make it do so, I'll find another tool, which is what has brought me here.

Finding the language really complex (never liked the whole void main int thing), but will hopefully manage a reasonable mapping between OpenSCAD and AngelCAD, then we'll look into writing out G-Code and working up a reasonable GUI.

raymw

  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: Discussion of doing CAM for/in AngelCAD and similar tools
« Reply #6 on: 2020-08-28, 19:02:45 »
Many milling tools are used in more than one way. A square ended mill, for example, is used for milling something flat, and the sides of said cutter for milling profiles., or all at once for making slots. That is not a compromise, it is using the tool as intended. If you are out on a limb, then perhaps you have  to design your own tool. All tools originated by someone solving a problem.

Unfortunately, Everything in engineering, and life in general, is a compromise, you've got to find the ones you're happy with, and work from there. I believe you are suffering from 'the not invented here syndrome', nothing being any use unless you've invented it, it fits exactly into your mind set. If the tool does not do what you want, then why mess around with the carbide3d? Get yourself some proper joinery machinery. If I wanted to make decent jointed boxes, that is possibly the compromise I would make, balancing time against cash and workshop space, whatever.

If you're accepting the compromise of shallow depth 3 axis machining, then the only way you can cut any surface, and undercut, on five sides at one hit is with a ball ended milling cutter (not a bull nosed but something like this http://cnc-plus.de/images/product_images/info_images/2974_2.jpg and then you live with a smoothish finish, but no sharp edges.to the bottom of any recesses. If you want undercutting then use a T slot cutter, or a dovetail cutter, or similar, but that is accepting the compromise that it will only give straight smooth edges, but at restricted angles. If you want square edges and corners, then the morticer is the tool to use. All the above  is accepting the compromise of not refixing the workpiece in some other orientation, or changing the tooling part way through the job.

It doesn't matter what fancy g-code/cad/cam/machine you use, at the end, it depends on the tool profile, its strength, etc. I'm not convinced you have specified what it is you are trying to achieve in enough detail for me to be able to offer much practical advice, except before getting bogged down in AngelCad/Openscad/whatever theory, I would suggest you get some bits of wood, and drive the router manually, to see if you can actually get the fit you want with the tooling that you have.

Why not start with something simple, let's say milling a 20mm cube? I guess your carbide3d machine can handle that. Making it from a 20mm thick piece of timber, clamped well out of the way of the area you are working on. What do you want to happen? Draw a 20mm cube in AngelCad, then generate the G-code somehow from that? Or, are you going to draw a 30mm cuboid, 20mm high, and let the 10mm cutter follow the path in the xy plain, and hope it can cope with a single 20mm depth of cut, or somehow 'it' will know that 20mm in z means 5 passes, say? Neither of these approaches is a Cad problem, it's not difficult to draw either size of cube/oid. OK, having decided that, how do you cope with a 20mm square hole (forget about the rounded corners), pocketing, say 10mm deep? Do you draw a cube 20mm square, knowing that the cutter has a square end - how is that be communicated between the cad and machine- or do you draw it as a 20mm cuboid, again 10mm deep, and communicate that it must cut on the inside of the line.

Many types of cnc machines rely on colour of line to define depth, laser cutters, switching from cut power to etching. There are plenty of cnc sort of raster programs, that can take a greyscale image, and machine to different depths depending on the shade of grey. Maybe, you could manually shade your pocketed regions - but that would not be automatic, unless you added some extra code to AngelCad, but you'd have to get used to the (void main int thing), and I feel your pain there XD

(one day, I'll write a short, non confrontational post.)

WillAdams

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Discussion of doing CAM for/in AngelCAD and similar tools
« Reply #7 on: 2020-08-28, 20:29:03 »
I've done plenty of 2.5D designs which are easily specified in traditional CAD/CAM tools:

https://cutrocket.com/u/WillAdams

Next up is creating designs which such tools don't allow, and doing joinery in new ways.

raymw

  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: Discussion of doing CAM for/in AngelCAD and similar tools
« Reply #8 on: 2020-08-29, 19:16:23 »
Having looked at a couple of simple shapes in csg format, that almost looks like G-code, but then G-code is more or less points in space. A square pocket is easier. If you need to know if a point is inside a boundary, then simply draw a line in any direction from the point, and if it crosses a boundary an odd number of times, it is outside, or an even number it is inside. You have to define how to handle the situation of a point being on a boundary. If it is a case of being happy with creating the cad by scripting, then perhaps it is simplest to generate a scripting language with inherent machine commands, so that as you draw the shape, it also writes the g-code. However many machine controllers, Fanuc, Seimens, Prototrac, (sp?) etc, more or less do that. The tool size and material requirements I would set initially, then after the principle was proved, add features as required. If you look at the resources that autodesk, for example, throw at their software, then in reality, you are unlikely to get near them, but no harm in trying, and as AngelCad, or openscad allows quick drawings of a certain type to be produced, then with restrictions, producing g-code at the same time should be possible. However if nobody else thinks it is worthwhile, then you'll have to learn coding yourself, openscad, and Angelcad are both opensource, and you are allowed to add/adjust/whatever, according to their agreements.

WillAdams

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Discussion of doing CAM for/in AngelCAD and similar tools
« Reply #9 on: 2020-08-30, 06:22:45 »
I like using BlockSCAD and OpenSCAD and (I hope) AngelCAD because the 3D Previewing affords an immediacy and feedback which I don't get when using other 3D programming tools --- feels reminiscent of using TeX --- make a change, compile, see the results of the change.

raymw

  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: Discussion of doing CAM for/in AngelCAD and similar tools
« Reply #10 on: 2020-09-05, 14:54:38 »

If we take a simple example to start with, the coupler, (the rendering of which I queried a few days ago),

Code: [Select]

// AngelCAD code.

shape@ main_shape()
{
   // create cube & sphere in default positions
   solid@ tube = cylinder(30,10);
   solid@ shank = cylinder(10,7.5);
   solid@ shaft = cylinder(30,4);
   solid@ fix = rotate_y(90)*cylinder(50,1);
//drill the two fixing holes straight through tube
   return tube-shank-shaft - translate(-20,0,4)*fix -translate(-20,0,22)*fix;
}

void main()
{
   shape@ obj = main_shape();
   obj.write_xcsg(GetInputFullPath(),secant_tolerance:.005);
}

 (you can tell I never removed all the 'new' Angelcad comments!)

from a machining point of view, a sort of p-code could be

profile circle, 30 deep, 20 diameter
bore in centre, 10 deep, 15 diameter
bore in centre, 30 deep, 8 diameter
rotate cylinder 90 degrees on  y axis
bore on centre line, 4  from end
bore on centre line, 22 from end

For many situations, machining consists of repeating standard procedures in different locations, orientation of work piece, and using different tools.

The above p-code could be readily translated into AngelCad script, and a library of functions could be developed. Knowing the size of the tool, and material type, etc., then the same p-code could generate the G-code too.

Instead of saving the AngelCad file, and  a separate g-code file, the g-code could be embedded as comments in the AngelCad file  e.g. all g-code comments begin with '//>> G01 x20.000 -y67.8765'  and then that can be run through a process that extracts all lines beginning with' //>>' and removes the '//>>' giving the g-code that you need. The actual method is unimportant, but with a consistent, well thought out structure that would possibly allow quick visualization via AngelCad, and produce the G-code file, too.

To start with, to see how extensible it can be, then I think I would standardize on a single sized tool, and a soft material. The machining would have to be limited to the movements available, e.g. rotate on y axis won't work on a usual 3 axis machine, unless manual intervention is employed. (but you'd have to do that anyway.) In such cases, issue a pause, and comment in the instruction within the g-code.



                                 

raymw

  • Newbie
  • *
  • Posts: 28
    • View Profile