<< Click to Display Table of Contents >>

Navigation:  Bits and PCs Blog - 2025.12.06 >

Making a single-sided PCB using a cheap CNC 3018 router, or "How I wasted a week of my life"

Previous pageReturn to chapter overviewNext page

This is a beginner's article, a rambling monograph, which describes how to use a cheap CNC 3018 router to machine a single-sided PCB for a simple TTL to RS232 converter. The design (from PicProjects, see below) uses two transistors, instead of the usual MAX3232 chip.

Each step is outlined: the circuit and board layout with KiCad and generating the Gerber track, drill and cut-out files; creating the G-Code command files with FlatCAM; and using Candle to send the G-Codes to a cheap CNC 3018 router (running Grbl) to machine the printed circuit board (PCB). CNC means 'Computer Numerical Control'.

This article reveals the parts that are difficult to understand and points out the common mistakes (i.e. all the mistakes that I made). It does not go into too much detail on KiCad, but it gives a step-by-step description of how to use FlatCAM and Candle for the first time. To learn KiCad just watch some of the many tutorials on YouTube.

Since I'm not an expert on CNC machines, if anyone notices I've got something wrong please let me know on info@muman.ch

Matt's Tip: Be aware that designing and making PCBs yourself takes a lot of time and effort! It is much easier just to buy something that already works! But you don't have so much "fun".

cnc-3018-router

Here's the PDF manual for my cheap VEVOR CNC-3018 router kit (which seems to be exactly the same as the Genmitsu 3018 Pro and several other manufacturer's devices)...
vevor-3018-pro-instructions-v2.5.pdf

 

Preamble

In the early 1990s I designed the hardware and wrote the firmware for SAIA's second industrial terminal, the PCD7.D200. This superseded the original PCD7.D100 terminal from Gercom. The D200 had a 4-line by 20-character LCD display and a haptic keyboard with 20 keys. The hardware was almost the same my design for SAIA's PG1 hand-held "Debugging and Commissioning Unit". It used the NEC V25, one of the first microcontrollers, which had the internal architecture and instruction set of the original IBM PC. The firmware was written in C, with some Intel assembler for direct hardware access. The prototype firmware could be run directly on a PC within a small BIOS wrapper.

I saw two D100 and two D200 terminals for sale on an online marketplace, and bought them for a good price (because no other fule was interested in this heap of ancient junk). But these old terminals can still be useful as front panels for devices in workshops and industrial situations, such as motor controllers, ovens, kilns, greenhouse control systems, electric chairs, Frankenstein basement equipment, etc. Their keyboards are usable even if you are wearing heavy protective gloves, if you have extremely large fingers, or if you just prefer poking the keyboard with a long stick because it's connected to 500kV power supply.

These terminals communicate using the prehistoric RS232 standard, almost the very first serial communications standard, with ±12 volt TX and RX signals to indicate 1s and 0s. To connect between your microcontroller's TX/RX signals (TTL levels, 3.3V or 5V) and the RS232 terminal (±12V levels), you need a "TTL to RS232 logic converter". You would normally use a cheap off-the-shelf converter based on the MAX3232 chip. But I didn't have one, so I looked around for an alternative and found a brilliant circuit which uses just two transistors, deriving the 12V from the RS-232 signals of the terminal.

Having four terminals, I needed four converters. So I took the opportunity of dusting off my cheap CNC 3018 machine to try to make a few single-sided PCBs. Here is a step-by-step description of the procedure, so I won't forget it.

This article is aimed at beginners - maybe they won't make the same mistakes that I did! I broke 4 drill bits and wrote off two V-tip cutters during this learning procedure; I made one PCB which was a mirror image of what was needed (I forgot to flip it on the Y-axis); I cut off the edge of the copper ground plane, breaking several GND connections (this is important on a single-sided board); and I forgot to add the 'via' for the one track that was needed on the top side of the board (KiCad did not automatically warn me about that); etc...

 

SAIA's first industrial text terminal, the PCD7.D100, made by Gercom.

pcd7-d100

 

SAIA's second industrial terminal, the PCD7.D20x. I did the preliminary hardware design and wrote the firmware.

pcd7-d202

 

The PCD7.D202 PCB, featuring the innovative NEC V25, one of the first microcontrollers. The V25 had an architecture based on the IBM PC, with the same Intel machine code and low-level hardware, so you could run the same code on a PC inside a simple BIOS wrapper.

pcd7d202-pcb

For those who wear anoraks (or expensive Armani suits), these are the official manuals for these terminals. Here you can find the character sets and command sequences for display control and cursor positioning. Much of the text in the D202 manual was taken from my original design specifications.
26-738_DE_Handbuch_PCD7D100_01.pdf
26-753_EN_Manual_PCD7-D160-D170.pdf
26-746_EN_Manual_PCD7-D202_01.pdf

 

Alternatively, you can simply buy a fancy MAX3232 module for next to nothing...

max3232-modules

 

If you've forgotten all about the megalithic RS-232 protocol, this Wackypodia article is very good:
https://en.wikipedia.org/wiki/RS-232

 

Archaeological note: Here is my original prototype for a "Hand Held Programming Unit" from 1989, using the NEC V25 microcontroller. The first hand-held PC? This design was used for the D200 series.

pg1-1   pg1-2

 

 

The Project: A very simple 3.3V/5V logic to RS232 converter

I found this excellent circuit on the PicProjects website. It uses two transistors and derives the 12v power from the terminal's data line.

picprojects

http://picprojects.org.uk/projects/simpleSIO/ssio.htm

First, I made a prototype on a breadboard using cheap 2N3904 and 2N3906 transistors. It worked! You can see the circuit design below in the Draw the circuit section.

Next, I wrote drivers for the D100 and D200 terminals in C using the Arduino IDE, while watching the intellectual action movie "Blood and Guts 2" on YouTube, or was it "Things Exploding 2"?

Here's my Arduino Zero code for the terminals. But probably I'm the only person on the planet who wants to use one of these antiques. If you run it on a different Arduino model, you may need to change the serial port for talking to the terminals.

  PCD7D100.h

  PCD7D200.h

 

 

Making the single-sided PCB using a cheap CNC 3018 router

 

WARNING! This procedure is NOT suitable for making PCBs that use mains voltages. Mains voltage designs need a wide gap between the line voltages and anything else, at least 5mm or more with cuts in the board to improve isolation. The CNC machine can only cut narrow isolation tracks with widths less than 1mm. But I will add details of how to do this in the future...

 

I used several software applications to design, machine and test the board:

LTspice to simulate your circuit before you make it (but you can also do this with KiCad)
KiCad to draw the circuit and create the board layout
FlatCAM to convert KiCad's Gerber files to G-Code commands for the CNC router
Candle to send the G-Codes to the controller which runs Grbl
Arduino IDE to edit and download the test program into an Arduino Zero microcontroller
WaveForms for the Digilent Analog Discovery USB oscilloscope to test the hardware
 

You can download the free software from here:

https://www.analog.com/en/resources/design-tools-and-calculators/ltspice-simulator.html
https://www.kicad.org/
http://flatcam.org/
https://github.com/Denvi/Candle
https://github.com/gnea/grbl/wiki
https://www.arduino.cc/en/software
https://digilent.com/shop/out-of-the-box-solutions/

 

For those who have not given up yet, here is a summary of the laborious and error-prone procedure :-)

1.

Optional: Simulate the circuit (LTspice)

2.

Make and test a prototype on a breadboard, and optionally make a soldered prototype

3.

Draw the circuit with the PCB layout designer (KiCad)

4.

Select the components for the finished board, so the PCB layout software knows the size and shape of each component (KiCad)

5.

Create the PCB layout, the components and tracks must be positioned by hand (KiCad)

6.

Generate the Gerber machining file (.gbr) for the tracks and the Excellon file (.drl) for the drill holes (KiCad)

7.

Convert the machining files to G-Code command files which your CNC machine can understand (FlatCAM)
Create a 'cutout' G-Code command file so the router can cut out the PCB (FlatCAM)

8.

Run the three G-Code command files with the CNC controller software to make the PCB (Candle)

9.

If the machining worked (then you were very lucky), clean up the board and solder in the components.
If the machining failed, go back to step 7 and correct or adjust the values and re-create the G-Code files.
If you made a mistake with the procedure, go to step 9 and try it again.

10.

Test the board, using your embedded cranial functions

Each step is described in horrific detail below.

 

1. Optional: Simulate the circuit using LTspice

Before making a prototype, I always simulate some or all of the circuit using LTspice from Analog Devices. I'm still using LTspice because I've used it for many years so it's familiar and easy to use. There are several modern simulators which are more sophisticated, but they're complicated. KiCad, which is used to layout the board, also has a simulation feature based on ngspice, an open source simulator (menu 'Inspect / Simulator...') - but I haven't tried it yet.

The problem is that a KiCad circuit contains many parts that cannot be simulated, so you may need to draw two circuits. A simulatable circuit often contains items which are needed only for the simulation, they are not components, so the simulation design and the actual circuit design may be different. So using LTspice separately actually simplifies the procedure (for me).

The analogue/transistor/mosfet/opamp sections of the circuit should always be simulated. You can't simulate microcontrollers, but you can simulate the voltages and switching (not the data) of serial connections using a 'pulse voltage source'. As you may have guessed, there are many tutorials on YouTube about LTspice. The whole family can watch these entrancing videos, because they [usually] don't contain any swearing, violence or sex.

The designer of LTspice, Mike Engelhardt, has developed a new simulator called Qspice which you can also download for free, but the GUI is different and it's not so easy to use, so (for the moment) I still use LTspice.

 

FesZ Electronics - Excellent LTspice tutorials

To learn about LTspice, I recommend watching the YouTube video series by FesZ Electronics. He has many other videos which go into deep esoteric details of almost every aspect of electronic design. Note that the latest version of LTspice has a slightly different user interface, but I'm not using it much because the access to component libraries has some problems.
https://www.youtube.com/playlist?list=PLT84nve2j1g_wgGcm0Bv3K4RSl2Jdjsey
https://www.youtube.com/@FesZElectronics

 

2. Make and test a prototype on a breadboard, and optionally make a soldered prototype

It's a good idea to build and test the circuit (or independent parts of it) on a pluggable breadboard (2.54mm grid). This is because the hardware rarely behaves in exactly the same way as the simulation, and you will find design problems early.

For example:

Test what happens during power up/down because oscillators, opamps and switching circuits can behave in strange ways as the supply voltage is rising/falling.

Test the drift with temperature changes. Almost all components are affected by temperature changes.

Mosfets and IGBTs often warm up and/or overheat, so experiment with PWM on-times and heat sinks into a full load.

 

Note that breadboards don't work well with high frequency circuits because the breadboard introduces its own inductance, capacitance and crosstalk, which can interfere with the behaviour. You often get bad or intermittent plug connections too.

You may need to change some component values while you're testing the prototype. It's much easier to change them on a breadboard than if you have soldered them in.

With a breadboard you must use 'through-hole' components that have wires or legs. Unfortunately most modern chips are not available in dual-in-line (DIL) packages with legs - they are only available as SMD (surface mount devices). So you must solder them onto a 2.54mm DIL adapter board. You can hand solder chips down to SOIC or SOT sizes, but QFN, SSOP, TSOP and MSOP (etc) packages are too small for me. You can often buy ready-made DIL adapter boards containing these tiny chips.

Don't forget to mount a decoupling capacitor directly on the adapter board between the GND and +ve pins of the chip, usually 0.1uF.

Wikipedia has a great entry which describes all the chip sizes: https://en.wikipedia.org/wiki/List_of_integrated_circuit_packaging_types#PIN-PITCH

 

SOIC and SSOP chips on 2.54mm adaptors, with on-board decoupling capacitors. SSOP/SOP chips are a devil to solder by hand, but sometimes it works (don't try it with very expensive chips, it's upsetting when you mess it up).

dil-adaptors

 

In case you don't know what I mean by 'breadboard' (it has nothing to do with bread). I've already dismantled my TTL-RS232 breadboard circuit, so here's a 3.3V to 5V level shifter. With this I can connect cheap retro 5V LED displays, with a 5V SPI serial connection, to a 3.3V microcontroller without damaging it. The level shifter uses four SOT MOSFETs soldered onto a 2.54mm adaptor board.

level-shifter

 

For verifying the functionality of the prototype, I use a Digilent Analog Discovery 2  (now obsolete, but still great). This works with their excellent WaveForms software running on your laptop or PC. This software does everything you need - see below. The new Digilent Analog Discovery 3 has replaced the Discovery 2, but they both use the same WaveForms software.

https://digilent.com/reference/test-and-measurement/analog-discovery-3/start
https://digilent.com/reference/software/waveforms/waveforms-3/start
https://digilent.com/shop/analog-discovery-2-100ms-s-usb-oscilloscope-logic-analyzer-and-variable-power-supply
 

analog-discovery-2

 

Digilent's WaveForms software together with the Analog Discovery 2 or 3 provides an oscilloscope, signal generator, two variable power supplies (low current), voltmeter, logic analyser, pattern generator, data logger, spectrum analyser, protocol analyser (UART, SPI, I2C, CAN, AVR), curve tracer, etc. There are also several add-on modules: impedance analyzer, transistor tester, audio adapter, breadboards, etc.

Click to zoom

 

Once the breadboard circuit is working, I usually make a soldered prototype on a standard 2.54mm perforated board with copper pads on one side. For the connections I use old "wire wrap" wire with heatproof insulation (Kevlar, I think). This is easy to strip and the insulation does not melt easily, unlike PVC insulation. For opamp circuits I usually add a thick uninsulated copper ground wire first, and use approximate "star" wiring to keep ground connections to the chips roughly the same length. Keep the analogue (VCC) and digital (VDD) +ve supply wiring separate too.

The soldered prototype, messy, but it works...

ttl-rs232-prototype

 

3. Draw the circuit with the PCB layout designer (KiCad)

There are many free software packages you can use to draw a circuit and design the PCB layout. You can't import if from LTspice.

I use KiCad (currently version 8.0.5) because it's free and it does everything you need (and a lot of stuff you probably don't need) in a [reasonably] easy way. The new version of KiCad has spice simulator based on ngspice, an open source simulator, but I haven't tried it yet.

See 'Getting Started with KiCad':
https://docs.kicad.org/8.0/en/getting_started_in_kicad/getting_started_in_kicad.html

As usual, there are many tutorials about KiCad on YouTube, so you'll get the hang of it fast.

 

The circuit for the TTL-RS232 converter in KiCad:

Click to zoom

 

Here's a few additional tips:

When you draw the circuit, it's best to have the 'inputs' or the 'master' on the left, and the 'outputs' or 'slave' on the right, so control flow is from left to right, else it can be very confusing. Just as you normally have the +ve rail at the top and the GND at the bottom.

For pin header connectors, try to keep their orientation and position similar to the way they will be on the final PCB. This reduces the number of "wrong way up" connection errors which might destroy your hardware.

If using digital or analogue chips in your circuit, don't forget the decoupling capacitors between +ve VDD (digital supply) or VCC (analog supply) and GND on [almost] every chip, usually 0.1uF.

Update the component numbering, R1, R2 etc. as the last step. Do this with 'Tools / Annotate Schematic...'. I prefer incrementing top down and left to right, using the 'Sort symbols by Y position' option. I forgot to do that one for this little circuit. It's more important for large circuits because it helps to find a component quickly from its reference number.

If you add a 'pin header' or other connector, you can assign signal names by editing the symbol. Select the pin header in the circuit, right click and use 'Edit with Symbol Editor'. This edits a copy of the part which is stored in the project, it does not affect the symbol in the library.

 

kicad-4

 

I left the 'Electrical Type' as 'Passive' to keep things simple.

edit-with-symbol-editor

 

Additional notes relating to this project:

 

RXD (receive data) and TXD (transmit data) signal names

The labelling of these two signals always causes a huge amount of confusion and many errors. Manufacturers seem to have different conventions for naming these signals. Do you connect the TX output of your master to the TXD, or to the RXD, of the module or device? This gets even more confusing if you use the old DTE and DCE conventions (so we won't go there).

The D200 manual uses the names of what it should be connected to - I think that is wrong - RXD is actually transmit data (an output), and TXD is actually receive data (an input)!

The D100 manual uses the actual signal names - this is the preferred way - TXD is transmit data (output) and RXD is receive data (input).

I think you should always use names relative to the device they refer to. For example, the module's input data is always RXD and the output data is always TXD, as with the Arduino's naming of the TX and RX signals. This means that you must connect the TXD output to the RXD input, and the RXD input to the TXD output, as in the connection diagram below.

 

RTS (request to send) and CTS (clear to send) handshaking

Sometimes data is sent faster than the terminal can process it. In this case handshaking can be used to pause transmission. This done using the RTS/CTS signals (or you could send XON/XOFF characters instead). The master raises RTS (request to send) and waits until CTS (clear to send) is returned, then it can send the data. If the CTS signal is dropped by the terminal, the master pauses the transmission until it goes high again. For the SAIA D100 and D200 terminals handshaking does not seem to be needed, even at the fastest baud rates (9600 and 19200 baud respectively - rather slow really), so we can just jumper the CTS/RTS pins together at the terminal connector.

The only time handshaking is needed is for certain command sequences which take some time to execute. For example, 'clear display' may take several milliseconds. For these you can just insert a short delay after sending the command. The D200's 'Reset' command takes a couple of seconds, but you can 'poll' it after power-up or a reset and wait until it responds so you don't send data until the terminal is ready.

 

Connection diagram

For cables longer than a few tens of centimetres (depending on the magnetic field environment), use a screened cable and connect the terminal's PGND (chassis ground) to the cable's screen at one end only to prevent ground loops. The terminal should have a good ground connection to the screw terminal on its chassis, so connect the terminal's chassis ground to the screen. This is because the microcontroller might only be grounded through the USB cable to your PC.

The Arduino's GND is connected to the terminal's signal ground SGND.

Note that the TX outputs are always connected to the RX inputs.

 

rs232-adapter-connections

 

4. Select the components (the 'footprints') for the finished board (KiCad)

To create the PCB layout you must first choose the components to be used, so the software knows the precise dimensions of each part. KiCad calls these the 'footprints', but it's also for the 'Bill of Materials' parts list (BOM).

Because we're using a cheap CNC router, you should use through-hole components and DIL 2.54mm chips, as you did for the breadboard. You could use SMD passive components and SOIC and SOT chips - they don't need drill holes - but the track tolerances are very tight for a cheap CNC machine and soldering is difficult. SMD components must be mounted on the copper side of the single-sided board! For SOIC chips and SOT devices it may be better to mount them on 2.54mm DIL adapter boards as shown above and mount them on the top side.

If you're going to use a PCB manufacturer to make your boards (by sending them the double-sided Gerber and drill files), then you can use all SMD (surface mount) components so they don't have to drill so many holes (which saves you money). Some manufacturers have a "preferred components" list and it's always cheaper to use their preferred components. Before making your SMD layout, it is sometimes worth making your own board first using through-hole components, to iron out any unforeseen problems. After you've ordered a few hundred PCBs it's always annoying to find out that you made a silly mistake (never forget Murphy's Law).

Use 'Tools / Assign Footprints' to view all the component assignments, or you can right-click on the symbol and select the footprint from the 'Properties' window.

https://docs.kicad.org/master/it/eeschema/eeschema_assigning_footprints.html

Many of the component footprints are just generic components, they are not specific parts. If you're having your PCBs professionally made, they will use their preferred component (or whatever they have in stock) that matches the type or value. If you need a certain tolerance or specific part from a particular manufacturer, then you need to add additional fields to the 'Bill Of Materials' (BOM). For example, you may want to use '1% metal film' resistors instead of '5% carbon composite'. There are many articles about how to do this, for example:

https://rheingoldheavy.com/kicad-bom-management-part-1-detailed-components/

 

When using TO-92 transistors, always use the 'wide' version, so the pads are not too close together. For example, use 'Package_TO_SOT_THT:TO-92_Inline_Wide'. With a cheap CNC machine, 2.54mm (0.1inch) is about the closest you can go reliably because of the machining and hand soldering.

 

5. Create the PCB layout (KiCad)

Now you've selected all the footprints, you can open the 'PCB Editor'. At first, all the components are jammed together in seemingly random positions (but the positions may relate to the symbol numbering). You will need to move them about to optimise the connections. First drag-and-drop each component so they are well spaced out. Next, position the connectors and mounting holes where you want them. Then reposition the remaining components to give the minimum number of crossed 'rats nest' connections, taking into account heat sinks etc.

Remember that there will be a ground plane, so the GND connections do not need separate tracks.

Also select a wider track width, I use 1mm, and 2mm for power tracks, which is better for our less accurate CNC machine.

We're making only single-sided boards, so only the bottom side copper 'B.Cu' layer is present. You may need to use a few jumper wires on the top side in place of a top side copper layer, depending in the complexity of your circuit. This is easily done using 1mm 'Vias', and drilling the through-holes using the same 0.7mm drill as the component holes.

 

Track widths

Because our cheap CNC router is not so accurate, you must set a wider track width (say 1mm). Also define a larger Via size (1mm with a 0.7mm hole). You can do this directly from the PCB editor's tool bar using 'Track: Edit Pre-defined Sizes...' and 'Via: Edit Pre-defined Sizes...'. Or from the 'File / Board Setup...' menu command. The you can select the new Track and Via sizes from the toolbar selectors.

kicad-6

 

Add a new 'Pre-defined Size' for the Track and the Via with the '+' button...

(Here it says 0.6mm Tracks Width - but in the final version I used 1mm, which was more reliable.)

kicad-7

 

Then select the new Track and Via items in the toolbar selectors, so they are used by default:

kicad-8

 

Ground plane

All GND connections are connected via the ground plane, so you don't have to route these.

If you hide the GND ratsnest then it makes the routing easier, you won't route them them by mistake. Do this by right-clicking on any GND pad, and select 'Net Inspection Tools > Hide Net in Ratsnest'.

hide-net-in-ratsnest

Or you can hide it from the 'Appearance' window, 'Nets' tab.

appearance-tab

 

Stop Press! With a single sided board made on your CNC machine, you don't really need to define a ground plane. You can just assume that the remaining copper outside the tracks is the ground plane. After you create the Geometry in FlatCAM, you can 'Edit the geometry' and delete the isolation cuts around the grounded pins before you create the CNC object.

To add a ground plane, select the 'Add Filled Zone' tool fill-zone-tool

Click in the window and the 'Copper Zone Properties' window should appear. The copper zone will be on the back copper layer and it will be connected to GND, so select 'B.Cu' and connect it to the 'GND' net.

kicad-9

Now you can draw the GND plane rectangle to enclose all the components, according to the size of your board. Click for each corner. If you want a nice square plane this is a bit messy - but you increase the 'Grid Size' to make it easier to draw. Make sure there's enough space at the edges to ensure the GND plane is connected all the way round when the board is cut out. (I made that mistake.)

Now use the 'Edit / Fill All Zones' command to create the GND plane. You'll need to re-do this command after adding new tracks.

While routing, it's best to hide the ground plane until the routing is finished, using 'Edit / Unfill All Zones'.

After routing all the tracks, you may find there is an island which is not connected to GND. You may not see the unconnected ratsnest wire, but the 'Design Rules Checker' should find it - see the 'Unconnected Items' tab. If this happens, you must add a 'Via' to connect the island to the GND plane with a wire on the component side of the board.

 

Edge cut layer

To cut out the board, KiCad expects an 'Edge cut' layer, but I didn't use that feature. I find it easier to do the board cut-out using FlatCAM's 'Cutout PCB' tool, as described below.

But you can define an edge cut layer in KiCad, and use that to define your cut-out in FlatCAM.

 

Mounting holes

Our little board did not need mounting holes because it can be "mounted" via the two pin header connectors, either by direct soldering or by plugging it into female pin header sockets. I often use sockets because it creates a modular design which allows you to plug in a different boards without changing the rest of the circuit - you may want to upgrade it to a fancy new MAX3232 board. To create mounting holes, you must add 'Mounting Hole' components to the schematic, then they will appear on the PCB layout and can be positioned in the same way as the other components. See the Universal Motor Controller prototype for an example of a modular design, each function is on a separate board which plugs on to the base board which contains the connectors and relays.

 

Don't forget, this is a view from the top, so you must flip it on the Y-axis to cut the board from the bottom copper side before you make the G-Code files! Do this with FlatCAM in Step 7.

Click me to zoom

 

Hide the GND ratsnest, because that will be connected via the GND plane. You don't need to route the GND signals. See above.

If you are using SMD devices, these need to be put on the back copper layer. But the pads may be too close together for this cheap CNC machine.

 

6. Generate the Gerber and Drill files (KiCad)

After creating the PCB layout, before you create the 'Fabrication Output', you should check for errors else KiCad may not tell you something is wrong. Run the 'Design Rules Checker' from the 'PCB Editor'.

For my board I have 8 Violations. 'Board has malformed outline' is because I have not added an Edge.Cuts layer - we will defined the edge cuts when we create the G-Code files with FlatCAM. The 'Silkscreen Overlap' warnings can be ignored too because we're not doing a silkscreen layer (you only need that if your PCB is being made for you).

Note that there's a separate 'Unconnected Items' tab, which is easy to miss. Naturally, I missed it. Check that you don't have any unconnected items.

kicad-5

 

Once you have laid out the PCB, you need to create the Gerber (.gbr) and Drill files (.drl). This is on the 'File / Fabrication Outputs >' menu.

kicad-2

 

You can just open the 'Gerbers (.gbr)' menu entry and also do the 'Drill files (.drl)' from there using the 'Generate Drill files...' button on the bottom right.

For the Gerber file, you only need to do the 'B.Cu' layer, so you can un-check all the others in the 'Include Layers' list.

Pressing 'Plot' creates the file. On a large display you may not see anything in the 'Output Messages' window unless you enlarge the dialog box.

kicad-3

 

By default, two drill files are created, the .NPTH file (Not Plated Through Hole) and the .PTH file (Plated Through Hole).

If you have added Mounting Holes to your board, these are found in the NPTH file. They are not in the PTH file, so they don't get drilled with the other holes when you process the PTH file, and you'd have to do two separate CNC runs. If you don't want to do this, you can merge the PTH and NPTH files into a single file by using the checkbox highlighted below. I use the same sized drill for all the holes, and then re-drill the mounting holes with a larger bit later, using the smaller hole as the centre.

kicad-3a

 

 

Here is the finished KiCad project, which may save you some time.
ttl-rs232-adaptor-1.zip

 

7. Create the G-Code command files for CNC machine control (FlatCAM)

The Gerber (.gbr) and Drill (.drl) files can't be used directly by the CNC machine. These need to be converted to G-Code command files first. It is the G-Codes that are sent to the CNC machine to control the stepper motors and the spindle. The G-Code commands are dependent on your CNC machine's features, which router bits you will be using, and on the cut depths and widths that you want to have. All these details need to be entered into the software so you can generate the G-Code files.

To do this, we use FlatCAM: http://flatcam.org/

You can download it from here: https://bitbucket.org/jpcgt/flatcam/downloads/   (I used version 8.994 BETA)

FlatCAM is an open-source program for preparing CNC jobs to make PCBs on a CNC router. Among other things, it can take a Gerber file generated by your favourite PCB CAD program and create G-Code for 'Isolation routing'.
http://flatcam.org/manual/introduction.html

Here you can find excellent detailed descriptions of the G-codes
https://linuxcnc.org/docs/html/gcode.html

 

FlatCAM uses a concept of 'Geometry' and 'CNC Jobs'. First you create the Geometry of the action, which shows where the cuts will be made. For than you save the 'CNC Job' files containing the G-Code commands for the router.

Be aware that FlatCAM does not have an undo feature. Each time you generate a new 'Geometry' or 'CNC Job', it puts a new entry in the Project tree. You can select this entry to get back to where you were before - that's the 'Undo'. You can delete those that you don't need (which is usually most of them).

FlatCAM is not perfect at associating a directory (folder) name with a project. When saving a file, ALWAYS check that the correct directory is selected - it may be for a previous project and you can get very mixed up! (I made that mistake, of course.)

Making a PCB is not something you do every day. It's a complex process complex software and many steps. It's very easy to forget a step, forget to set a value, forget to click on a checkbox, or to set a value incorrectly. If you make even one mistake, it can write off the entire job and probably damage your expensive router bit too. Using FlatCAM for the first time is tough, and I didn't find any really good YouTube tutorials (nobody else understands it very well either).

So for these reasons I'll give a detailed explanation of the steps I took...

 

CNC router bits

We need three different router bits to make the PCB. The first cuts the tracks, the second drills the holes and the third cuts out the board. Each drill is controlled by its own G-Code command file which will be created in this step. These bits can be expensive, so you don't want to break them! I bought a lot of them on Temu for a good price, so I should be OK for a few months.

router-bits-1

1)  V-tip

Ideally 0.1mm 30°, 40° or 45° tip, for milling the tracks. It has a fine point which cuts a V-shaped groove and so must make several overlapped passes to isolate the tracks. The cutting depth defines the effective tool width. I used a 45° tip.

2)  Corn cob

0.7mm, for drilling the holes. All holes will be the same size to save changing the bits. You may need to enlarge some holes manually depending on your components. For example, TO-220 parts need 0.8mm, screw terminals need 1mm, and the mounting holes may be 2 or 3mm.

3)  End mill

2 to 3mm up-cut type (clears debris upwards), to cut out the board. This is a wide robust cutter, it won't break too easily.

 

Stop Press! After some further experimentation, I found that you can make this board with one 0.7mm 'corn cob' bit. This single bit can cut the tracks, drill the holes and cut out the board. I'll update the description for this when I've got time!
This saves changing the bits and makes the whole procedure much quicker and much safer. But it only works for boards with no distances less than 0.7mm, no DIL chips.

 

Here's a summary of the procedure. Each step is described in hideous detail below.

7.1

Open the Gerber (.gbr) and Excellon Drill (.drl) files which you made with KiCad in Step 6.

7.2

Flip the board on its Y axis, because the copper is cut from the underside and the .gbr and .drl files are views from the top.

7.3

Set the (0,0) origin (the starting point) on FlatCAM's view.

Now you must configure the job according to the router bits you will use.

7.4

Configure the copper 'Isolation Routing' for the .gbr file.

7.5

Configure the hole drilling for the .drl file.

7.6

Create a 'PCB cutout' to cut out the board.

7.7

Save the project.

 

7.1   Open the Gerber (.gbr) and Drill (.drl) files

Start FlatCAM. It starts with an empty unnamed project.

Do 'File / Open > Open Gerber (.grb)' (or press the 1st toolbar button) and choose the '.grb' file you created in Step 6. This should have the name "name-B_cu.gbr". FlatCam's view will show the board's copper tracks in green.

flatcam-1

 

Do 'File / Open > Open Excellon...' (or press the 2nd toolbar button) and choose the '.drl' file you create in Step 6. Open the file with the name "name-PTH.drl" (PTH = plated through hole). There may also be a "name-NPTH.drl" file (NPTH = not plated through hole), you only need that one for the mounting holes. Or you may have merged the PTH and NPTH files into one 'name.drl' file.

 

Now you should see both the copper tracks in green and the drill holes in red. The two smaller red dots are the 'Via' holes. I think I left these as the default size, which is why they are small. But that won't matter because we'll use the same 0.7mm drill for all the holes.

You will also see the two files in the Project tree on the left.

flatcam-2

 

7.2   Flip the board on its Y axis - THIS IS VERY IMPORTANT!

You must do this because the copper is cut from the underside and the .gbr and .drl files are top side views, and you don't want to cut a mirror image. There are many ways to do this, but the 'Flip On Y Axis' command is the simplest.

Do 'Edit / Select All' (or press Ctrl+A). The copper and drill holes will be selected.

After 'Select All', you may be surprised to find that everything is shown 'selected'. The blue rectangles mark the edges of each section, the B.Cu layer, and the drilling area (but you can ignore those).

flatcam-2a

 

Now do 'Options / Flip on Y Axis'.

The board is now the view from the underside...

flatcam-3

 

7.3   Set the (0,0) origin (the starting point) on FlatCAM's view

Do 'Edit / Set Origin' (or press the 'Set Origin' toolbar button) and move the cursor with the red cross cursor to the grid intersection closest to the bottom left of the copper area, and click once.

The zero-origin (0, 0) is now set, indicated by the red lines.

flatcam-4

 

7.4   Configure the copper 'Isolation Routing' from the .gbr file

Double-click on the 'name-B_Cu.gbr' file in the Project tab on the left. The Properties tab should open, showing the Gerber Object properties.

flatcam-5

 

Click the 'Isolation Routing' button. This opens the 'Isolation Tool' tab. (Should be the 'Isolation Routing Tool'?)

You should see one default tool configured in the 'Tools Table'. Make sure you have the tool type 'V' selected in the 'TT' column. (Here you can select C1..C4=circular with 1..4 teeth, B=ball and V=tip angle types, but we'll use the 'V' for the tracks). You can hover over the 'TT' header to see a pop-up description. Hover over any text in this window to get a popup description - this is a very handy feature.

We will only use one tool for the copper.

flatcam-6

 

Now we need to configure the V-tip bit. (We won't use the 'Add From DB' feature because we haven't created a tool database yet.)

The V-tip bit has a 30° or 45° angle, so we will get a different width of cut depending on the depth of the cut. We need to calculate the width of the cut according to the depth of cut and the thickness of the copper layer.

v-groove-bit
(Picture courteously appropriated from the HobbyCNC website)

 

To do this, FlatCAM has a handy calculator. Do 'Tool / Calculators'. This opens the 'Calc. Tool' tab. Here you will see the 'V-Shape Tool Calculator'.

 

Set the parameters according to your bit. For mine, the 'Tip Diameter' is 0.1mm, the angle is 45, and we want a cut depth of 0.07mm which is double the thickness of the copper on the board (35 µmCu coating).

When you enter the values it automatically updates the 'Tool Diameter' result, 0.1580. You don't need to press the 'Calculate' button?

Copy the 'Tool Diameter' value to the clipboard, or store it in your internal memory unit, or write it down.

Enter this value into the 'Tools Table' 'Tools Diameter' column on the 'Isolation Tools' tab.

For the V-tip bits, even a tiny amount of damage or wear can change it from having a nice sharp 0.1mm tip, to 0.2mm or worse, so the calculation will be incorrect. But with practice, maybe you can take this into account when you configure the tool's width. Further experiments are needed...

flatcam-7a

 

To get back to the 'Isolation Tool' tab, you have to go back to the 'Properties' tab and press the 'Isolation Routing' button again. This gets you back to tab we had before, but if you had entered any data here, it is lost.

 

Fill in the V-tip tool's cutting diameter in the tool's 'Diameter' column. Double-click in the 'Diameter' field which contains the default '0.1' value (single-click does not work), and enter the 0.158 value we got from the calculator.

So the V-tip cut has a width of 0.158mm. This is not wide enough for the isolation cut of the tracks on the board. So you need to make several passes to get the right width. The number of passes and the overlap for each pass must be configured. Do this in the 'Parameters for Tool 1' section.

You can experiment with different values here. I found that 3 passes with a 35% overlap worked well.

Check 'Combine' in the 'Common Parameters' section. This combines the three V-tip passes into one 'geometry object' - one G-Code file - so you don't have to run three G-Code files on the CNC machine.

flatcam-9

 

Now press the 'Generate Geometry' button. This opens the 'Geometry Object' window for the isolation cuts.

Default values are shown of the 'Parameters for Tool 1'. You will need to modify them...

flatcam-9a

 

Set these values:

V-Tip Dia

The actual tip diameter of your bit, 0.1mm.

V-Tip Angle

The bit's angle, set this to 30/40/45 etc.

Cut-Z

This is the depth of cut, a negative value. It should be just over the thickness of the copper. Editing will be disabled for a V-bit. The value is calculated for you from the Dia you entered in the Tools Table, and the actual V-Tip Dia and V-Tip Angle. It should be the same as the Cut-Z value you entered in the V-Shape Tool Calculator earlier.

Travel Z

This is the height the bit will be moved vertically when it moves to the next position. It must not touch the surface of the board, so 2mm is fine. If you make this larger it just slows down the procedure.

Feedrate X-Y

This is the speed the tool will move while it's cutting. If you make this too fast you will get a ragged cut and may damage the bit. Slow speeds are better, but it takes longer if it moves slowly. It is measured in 'units per minute', which depends on the settings of your CNC machine. 120 seemes to be ok.

Feedrate Z

This is the speed of the vertical movement. I left it at 60. Note that the pop-up comment seems to be wrong here.

Spindle speed

This should be your spindle's fastest setting. For my machine it's 1000.

End move Z

When the job is finished, this is the vertical height the tool will be moved to so you can change the bit for the following drilling procedure. I set it to 20mm. It needs to be high enough to remove the bit and insert the drill. But this value must not move the spindle beyond the upper end stop or you'll be in trouble if your CNC machine has no end-stop switches.

 

Now scroll down and press the 'Generate CNC Object' button. This creates the 'Geometry object' which defines the geometry of the movements to be made, and the 'Properties' page changes again. You will see the cuts with the cutter widths shown in blue in the view. It also shows the spindle movements as yellow tracks.

But we still haven't created the G-Code file yet. To do this you must press the intuitively named 'Save CNC Code' button. This opens the 'Export Code' dialog box, where you can select a destination directory and a file name. The default G-Code file name is "name-B_Cu.gbr_iso_combined_cnc.nc". Save this in a new "flatcam" subdirectory.

WARNING: Check the directory name where the CNC file will be saved - this is often the wrong directory!

flatcam-11

 

Click on the 'Project' tab again. You will see that the 'Geometry Object' and the 'CNC Job' files that you have just created are shown in the tree. If you repeat these operations you will create additional files with an incrementing postfix number.

flatcam-12

 

7.5   Configure the hole drilling from the .drl file

In the 'Project' tab, double-click on the Excellon file "name-PTH.drl". This opens the 'Properties' tab for the  'Excellon Object'.

In the 'Tools Table' you will see several drill tools with different diameters. In this case you can see 0.3, 0.8 and 1.0mm drills, with 32 drill holes in all.

We are going to use just one 0.7mm drill for all the holes. I recommend you always use this sized drill, it works for most through-hole components. If not, it's very easy to make the hole a little bigger by drilling a bigger hole. Some components, like TO-220 parts need a 0.8mm hole, and screw terminal blocks need 1mm.

flatcam-13

 

Click on the 'Drilling Tool' button which opens the 'Drilling Tool' tab.

You can leave the 'Drilling Tool' list unchanged because we are going to use the same drill (0.7mm corn cob) for all the holes. There will be no drill changes during the procedure.

 

Make the following changes...

Cut Z

This is the depth of the cut from the zero Z position. It's always a NEGATIVE number. It should be a tiny bit beyond the thickness of your board. My board is 1.6mm thick, so I used -1.7mm.

Multi-depth

Uncheck this, we drill all the holes in one go with the same drill.

Travel Z

This is the height the spindle is raised above the board as it moves between holes. 2mm is fine.

Feedrate Z

This is the speed (in units per minute) that the drill is moved downwards while drilling. I set to to a slower rate, 120, so it does not rip up the copper.

Spindle speed

Set it to the fastest speed, 1000rpm.

Offset Z

Not used, make sure it's 0.0000.

Tool change

Unchecked, we won't do a tool change, all holes will be drilled with the same 0.7mm drill.

Tool change Z

Not used, but set it to 20mm anyway.

End move Z

Set this to 20mm. This is the height the bit will be moved to when it's finished drilling. By default, I get 0.5mm here - that is NOT high enough and it will break your drill! (again).

End move X,Y

Set to 'None'. The spindle can stay at the location of the last hole, but will be moved up by 'End Move Z' which is 20mm. You could set this to an X,Y position to move to at the end of the drill sequence, such as 0,0.

 

flatcam-14

 

Now scroll up and press the 'Generate CNC Object' button to create the G-Code file for the drill hole procedure.

 

flatcam-15

 

The drill movements can now be seen in the view as yellow tracks. The CNC Tools Table shows 0.3mm. You can ignore this because we'll fit a 0.7mm bit.

flatcam-16

 

Now press the 'Save CNC Code' button, to save the drill file as a G-Code file in the 'flatcam' subdirectory. This uses the file name "name-PTH.drl_cnc.nc".

 

Click on the 'Project' tab on the left. You will see the two CNC job files you have created.

flatcam-16a

 

7.6   Create a 'PCB cutout' to cut out the board

We didn't use KiCad's 'Edge Cut Layer' feature, so we need to create our own edge cut G-Code file. This is very easy to do with FlatCAM's 'Tool / Cutout PCB' command.

Do 'Tool / Cutout PCB', to open the 'Cutout PCB' tab. Here you can define the 'Cutout Tool' and its cutting path. Refer to http://flatcam.org/manual/cutout.html

Change the settings to these:

Source Object

Select the 'Single' and 'Gerber' radio buttons.

Tool Dia.

I used a 3mm end mill bit, but a 1.5 or 2mm bit will waste less board.

Cut Z

This is the total depth of the cut, a negative value because it's below the Z0 point. We're using a 1.6mm thick board, so set this to -1.7mm.

Multi-depth

Check this option. It allows multiple passes to be made, cutting this depth on each pass until the Cut Z depth is reached. Set it to 0.425mm (1.7mm / 4), which means it will make 4 passes.

Margin

This is the margin between the copper and the edge cut. 0.1mm is OK.

Gap size

1mm is sufficient. We will use a rectangular cut. Instead of cutting all the way around the board, it leaves part of the cut intact so it doesn't fall apart. This is the width of the section which will not be cut. You'll need to break this to remove the board, and sand the board edges to make it look pretty.

If the board is stuck to the bed with double sided tape, then the 'gap' is not so important.

Gap type

The gap type should be a 'Bridge'.

Gaps

It's a rectangle, so we need 4 gaps.

 

flatcam-17

 

We will generate 'Automatic Bridge Gaps', so press the '[] Generate Geometry' button to create a rectangular cutout. You will see the geometry outline of the cut as a red line.

flatcam-18

 

flatcam-19b

 

I expected this to open the 'Geometry Object' tab for the Cutout Tool, but it does not. So you have to select the 'Properties' tab.

flatcam-19a

 

Select the Tool Type as 'C2' in the TT column. This column is not properly visible due to GUI scaling problems on my high resolution monitor, but the drop-down list is ok. 'C2' means it is a 'Circular' drill with 2 teeth, but the number of teeth is not used, so any 'Cx' value will do.

Note! Changing the Tool Type (TT) sometimes changes the Cut Z value, so make sure it's still -1.7.

The remaining parameters are as you set them before. Spindle speed=1000, End move Z=20mm.

Scroll down again until you see the familiar 'Generate CNCJob Object' button and press it. This creates the CNC object, and the wide cuts the end mill bit will make are shown in blue.

flatcam-20

 

Now press 'Save CNC Code' to save the G-Code file. Save it as "name-B_Cu.gbr_cutout_cnc.nc" in the "flatcam" subdirectory.

Click on the 'Project' tab again, and you'll see the three CNC Job files that we have created.

flatcam-21

 

7.7   Save the project

It's finished, well done! Now you need to save the project because you'll probably have to come back a fix all the things you did wrong.

Do 'File / Save / Save Project As...' and save it in the "flatcam" subdirectory of your KiCad project. The default project file name contains the date and time, so you probably don't need to change it.

Once saved, you will see the project path in the title bar.

Now you can close FlatCAM.

 

Few! Next you can start the machining! (or go down the Pub for a breather)

But before you do that, check the directory you used for saving the G-Code files. Hopefully, you will see your project file ".FlatPrj" and the three ".nc" files...

flatcam-22

 

8. Run the three G-Code command files on the CNC machine to make the PCB (using Candle)

The CNC machine has a controller board with a USB interface (some have WiFi and/or Bluetooth too). The controller board usually runs a version of Grbl, which converts the G-Codes to stepper motor movements and controls for the spindle speed. To send the G-Codes to the controller board, the open-source Candle application is used.

Candle is a "GRBL controller application with G-Code visualizer": https://github.com/Denvi/Candle

I installed the version of Candle (1.2.15b) which was supplied with my CNC machine. There may be some mysterious default settings for Candle which would be incorrect if I installed a later version.

BUG: Candle will crash on systems with two displays
If you have two (or more) displays on your system, you should only run Candle on the primary display (or at least, only close Candle when it is displayed on the primary display). If you move it to the second display and close it there, you will never be able to open it again - it crashes! You can see the crashes in the Windows Event Viewer. But there's and easy way to recover - disconnect the primary screen and run Candle again, this forces it to open on the remaining display, which will now be your laptop or PC's primary display.

WARNING
The cheap CNC 3018 machines do not have limit switches. This means that some functions, like the 'Home' command WILL NOT WORK. In fact 'Home' may even damage your machine because the motors will not stop.

SainSmart has an excellent introduction to CNC 3018 machining. I recommend you read this first...
https://docs.sainsmart.com/article/imvlf0s7un-intro-to-cnc-for-a-total-novice

 

Here's an view of my CNC machine's controller board. Most of the new grbl-based 3018 controllers are very similar. It shows where to connect the Z-Probe described below.

The 'Power' switch on the centre left controls the power to the spindle and the motors. You can use this as an Emergency Stop because it will always stop the motors and spindle even if the controller has crashed. The microcontroller may be powered directly from the USB, so many things "seem to work" even with the Power switch in the OFF position (which is weird).

The red 'Reset' button on the bottom right resets the microcontroller and restarts Grbl. I think it does the same thing as Candle's 'Reset' button.

cnc-control-board-1

If you are interested how the controller board works, check out the open source Grbl code:
https://github.com/grbl/grbl

 

Preparation

Before you begin, you need to prepare your CNC machine for the job. Two things are important: a wooden baseboard so you don't cut into the aluminium X/Y bed (this helps to save tool bits too), and a 'Z-probe' for setting the Z-axis zero point and creating the 'heightmap' for each job.

 

Wooden baseboard

To protect the aluminium bed, a plywood off-cut, about 1cm thick, should be bolted to the bed using the screws and wing nuts that came with the kit. (I could have drilled the bolt holes a bit closer to the edge, but there's still plenty of room for the PCB.) The copper-coated board is stuck to the baseboard using strong double-sided tape (Tesa). Tape only in the area of the PCB that you will be cutting, to make it easier to un-stick it when you've finished.

If you put tape on the whole PCB it is very difficult to un-stick it without breaking it.

Here you can also see the fitted Z-probe.

cnc-base-plate

 

Z-Probe

The Z-probe (the red and brown wires in the picture above) is used for zeroing the vertical height (Z-axis) and for creating a 'height map' (see below). The two wires are connected to the 'Z Probe' pins on the controller board. One wire connects to the copper surface, the other wire ends with a crocodile clip that is clipped onto the spindle which holds the cutting bit. When the cutting bit touches the copper, it closes a circuit and the controller knows this is the exact Z-axis zero position.

Note that this only works reliably if you are using a sharp-pointed V-tip bit, other bits sometimes do not make a good connection with the copper due to dirt or the coating on the bit.

If the crocodile clip falls off during the process, you're stuffed! Be ready to power off the controller instantly if this happens, else something is going to break!

I usually just sticky-tape the GND wire to the copper as you can see in the picture above (if the copper is old, sand it a bit to get a good connection). These wires MUST make good connections, if they don't then the controller will not stop the motors and it will usually break your routing bit (naturally, I have done this several times). You can test the electrical connection with a voltmeter - put one meter probe on the copper and the other on the bit, you should see 3.3V or 5V if the connections are good, according to your controller board's voltage.

You can either make the Z-probe yourself with a couple of crocodile clips, or buy a ready-made probe. Some come with their own connecting pad fitted, so you don't need the connection to the copper plate (you just subtract the thickness of the plate from your Z-axis values).

The Z-probe pins will be marked on the controller board. If you make the probe yourself, you'll need a "2.54mm 2-pin female header connector" to plug onto these pins.

z-probe-1

Here is a good article by SainSmart about the Z-Probe. I used their 'Probe Command' (G91G21G38.2Z-50F100; G92 Z0; G0Z5M30) for my Candle configuration.
https://docs.sainsmart.com/article/yhgowhcb8x-what-is-a-z-probe-how-do-i-use-it

Here it is as a local PDF, in case the link above stops working:
Z-Probe-SainSmart-Resource-Center.pdf

 

Connect the CNC machine to your PC via the USB

Before opening Candle, connect your controller board and make sure it's visible in the Window's 'Device Manager' as a COM Port. With Windows 10 or 11 it should automatically install the driver. Otherwise you may need to install the driver that comes with your software, e.g. CH341SER.

NOTE! My controller board has a ON/OFF power switch which must be in the ON position for it to comminicate. But the USB data communications runs and LEDs flash even when it's in the OFF position and the board is powered off. Candle doesn't seem to detect any errors either, even though it's not working.

cnc-device-manager

If you haven't already done it, stick your single-sided copper board onto the wooden baseboard using double-sided tape (copper-side up ;-) You only need to put the tape below the area of the board you will be cutting. If you cover the whole back of the board then its very difficult to unstick it without breaking it. Before you stick it down, you may need to sand the baseboard a bit and dust it off to be sure it is as smooth as possible.

 

Now you can open Candle.

First open the 'Settings' window and select the connection to your CNC controller. Do 'Service / Settings' and choose the right port and baud rate to 115200. I'm not sure if the 'baud rate' makes any difference - it's a USB connection which can run a lot faster than that!

I changed a few other settings.

Set the 'Spindle speed max.' to 1000 (the maximum speed of my super-cheap spindle motor)

Set the 'Probe commands' to match the command recommended by SainSmart in the article linked to in the Z-Probe section above.
G91G21G38.2Z-50F100; G92 Z0; G0Z5M30

Click to zoom

 

Delete the 'Safe position commands'. This machine does not have end stop switches and it cannot go to the 'home' position.

Set the 'Button 1' User command to G0 X0 Y0. This will move the spindle to the X,Y zero position. You will use this before changing a bit.

candle-2b

 

The 'Tool model' is only for the 3D display. When using a V-tip bit, it's nice to have an image of a V-tip bit for the 3D viewer. Make sure the 'Tool Model' type is 'Conic', with a 15° angle so you see a nice point. By default, mine was set to 'Flat' which doesn't look right when you're using a V-tip.

candle-v-tip

 

candle-2a

 

Press 'OK'. Back to the main screen...

candle-3

 

If your controller is properly connected, the 'State' properties on the top right will show 'Idle' as the status of your controller, and all the coordinates will be 0s. It thinks your spindle is at position (0,0,0), which is probably wrong. Later, we will zero the positions correctly.

The controller board will (hopefully) have been configured for your CNC machine. The configuration parameters are stored in the controller. It's a good idea to make a copy of these values so you can restore them if necessary.

Only modify these parameters if you know what you're doing, because you can really mess things up. (Naturally, I really messed things up.)

In the 'Console' entry field, type the command '$$' and press the 'Send Command' button. This dumps the parameter list to the console. Copy/paste this list into a text file, and save it somewhere safe for future use.

Each parameter is $xx=value, where 'xx' is the parameter number. You can find descriptions of the Grbl 1.1 parameters here (and in many other places).
https://github.com/gnea/grbl/wiki/Grbl-v1.1-Configuration#grbl-settings
https://github.com/gnea/grbl/blob/master/doc/markdown/settings.md

If you do need to change a parameter, just type $xx=value in the Console entry field, e.g. $21=1. This stores the setting in EEPROM, so it's remembered forever. There is no Undo.

Expand this to see the factory Grbl 1.1 configuration of my VEVOR 3018

 

If this is the first time you've used Candle, familiarize yourself with the manual controls. Locate the 'Jog' section on the right. You may not see the 'Jog' section unless you scroll up.

Note the little '-' symbol in the top left of each section. Click on this to expand or collapse section so you can hide the parts you don't use, like the 'Overriding' section which we won't use.

 

The 'Jog' section allows you to manually position the spindle. It works in the same way as the 'Offline Controller' which you may have received with your machine.

offline-controller

 

Make sure you don't overrun any of the axes, because the cheap CNC machine does not have end stop/limit switches to turn off the motor when it gets to the end of travel. It is VERY EASY to break your tool bit by dragging it or pressing it too hard against the baseboard. (Naturally, that's exactly what happened to me the first time I tried it.)

In the 'Jog' section, press one of the blue buttons. The blue buttons control the X and Y axes. The spindle will move 'Step' millimetres at the 'Feed' speed.

The X-axis is left to right, the Y-axis is backwards and forwards, and the Z-axis is up and down.

You can move backwards ^, forwards V, left < or right >. The middle button is 'Stop'.

The two grey up/down buttons on the right control the Z-axis, intuitively up ^ and down V.

Play with this for a while to get the hang of it - without a cutting bit fitted, so you won't break anything.

candle-4

 

The distance moved on each step is set by the 'Step' value, in mm. For precision control you can set this to a very small value down to 0.01mm.

The 'Feed' value is the speed it moves at, 10..2000 'units per minute'. 100 or 500 seems to be ok. The 'units per minute' value relates to the capabilities of your CNC machine.

 

Error recovery

You should know what to do if something goes wrong. When Candle detects an error from the controller while executing the G-Codes, it will display an error message and abort. This locks Candle so nothing else can be done until the 'Unlock' button is pressed. You should also press 'Reset' to reset the error in the controller. But you usually have to restart your job again from the beginning, see Pausing and resuming a job.

The error message may show you an informative GRBL error number, and you'll need to look up what it means...
https://docs.sainsmart.com/article/dm4jbd5jce-grbl-error-codes
https://www.sainsmart.com/blogs/news/grbl-v1-1-quick-reference

 

Running a job without a tool bit fitted

If it's your first time, it's a good idea to run the job without a cutting bit fitted and without a copper board, so you can see what happens without any risks.

If a bit is in the chuck, remove it. Using the manual positioning knobs, make sure the spindle is in the center of the bed and about 40mm above it, leaving at least 20mm of vertical travel for the spindle.

Do 'File /Open' and open the first isolation cut G-code file, "name-B_Cu.gbr_iso_combined_cnc.nc".

candle-5

 

Press 'Send'. You will probably get an immediate error message, "M6 error 20". This is not serious - it just means that the M6 command (bit change) was not accepted. GRBL does not handle this command. Press 'Ignorieren' (or whatever it says in your language) to continue.

The job continues, moving the spindle to the X0 Y0 position. If it pauses there, just press 'Pause' again to continue.

The cutter should now make many passes to cut out the tracks - but since you don't have a bit fitted, it would be doing anything. Press 'Abort' to stop the process.

You can also run it with your controller's power switch in the OFF position. Everything goes ahead as normal, but the motors and spindle are not moving. (I would expect an error message in this case, but what do I know.)

 

Setting the X,Y and Z-axis zero positions

Once you have stuck the copper-clad board to the wooden baseboard with double-sided tape, then you can set the X/Y zero position and calibrate the vertical Z-axis. The Z-axis zero point is normally set with the Z-probe, but you can also do it manually if the vertical tolerance is not too important (e.g. if you are drilling or cutting right through the PCB).

Insert the V-tip bit into the chuck and tighten it up carefully.

Using the Jog controls, or the manual positioning knobs on the CNC machine, move the cutter until it is in the exact position you want to use as X,Y 0,0. This should normally be the bottom left hand corner of the PCB. This is the (0,0) origin that you set in FlatCAM. Remember that you will cut out the board using a 3mm cutter, so position it about 5mm from the bottom corner of the board. But it doesn't matter if the 3mm cutter overlaps the edge of the board a little bit, so anything between 1 and 5mm is fine.

Use the manual spindle height positioning nob to move the V-tip bit downwards until it's quite close to the copper surface, so you can see where the bit will touch the copper. Don't use the Jog control for this because it may overshoot and damage your tool (which can be very painful).

Once it's at the X0 Y0 origin point, press the 'Zero XY' button to set the X/Y position. This does not affect the vertical Z-axis zero position.

zero-xy-button  Zero the X/Y axis

 

Now you can connect and check the Z-probe, as described above. Once you're sure the Z-probe is working, press the 'Z-probe' button. Be ready to hit the 'Reset' button if it doesn't stop, else you will damage the tool bit!

z-probe-button  Start the Z-probe to zero the Z-axis
candle-reset  This is the 'Reset' button, press it if the Z-probe does not stop!!!

 

The spindle will move down until the tip of the V-tip bit touches the copper layer and completes the circuit. This sets the Z-axis zero point. The bit moves up again and back down slowly until it's exactly at the Z-axis zero point. Depending on the configured 'Probe commands', it may stop when in contact with the board, or may move upwards a few millimetres. If it is still touching the board when it stops, then press the grey ^ button to move it away from the board by a few millimetres, just to be safe.

Once you have set the zero points YOU MUST NEVER TOUCH THE MANUAL POSITIONING CONTROLS! Otherwise the controller will not know the correct coordinates.

If you do need to manually move the spindle, always use the 'Jog' controls so that Candle can keep track of the exact coordinates.

Now you can create the 'height map'. But first, a few tips...

 

User commands

Four special G-code commands can be programmed. My setup has commands 1 and 2 programmed, to move to the zero positions. You can program these from the 'Settings' dialog box, 'Service / Settings...'.

NEVER USE THESE COMMANDS UNLESS YOU HAVE FIRST SET THE X, Y AND Z-AXIS ZERO POSITIONS! The spindle may move too far and you may damage something!

1 = Move to X0, Y0 point, the Z-axis is unchanged, "G0 X0 Y0"
2 = Move to the Z0 point, only the Z-axis is moved, "G0 Z0"

 

candle-user-commands

 

Emergency stop

If you start a job and something goes horribly wrong, as it so often does when you're learning, you will need to be able to stop everything fast.

When running a job, you can use the 'Pause' or 'Abort' buttons, but these don't work instantly, the controller continues to execute the command it has received.

'Abort' stops the whole process, but you have to restart from the beginning.
'Pause' pauses the stepper motor movement, leaving the spindle motor running. You must press 'Pause' again to continue.

However, the 'Reset' button works instantly. So that's the best button to hit if there's an emergency.

candle-reset

The ON/OFF button also stops everything instantly by disconnecting power from the board and the motors. You could add a big red emergency switch to disconnect the power - that's what I'm going to do when I get round to it.

 

Creating the height map

The PCB is never exactly flat. The wooden baseboard may not be flat, it may have an uneven surface, there may be dirt stuck on the double-sided tape, etc. This can cause variations in the depth of cut, which will change the width of the tracks and can cause serious problems. You can compensate for this by creating a 'height map'.

The 'Heightmap' section is disabled until you open a G-code file.

Before you can create a height map, Candle needs to know the dimensions of the board, so you must open the first C-code file, "name-B_Cu.gbr_iso_combined_cnc.nc" with 'File / Open'.

You will see the copper side of the board in the view window, and the G-Code command list below. You will also see that the spindle and V-tip bit are set over the 0,0 position on the bottom left. In our setup, the spindle height (Z-position) is 3.054mm, see top right.

candle-5

 

To create the height map, expand the 'Heightmap' section by clicking on height-map if it is not already expanded.

Then press the 'Create' button in the Heightmap section. This opens the 'Heightmap settings' window...

candle-6

 

Above the 'Heightmap settings' area is a matrix showing the current height map. If you don't see this, drag the dot-dot-dot bar upwards to reveal the window. At first. all values are 'nan', which means 'Not A Number', since we haven't created the map yet.

(If the red rectangle in the view window above that - the map area - does not encompass the entire board, press the 'Auto' button near the bottom left to select the correct area. But this is usually not necessary.)

The values below 'Probe Grid' show that we will have 3 samples on the X-axis, and 4 samples on the Y-axis. This is OK for a small board, but you could add more points for larger boards.

Again, make sure you're Z-probe is properly connected!

The 'Zt' and 'Zb' values define the range of +/- values which are valid. These are offsets from the Z0 position. If the level is above Zt (top) or below the negative Zb (bottom), then the procedure will be aborted with an error.

 

Starting the job

Dispel your fears, take a deep breath, and press the 'Probe' button to start the process...

The probe will move up and down over the copper board, storing the difference in height relative to the Z0 position.

The height map will be complete after about 1 minute, and you will see the matrix in pretty colours which indicate the heights.

 

Making the height map. All videos are running at 4x speed, to save a bit of time...

Play

 

Now you can breathe again.

From here the 'user interface' gets a bit confusing (for me)...

candle-7

 

We are currently in 'Heightmap Edit Mode', and the obvious next step would be to tick the 'Use heightmap' checkbox. But it's disabled.

First you need to get out of 'Edit mode'. So, naturally [not], you must press the 'Edit mode' button to exit edit mode.

Now the 'Use heightmap' checkbox is enabled :-) so click on it!

This flashes a dialog box up so fast that you can't see what it is. This could be saving the heightmap data in a temporary file called 'Untitled'. The saving of heightmap data is another 'anomaly' of the UI design.

But we will press on...

After creating the height map, Candle still knows the coordinates of the spindle and the V-tip bit.

Remember - DO NOT TOUCH THE MANUAL POSITIONING KNOBS! Otherwise you will be stuffed and will have to start again.
You can only move the X/Y/Z axes using the Jog controls, so the controller can keep track of the work and machine coordinates.

 

And don't forget to remove Z-probe crocodile clip and stash it safely! (I forgot to do that, as you can see in the video.)

 

Now we are ready to start the milling process! The spindle will be where it stopped after creating the height map. In my case it's at the top left-hand corner of the board (64.360, -1.064). I think the final location depends on the 'Probe command' configured in the 'Settings' window.

But don't panic, this is OK. Hopefully, it will be moved back to the zero point when you start the job...

candle-8

 

Did you reload the hightmap file and check the 'Use heightmap' checkbox?

Have you removed the Z-probe crocodile clip?

OK, then we can begin. Fasten your safety belt and press the 'Send' button. This starts sending the G-code commands to the controller...

Suddenly, nothing happened! I got an immediate error message, "M6 error 20". This is not serious - it means that the M6 command (the 'Bit Change' command) was not accepted. For some reason Grbl does not handle this command. But we don't need to change the bit, so you can press 'Ignorieren' to continue.

candle-error-1

The job continues, moving the spindle to the X0 Y0 position. It pauses there. This is a great opportunity to check again that you have removed the Z-probe crocodile clip. Press 'Pause' to un-pause and continue.

The cutter should now make many passes to cut out the tracks. Mine took just over 16 minutes, but you could make it faster by increasing the 'Feedrate X-Y' in FlatCAM's isolation geometry. If anything goes wrong, hit the 'Reset' button, or if it's really serious power it off and "go down the pub".

 

Here, I had to re-start the job from the beginning because I forgot to check the damned 'Use heightmap' checkbox...

Play

 

While running, you will see a nice animation of the process. Watch it here at 10x speed...

Play

 

Once the job has finished, the spindle will raise itself to the 'Endmove Z' height that you defined in FlatCAM.

Using a small paintbrush, brush and vacuum away all the debris so the workpiece is clean.

 

Pausing and resuming a job

You can only pause and continue a running job by pressing the 'Pause' button at the bottom of the window, which is enabled when the command sequence is running. It just pauses the sending of G-codes to the controller. The currently executing command finishes, the motors stop, and the spindle motor probably keeps running.

You can stop the motor by pressing the 'spindle on/off' button. But if you do this, you MUST re-start the motor before you press 'Pause' again to continue the job, because it's not guaranteed that the G-codes will restart the motor, and you will probably damage the tool bit! Again.

spindle-on-off

If you make a mistake, like forgetting to check the 'Use heightmap' checkbox, you can hit 'Abort' then 'Reset'. Check the 'Use heightmap' box, then press 'Send' again. This will move the bit back to the zero position and restart the process from the beginning. I have done this and it doesn't cause any problems.

If the board has been partially machined, you can restart from the beginning providing the coordinates are still valid. If not, you must reset them to zero, ensuring the spindle is in exactly the same position as it was when it was originally zeroed. You can still use the original height map.

If the coordinates have been invalidated so the 'User Command 0' button will not move back to the 0,0 position, you would normally use the 'Home' command to move the spindle back to a known position so you can re-start the job. But this does not work on machines without limit switches. So what can you do?

You can move the spindle to the 0,0 position using the manual controls, press the 'Zero XY' button, then redo the Z0 location with the Z-probe. But how do you set the X/Y 0,0 position? ...

One way is to manually lower the spindle until it makes a tiny dot in the copper at the zero position when it is first set, then you can manually reposition it at the same point.

Another way is to manually set the approximate 0,0 position, do the Z-probe stuff, then restart the job. Pause it just before the tool touches the copper. You can then adjust the position manually and resume the job. You can usually repeat the "pause - reposition - resume" procedure if it wasn't perfect.

 

Drilling the holes

The "name-B_Cu.gbr_iso_combined_cnc.nc" file has been processed, so we can load the drill file next.

Do 'File /Open'.

If you haven't saved the heightmap yet, you will see the "Heightmap file was changed. Save?" dialog box. Save it to "heightmap.map", re-open it and re-check the 'Use heightmap' checkbox before you start the job.

Open the drill file, "name-ttl-rs232-adaptor-1-PTH.drl_cnc.nc".

Now you will see a nice 3D picture of the drill holes and spindle paths. You can click in the view and drag to change the viewing angle.

candle-9

 

Before starting the drilling job, we must change the bit to the 0.7mm corn cob bit. All the holes will be made with the same bit, despite the component 'footprints' indicating that different drill sizes are needed.

Do NOT touch the manual positioning knobs - only move the spindle using the Jog controls, so the controller does not lose the coordinates!

I was unable to remove the V-tip bit from chuck when it is at 15mm (now I used 20mm) so you may need to move it up using the Jog buttons.

Fit the 0.7mm corn cob bit. Make sure it is not so high up in the chuck that the spindle hits the end stop before it has drilled the hole - that's another mistake that I made!

Now you must reset the Z-axis zero position. Reconnect the Z-probe to the spindle and check it's working. Move the spindle to the 0,0 position by pressing the 'User command 1' button.

Press the 'Z-probe' button as you did before.

When it's set, remove the Z-probe's crocodile clip.

Next, reload the heightmap file. Press the Heightmap 'Open' button and select the file you saved above, "heightmap.map", and check 'Use heightmap'.

Now you can press 'Send' to start the drill run. This takes a little over 2 minutes. With luck, you won't have broken the drill bit.

Vacuum away the debris again.

 

It was soon full of holes...

Play

 

Cutting out the board

Open the file "name-B_Cu.gbr_cutout_cnc.nc". You will see the cut-out movements.

candle-10

 

Change the bit to the 3mm end mill bit and zero the Z-axis as you did before.

Tip: The end mill bit cuts through the double-sided tape, and can have tape residue on the end of the bit which can affect the zeroing of the Z-axis. Always make sure the bit is clean.

Press 'Send' to start the cut-out run. This generates a lot of debris, so you might need the vacuum running throughout the run.

It will make several passes, according to the 'Multidepth' value you used in FlatCAM.

 

I'm not cut out for this...

Play

 

You should end up with something that looks like this. This board is one that failed - I used the good ones to make the finished product. The grooves are a bit deep, and you can see that I messed up the bottom cut - that was because I did not set the Z-axis zero position correctly - it cut too deep and I had to abort and re-start the cut-out process.

pcb-1

 

Here's is a blurred shot of a run that left a very thin copper trace in the centre of the isolation route. This is not good because it will probably short out when you do the soldering, but you can remove it with a sharp steel blade when you inspect the board. This happened because the 'Passes' and 'Overlap' values used in FlatCAM were not suitable (I think it was 2 passes with 20% overlap). Go back to 7.4 and do it all again :-(

bad-cut

 

9. Clean up the board and solder on the components (sadly, there's no app for this step)

Give the board a careful visual inspection to see if there are any tracks which have not been properly cut, have been cut too thin so the track is broken, or still have copper in the grooves (see pic above).

Sand the edges using something like 100 grade emery paper - I like to use belt sander paper because it's the best quality and it's usually much cheaper than emery sheets. Don't sand too much of the copper off, else you will break the GND plane connections.

Lightly sand the copper side with 600 grade paper and use a flux pen on the solder locations, else sometimes the solder does not flow on the copper (if it's old and corroded, like mine).

Make sure you get the diode and transistors the right way round. And the polarised capacitors too (not used in the project). It doesn't matter so much with the resistors :-)

The pin headers must go on the top, so they can be soldered underneath on the single-side board. This is a shame because they would have been useful to plug into female connectors on a 'mother board', which is nice for modular designs.

 

Three finished boards. Very messy, but they work! Not too bad for a first try.

Click to zoom

 

10. Test the finished boards (there's no app for this step either)

Don't forget to power off the Arduino and the terminal before you connect the board, in case you short-circuit something. And be VERY careful with your scope probe's ground clip - if you connect it incorrectly you may damage the 'scope (speaking from experience). Always double check the connections before power up!

Note that the Arduino Zero has 'Serial' as the USB->COM port, and 'Serial1' as the RX/TX on pins 0 and 1. The Arduino Uno cannot be used because both the USB and the RX/TX are 'Serial' - the RX/TX pins are connected to the USB's data lines, it's the same port.

testing-d200

 

Download and run the D100 or D200 test program into the Arduino Zero. It should show "Hello world!" on the display, and you can use the Serial Monitor to view the key depressions.

If it doesn't work, it's probably a shorted track (bad routing or a solder bridge) or maybe a transistor or the diode is the wrong way round. Don't forget the RXD/TXD naming problem described above - maybe you've got the RX and TX connections the wrong way round. Naturally, I was guilty of that one.

*    *    *    *

Finally, to prevent corrosion, spray the copper side of the PCB with insulting lacquer. Or is it insulating lacquer? For example, 3M Scotch 1601/81042 or WEICON 11551400.

Cover the pin connectors with masking tape first, so you don't get lacquer on the pins!

isolating-lacquer-sprays

 

Joke of the week

"Resistance is useless!" ...
"You must use a capacitor."

 

Useful Links

The original TTL-RS232 converter circuit
http://picprojects.org.uk/projects/simpleSIO/ssio.htm

FEZ Electronics, one of the best YouTube channels, if you like electronics...
https://www.youtube.com/@FesZElectronics/featured

Basic G-Code for Grbl V2.0
https://www.sainsmart.com/blogs/news/basic-gcode-for-grbl-v2-0