CNC tool chain for PCBs, FlatCAM - Part 2 of 3
FlatCAM turns the Image and Drill files created by our CAD program, KiCad, into G-Code which is used to control the mill. This the trickiest part of the process. What you do here determines how the mill moves. It's important to have an understanding of the actual milling process and helpful to be able to visualize how the instructions generated here will translate into the motion of the tool head during milling.
There are 4 basic steps to this process:
You'll be repeating this for each of the layers and set of holes you want to mill. In our example, this will be done three times, once each for the bottom traces, the holes and the outer edge of the PCB.
Note that I'm doing single-sided boards here. FlatCAM does have a nice feature to facilitate making double-sided boards. I've used it and it works well. However, for a single sided board I find it simpler to just mirror everything. Also note that even when I do have to do double sided boards, if if the design supports it and I can keep the top layer to two or three traces I simply do a single sided board and run a jumper wire where necessary.
Import Gerber & Excellon files
Launch FlatCAM. Then, use the options under the File menu or the buttons on the toolbar to open the Gerber (.gbr) and Excellon (.drl) files you created with KiCad
Create geometry
Select the appropriate gerber file in Project tab. For our example we'll start with the bottom layer.
Next, select the Selected tab.
Here's an example of why you'll want to understand how the actual milling takes place. You'll notice the image you're seeing represents the bottom of the board as seen looking down onto it from the top. However, the board will be milled from the other side. If we were to cut this image onto a board, when we flipped it over, everything would be backward. To adjust for this we tell FlatCAM to flip the image over so we're viewing it from the same side which the tool head will be cutting. This is done by selecting 'Mirror: Axis: Y' and unselecting Center axis automatically. I don't let it center automatically because I've had issues with rounding errors which resulted in the middle being slightly off-center in layers which were not mirrored.
As this is a trace geometry, we want to set the Isolation Routing values. Don't worry about the other values here other than the mirroring as noted above. I'm using a 1/64" mill so I've set it to 0.016 inches.
Click Generate Geometry
Notice the options in the 'Selected' tab have changed and there is now a red outline showing the geometry to be milled. FlatCAM has also created an Isolation geometry file (.iso).
This is another point where it helps to understand some of the details of the milling process. The values entered here determine things like how quickly the mill moves the tool head, how deep to make the cut and how many passes it takes to get there. If you think about this, you can see there are many trade offs. For example, trying to move the tool head through the copper layer at 15 inches a minute will complete a cut more quickly than moving at 5 inches per minute. However it also also puts more strain on the tool and the spindle motor. It may also result in a ragged edge or a broken bit.
The values you see here have been working fine for my setup. They are:
- Cut Z : -0.01 # 1/100th of an inch deep
- Travel Z : 0.1 # When moving across the board to another cut, travel 1/10" above the surface
- Feed rate : 5 # When cutting move the tool head at 5" / min across the board
- Tool dia : 0.016 # 1/64 inch end mill (In reality, I use an engraving bit but this is close enough)
- Spindle speed : 10K # In reality I think my mill treats anything above 1024 as full speed
Set your values then click Generate.
The options in the 'Selected' tab have changed once again. FlatCAM has created a tool path (.cnc) file and path is now shown in blue and red.
Scroll down in the selected window and select Export G-Code to create the G code file.
You may want to come up with a naming convention that works for you. I like to use .nc where the nc stands for 'numerical control'. In this example ESP8266_bottom_64.nc refers to the bottom layer of the ESP8266 board. It expects to use a 1/64 mill and is a G-Code or 'numerical control' file.
You've just completed the 4 steps for the bottom layer. Repeat the process for the edge cuts and the drill file. Be aware there are some slight differences.
Edge cut (differences)
When creating the geometry for the edge cuts you'll be using the Board cutout: section. In this case I'm using a 1/16" (0.063") mill to cut the outline of the board. I've set the gap size to -0.1 as I use double sided carpet tape to secure my work piece and don't need tabs.
When creating the tool path, you'll want different settings as well. I've been using:
Cut Z : -0.062 # The full depth of the board
Tool dia : 0.063 # 1/16 inch
Multi-depth : [selected] # We make multiple passes
Depth/pass : 0.031 # each pass is 1/2 the depth of the board
Holes (differences)
I've been drilling everything with a 1/32" bit. Just select all holes you'll be drilling with that tool. Note I've unselected the 4 vias as I'm going to do these with jumpers on this board.
Cut Z : -0.062 # The full depth of the board
Feed Rate : 10.0 # We can drill much more quickly than we mill
Tool dia : 0.031 # 1/32"
Output from FlatCAM
At this point I now have an G-Code file for each layer:
- ESP8266_bottom_64.nc
- ESP8266_drill_32.nc
- ESP8266_edge_16.nc
Save the project
You can save all of your work as a project to simplify modifying any step at a later date.