For the last few months I've been helping out with a side project to write a CAM workbench for FreeCAD. Being a not-very-good programmer, I've focused on cheer-leading, testing, and trying to stay out of the way. The project has come a long way, but it will still be a long time before the average user sees it. Still, it's a good time to start talking about the workbench, setting expectations, and encouraging folks to take a look.
Don't we already have open-source CAM tools? Why do we need another one?
A quick Google search or browsing through the LinuxCNC wiki would make you think the field is already crowded with alternatives. If you've actually tried to find a functional solution though, you probably already know the answer. Most of the projects out there are stale, offer limited utility, or are very specialized. A lot of them are completely dead. To be fair, some of the projects like BlenderCAM, HeeksCNC, and the Inkscape plugin gcodetools offer decent hobby-level functionality but there's nothing that competes with the commercial alternatives.
To be competitive, an open-source alternative really only needs two things (and time):
First, the application has to be user friendly:
- Cross Platform
- Integrated with CAD
- Reasonably Intuitive
Cross Platform means the application meets the user half way. Learning the application means the user will have to understand new concepts, watch tutorials, read manuals, and suffer through bugs. Asking them to change operating systems or compile from source is unreasonable. Integration with CAD doesn't mean the user should change his primary design tool but the line between CAD and CAM gets kinda fuzzy in practice. Visualizing your tool path as it relates to your base geometry and making minor tweaks to the design to get a usable path are common. Switching tools for minor adjustments is annoying and leads to errors.
The application doesn't have to be a marvel of form and function but it needs to have a reasonable UI. By this I mean that it should work for a hobbyist who needs to set up a simple CNC router job but provide capabilities for an experienced machinist to set up more complex jobs as well. (multiple fixtures, tool tables, and selection planes). It should let users customize their configuration so the output is predictable and works with their machines.
And, of course, it's got to be fast. 'nuff said.
Second, the project has to appeal to the developers:
- Reasonably easy to learn
- Great community
- Clear license policy
Plenty of digital ink has been spilled discussing what it takes to make a great open source project so I'm only talking about those things that I've personally seen kill open-source CAM projects.
The number of people in the world that have both programming skills and machine tools is pretty limited. For open source CAM to succeed, the developers who show up need to be able to get into the project easily and become productive. A great open source CAM project would have a great architecture, robust community, thorough documentation and large user base. It should be easy for a new developer to understand the landscape and figure out how to improve application -even a little bit- and then get their improvements adopted by the project.
I'm not sure anybody including lawyers actually like dealing with licenses but they're a reality we have to live with. If the license landscape isn't unambiguous, packaging and distribution of the application is a non-starter. If the license doesn't protect the developer contributions and make it easy to distribute, why bother?
The things I've listed aren't rocket science and they don't, by themselves, make a great application. But together they create an environment in which a great application can mature. Obviously I'm writing this because I think the FreeCAD Path project has this particular mix.
So where is the project now?
Rather than trying to provide all the functionality of a mature CAM application, Path will initially provide only the basics. In fact, the real focus will be on the underlying infrastructure.
Like other workbenches in FreeCAD, the low level stuff is programmed in C++ and the high level, user-facing, functionality is written in Python. The low-level stuff includes the data structures to represent a single move (command), a group of moves (path) and other structures for organizing projects. It handles representing those things on the screen and provides the interfaces to Python so they can be manipulated by the GUI and macros.
An import framework is provided so path information created externally can be loaded and rendered within FreeCAD. Likewise and export framework exists to get path data out in a usable form.
If importing and exporting were only provided through the compiled C++ application code, it would mean that FreeCAD's ability to read and write gcode would be fixed and difficult to adapt. So the import/export framework is exposed through a set of pre_ and post_ scripts written in Python. This means FreeCAD can play nice with all kinds of other applications. If you already have a program that generates gcode, you can import the code into FreeCAD. If your machine needs gcode in a unique dialect or modified some other way, you can tweak the export post_ script to get exactly the what you need.
This is pretty handy but most users will want to create gcode directly from the things they design in FreeCAD and this is where things get interesting. Experienced CAM users opening the workbench for the first time will be asking questions like, "How do I create a profile or pocket a feature?" CAM operations like this will be implemented as a Path-Python-Feature (PPF). A PPF is a python script that uses the FreeCAD API to generate the path data. Almost everything you will see in the workbench GUI represents a PPF. PPFs can have have icons and dialogs and integrate seamlessly into the workbench GUI and power users can study and extend their functionality.
Now is the time to set expectations. The initial set of PPFs will be limited. Users just looking for a functional CAM system might be disappointed. There will be pocketing, profiling, and drilling operations, but they will have plenty of bugs and missing features. Other kinds of operations, like 3D surfacing, will be missing altogether.
CAM users will also be looking for tools to organize operations into a complete project -- Sequencing, tool management, part nesting, etc. Early users of Path will see some of this but it too will be buggy and incomplete. Users should expect things to change a lot in the near future.
Because all of the PPFs, project structure, and pre/post processing is written in Python its pretty easy to experiment with and improve. No doubt, an active community will mature the operations quickly and add new ones as well.
Once Path is merged into the Master branch of the FreeCAD development repository, it will still be quite a while before end-users see it. Users running the development version will see it, of course, but it might be a year or more before Path makes its way into a stable version. By then, the functionality should be more mature and usable for real CNC projects.
For the last eighteen months I've been working with a group building a way for people with ideas to get things made by people with tools. Here's the big idea:
HeeksCNC can be finicky about profiles. Often I've found that a sketch which should be easily profiled won't generate any gcode at all. When I look in the console, I find an error like this
File "/usr/lib/heekscnc/kurve_funcs.py", line 247, in profileraise Exception, "couldn't offset kurve " + str(offset_curve)Exception: couldn't offset kurve <area.Curve object at 0xb6f4bf2c>
I got the chance to speak about FreeCAD at the Osmoces event near Chicago over the weekend. I had a really good time seeing some of the other presentations and exhibits and just hanging around with some pretty cool people. In addition to the talk, I also taught a workshop where we got hands-on with the software and modeled a simple part.
One theme in my presentation was that this stuff is really hard. It's hard to learn, hard to use, and mistakes have real consequences. This isn't just true of FreeCAD but of any CAD or modeling software. This fact was reinforced for me personally in the workshop where I saw frustration and confusion first hand.
Even though students struggled at first with the interface and the general concepts, most were able to make a lot of progress and judging by the number of students who stayed late and asked about areas I hadn't even covered, the demand for powerful open source design tools is growing.
This was the second time I've taught FreeCAD to a group of new users and I'm starting to get a sense for where they get hung up. I'm hoping to teach this again so I can build on that knowledge and perhaps find better ways to explain the core concepts. If you have anecdotes about learning CAD or teaching it to greenhorns, I'd be interested in your comments.
If you're looking for my slides or notes, they can be found here.
This is still early but it's too cool not to share. Yorik has added a WebGL exporter to the FreeCAD arch module (but it seems to work everywhere in FreeCAD)
Open a model in FreeCAD and select the objects in the tree
Export the objects (File -> Export) and select WebGL
Save the file and open it in a browser: WebGL export (will open in a new window)
(The default view is zoomed up close but clicking and dragging with the mouse buttons will zoom/pan/rotate the object. There's still plenty to be done with materials and lighting but being able to share FreeCAD models through a browser is very cool.)
I'm going to build an enclosure for my CNC mill to keep coolant and chips from going all over the floor. It took about ten minutes to model the mill table in FreeCAD but modeling all the aluminum extrusions was looking like a lot of work. Fortunately it isn't necessary
More and more vendors are providing CAD data in their online catalog. As long as they provide data in one of the non-proprietary formats, it should import very nicely into FreeCAD.
McMaster-Carr's catalog is legendary and many of their products have CAD data associated. You can download in a bunch of different formats that are compatible with FreeCAD, HeeksCAD, or probably any other CAD system on the planet.
Just click on the part number . In the item detail pop-up there's a CAD link that will take you to a page where you can get 2D and 3D CAD models and also see some dimension data online.
Misumi's site is maybe even better. Misumi will custom cut aluminum extrusions without a setup fee. The nice thing is they also provide custom CAD data for the parts you specify. For example, if you want a 330 mm extrusion, they'll cut it, but you can also download a 330mm model to use in your design.
In the design at the top of the page, I used three different length pieces and played with them in FreeCAD to verify that things would line up on the table the way I wanted.
I wish all vendors provided this, along with detailed specs, schematics, and illustrated parts lists. If you know other noteworthy vendors, drop a comment.
I spent the Thanksgiving holiday at my brother's place. It was a very relaxing weekend spent eating too much and shooting stuff. (I'm not very into guns but this stuff is fun!)
My brother recently bought a jealousy inducing lathe like this:
This thing was barely out of the crate. The DRO hadn't even been installed yet and and he was just getting familiar with it. So, of course, we decided we needed to make something -- preferably a piece of high-precision technology.
Armed with a healthy disregard for prior planning, a can-do attitude, and the proper fluids:
we started making chips.
Two days (and late nights) later, the world's first tactical yo-yo. Heavy enough to take your head clean off.
The first field test was less than impressive
So, back to the drawing board:
In the end, the device functioned within specification. It's a bit heavy for normal use but there's plenty of material that can still be removed to improve it.
All joking aside, I really enjoyed this project. Too often we think through a project and, figuring that we could do it, we declare it done. Actually DOING it unearths all kinds of tricky problems but that's where real experience is developed. I know my meager skills on the lathe were improved greatly. And I had a blast.
My interests in CNC and machining developed over a period of years in a very organic way. I have no formal training in either engineering or manufacturing --my interests were born out of necessity. Learning that way is great if you have the time and patience. Sometimes, however, it's just frustrating. You find yourself struggling with something that should be easy and only later find out that all kinds of people have the same issue and either they know how to work around it or perhaps they just feel each other's pain. But you, the loner, are left banging your head against the wall feeling like an idiot.
Meet the Spider
This post is about a perennial problem that I've faced in lots of CNC projects. It's something newbies like me are going to see eventually so this post is for you. I don't know if this problem has a name so I call it the 'spider problem'. If you know anything about this or how other CAM packages address it, leave a comment.
The first time I saw it was when I was playing with the HeeksCNC zigzag operation. To mill the spider, a lot of material needs to be removed but there are some areas that are very small and require a small cutter to reach. And there lies the problem. If you use a big cutter to go fast, you can't get into all the nooks and crannies like the space between the legs. You end up with a tool path that looks like this:
If you choose a small cutter that can get in there, your step over and step-down values have to be small. The run-time on the job is going to be excessively long - really REALLY long.
Roughing and Finishing
The intuitive solution is to rough the spider out with the big cutter, then do a finishing pass with the small cutter. With a model that doesn't have all those tight corners, this works great. It's exactly the technique I used on this pinewood derby car.
But it doesn't work here. Finishing assumes that the roughing phase has left a small, roughly uniform amount of material all over the model. The finish pass doesn't limit step-down because it doesn't have to. Ideally you're already within one step-down distance of the model everywhere. Cutting our spider, we're within one-step-down everywhere except the small areas between the legs. There, the remaining material is 5, 10, or more step increments away -- we're still roughing in those areas.
Of course you can limit the step down value but now you're back to where you started. You're either spending a LOT of time milling air, or you're plunging your cutter and breaking it off.
The fundamental problem is that the CAM software doesn't know what material has been removed.
Manually controlling the boundaries.
The only other solution I've found, and one I use regularly, is to artificially limit the boundaries of the operation. This means creating some geometry -- a sketch -- to limit the work area of of a roughing operation. For instance, I could create a boundary sketch like this:
The resulting toolpath will focus on the problem areas. This works but it's a compromise. If the model is complicated with lots of small problem areas, it can be difficult or impossible to create the right kinds of boundaries. It's also manually intensive and, at least in my case, that means mistakes are likely.
Not just about 3D sculpting.
The example I've given might make it seem like this problem is only about milling 3D irregular models but it isn't. Imagine cutting a simple rectangular pocket. If the pocket is large, you'll want to use a big cutter to remove a lot of material but you'll have rounded corners with the radius of the cutter. If you use a small cutter to get in tighter, you'll either spend a lot of time milling or you'll have to add some artificial bounding geometry to keep your itty-bitty cutter working in the corner and not milling air that the big cutter already cleared. The problem is the same and the available solutions are the same too. All compromises.
What would a better solution look like?
A smarter CAM tool would remember where previous operations had sent the tool and avoid re-milling those areas in subsequent operations. The workflow I would like to see would look like this:
1) The user selects the model and creates a roughing operation, specifying the tool to use and the feeds and speeds. The boundaries of the model are used to determine the work envelope. The step-over and step-down could be suggested from the tool or overriden by the user.
2) The user selects the previous operation and creates a refinement operation. The user selects the tool, feeds,speeds, and step-overs just like above.
3) Optionally, additional refinements can be added with progressively smaller tools, each time, the refinement references the previous operation not the original model.
4) When the tool path is generated, the system first generates the roughing operation tool path. It then constructs a solid in memory using the bounds of the path - the area swept out be the tool. It performs a boolean operation comparing the new solid to the original model to see where material still remains to be cleared. The resulting area, or its perimeter at least, is used as the bounding box for the refinement operation.
5). The user selects the original model and adds a finishing operation, which works just like it does today.
I'm sure there's a lot I'm missing in this approach -- maybe even some legitimate reasons it won't work at all -- but I'm listening and willing to learn.
When I first started using HeeksCNC I was totally confused. It seemed overly complex. When I finally understood it, I realized what a great model it is. I still won't claim to be an expert but from my perspective it meets three really big objectives. One of these is compromised in every other solution I've seen:
1) It keeps the computationally intensive algorithms in C++ where they run fast. Other systems that are flexible and customizable are written in interpreted languages and that means they're slow for computationally intensive tasks. Generating a complex path can tax a processor and really needs to be fast.
2) It provides a scriptable interface in a friendly language (Python). No matter how good the developer was, there's no way he can anticipate every need. That's why we like applications like blender, inkscape, gimp, and FreeCAD. These apps assume that the user may want to extend the application. Making the tool path generation accessible through a scripting language unleashes a lot of power.
3) It allows customization for the machine specific output without recompiling. This is the Post-processor. Not all machines are created equal. Different capabilities and different controllers mean the final output must be tailored.
Dan Falck did a great write-up of how Python is used in HeeksCNC to generate tool paths using the C++ libraries. I hope a future CAM workbench for FreeCAD has a structure like this.