Generating the GCodes
Now it is time to prepare for CNC milling your PCB board. The main process consists of creating gerber files from the PCB design and loading these gerber files into Line Grinder to create the GCode. The GCode directly controls your CNC milling machine. Be aware that you need to manually modify the GCode to make it compatible with your own machine.
Step 1: Place origin and save gerber files in KiCad
When milling with a CNC milling machine you need to set the origin point of the milling head. This point is exactly at the (0,0,0) coordinate. You are far away from milling but the important thing is that the origin point on your PCB design will be at the same position of the origin point of the milling head. So the first step of the process should be defining the origin point in KiCad by clicking on the menu item shown in Figure 1. Then click on the point you wish to select as the origin point.
Now generate the gerber files using KiCad by clicking on the icon in Figure 2. A 'Plot' window opens. Please choose 'Gerber' and click 'Browse...' to select the destination folder for the gerber files. You also need to select the layers that are important for your gerber files. Layers are not important for generating CNC milling GCodes. Although it is important to know what type of layers are required on your PCB board. If you are ready click 'Plot' which creates the edge cut file (.gm1) then click 'Generate Drill File'. In the new window please click 'Drill file' which creates the drill files (.drl) for pin and NPTH holes.
Step 2: Download and start Line Grinder
Line Grinder is a GCode generator software which is recommended by our electronic engineers. Line Grinder accepts gm1 and drl files you created with KiCad in step 1. First you need to download Line Grinder from their official website found here. Choose the download link by selecting 'zipped_binaries' (Figure 3). After downloading and unzipping Line Grinder, you can instantly start using it.
Step 3: Configure Line Grinder settings
Your first step after starting Line Grinder should be setting the CNC milling features for both the drl (Figure 4) and gm1 files. Here you can set the output file extension which should be txt so you will be able to modify it for your own CNC milling machine in notepad. You can also set important features like XY feedrate, Z feedrate, Z clearance level and Z depth.
Step 4: Open the required files and generate the GCodes
If the settings are ready please jump to the 'Plot View' tab. Here you will be able to easily generate the gcodes following the 4 simple steps shown below in figure 5. You need to do these 4 steps three times. First do them with both drill files (.drl) for pin and NPTH holes then do them with the edge cut file (.gm1). In all three occasions the output will be a gcode saved in a txt file.
Step 5: Modify the generated GCodes as seen in the video
Please open your txt files in notepad and delete the beginning of the files. As shown at the end of the video, you need to delete the sentences between the brackets. Carefully seperate the GCode of hole drillings designed for different milling head diameters in different txt files so when milling with your machine you can manually switch milling heads between loading files to the machine. In the next tutorial you will learn how to use a CNC milling machine.
More information
- Generating the GCodes
- Drilling and cutting out your PCB board