Last year I decided to sell my metal lathe, a 40" gap-bed behemoth, and use the money to buy a Chinese CNC6040 router. I had the lathe for a long time and rarely used it, so the swap made sense to me.
Before I got my Chinese CNC6040 I had already made an attempt to build a 3d printer based on the SeeMeCNC H1. That printer sucked. I got it to print once, and it wasn't a very good print. I then spent about 4 years trying to tweak the printer to get it to print better before it started to fail all over the place. So when the CNC came in the door, the H1 got wholesale dumpped in a box on a shelf so that I could use the computer for the CNC.
Prior to getting the CNC, I already had some experience with Mach3 and setting up the hardware, but to be honest, gcode was still almost black magic to me. I just knew that when I ran my slicer, it spit out hundreds of lines of gcode, and I had no interest in trying to peel back the layers of how it worked since the gcode files were never the problem.
I was so excited to have my CNC that in the days leading up to its arrival, I began to realize that I needed a project to do when it arrived. I started searching for free software to help me out when I hit the first major road block: free CNC software SUCKS. I spent weeks trying to find, download and use software that could create gcode as easily as slicers create 3d prints. What I found was a bunch of software that was based on hacks that people had developed with little documentation (or documentation in foreign languages) and was only good for very specific things.
As I was searching, I was also trying to come up with a good starter project. I got the idea for a rocking horse because it seemed like a fun thing to give to my daughter and was well within the range of skills I had to make it even without a router. (but without the router I wouldn't have spent the time with a scroll saw to cut all the pieces out!).
Intro to Gcode
So after screwing around with dozens of crappy CNC packages, I finally decided to open pandora's box and find out how to write gcode from scratch. I did some google searching and started reading only to find that:
Gcode is stupid simple
Gcode boils down to commands that simply tell a machine where to move next, how to get there, and what it should do while it moves. There are also codes that tell the machine how to orient itself, and a few advanced codes that give built-in functionality such as drilling holes, or cutting to the left or right of a line.
For example, G00 moves the tool as fast as possible, G01 moves in a straight line at a specified speed, G02 and G03 will cut an arc from a center point. Specifying coordinates is as simple as typing the letter of the coordinate followed by the location or magnitude, and spaces are optional. So G00X0Y0Z0 will move the tool to 0,0,0 as fast as possible. You can insert spaces to make it easier to read: G00 X0 Y0 Z0 will yield the same result.
I think the reason that I got scared of Gcode was the shear quantity of lines that my 3d printer's slicer spit out. It makes sense now, as the slicer seemed to only use the straight line G01 command and if you want a circle, you have to tell the print head to move in very short straight lines to approximate a curve.
So I wrote my own
For the first set of rocking horse parts, I decided I would write my own gcode. I went back to my onshape models, and made sure that everything was done with either straight lines or circles. Then I created a drawing of each part, and with the knowledge of how I wanted the tool to cut it, I dimensioned each line and curve to give me the gcode coordinates. (these drawings can be viewed in the Onshape project).
I took those drawings, opened notepad, and started writing the code for the shape. I decided to try to cut the board in 3 passes, so I first plunged the cutter in the z, then pasted the shape code, plunge z, paste shape code, plunge z, paste shape code. Clunky, but it worked.
I then found out that you can use a simple program call and name subroutines. This let me have the shape code once, and call it every time i plunged the cutter. This shrunk the gcode file considerably, and turned it more into a program than simply a list of steps.
Mother nature is an Evil Teacher
When I got my machine I realized quickly that the difficult part of CNC machining is NOT the drafting, or the coding. I ran into the simplest of problems: there was no fixed location on the machine. With no homing switches there's no accurate starting location, and the tools were different lengths and don't have an index, so there's no way to know for sure where a new tool is even if you know where the old one was after a tool change.
Method of Manufacture
This was the single most important lesson after getting the machine: If I want to be able to make something I have to plan not just the gcode, but also how I will fixture the parts, where the home coordinate will be, and know how to set my tool length. There were a ton of variables to consider, but for the first set of parts I just wanted to cut wood!
Cutting Each Part (the Ugly Way)
So my machine had no homing, no tool setting, and no memory after I shut it off. The fastest path to a set of parts was to make every part start at 0,0,0. I would manually move the cutter head to the location on the piece of wood where the part would be cut, then holding a piece of paper under the tool, slowly lower it until the paper was touched. I would then tell Mach3 to reset 0,0,0 to that location and run the code. This enabled me to cut all the parts out, but I did have some issues. At one point I manually typed in a bad command before starting a cut and the cutter drilled a hole right in the center of the rocker bottom. I was able to live with the mistake, but it was a hard lesson. Another time, I mis-judged the length of material, and the cutter went right off the end of the board. I kept the piece, but it was about 1/4" shorter than planned...
It's Not Hard to Learn to CNC
But you're going to have to do a bit more thinking than your 3D printer requires. If you're getting into CNC routing or looking to buy one, do yourself a favor and write your first part cut in g-code. The lesson will set you up for lots of success later!
This post ended up a lot longer than I thought, so I'll put a few other learning experiences in another Phase 1 recap post later.