Sunday, September 27, 2020

Notes on CNC for PCB Milling and SMD Solder Masks

Some time ago I bought a personal CNC machine, as I had always wanted to learn more about gcode and in general what could be done with a home CNC machine. I also used the excuse that I would be able to make prototype PCB quickly. Nearly 2 years later, I have not yet etched a single PCB with it. So many fun projects, so little time! 

The CNC arrived in kit form and required (relatively straightforward) assembly, which was really enjoyable. I ordered this TwoWin Pro 3018 from Aliexpress. It's definitely a low-end CNC machine, but for the price I am quite happy with it. While it is certainly not going to be machining a new engine block - it is completely capable of light-duty PCB etching and similar work.

As noted in my prior blog, I purchased (and "upgraded") a T962A Reflow Oven. There too - the upgrade rework was a lot of fun! In looking at practice SMD boards - I realized that none of them had any sort of stencil. How to make one? Well, I'm thinking of something in Adobe Illustrator that will output a DXF file and convert that to g-code, perhaps with dxf2gcode. (it is a shame the sourceforge site continues to be so riddled with ad-spam but pi-hole really helps block much of the crap), See also grauonline blog: "CNC Milling: From DXF Files to g-code using free software. Note the google drive download link there is a bit dated. 

I ordered some 3 mil Blank Stencil Mylar Sheets that should be here next weekend. From what I could tell from a variety of google searches, the thinner 3 mil mylar should have less of a tendency to have the solder paste stick when removed from the PCB. We'll see.

There's definitely a learning curve for any CNC machine. I somewhat lost interest out of frustration in converting file formats from various editors to g-code. I spent a bit of time learning Fusion 360. It is great for drawing, but getting the data out to actually machine something is another story. Note that Fusion 360 is a cloud product, and the files are stored primarily in the cloud.

Here's a guy that says "It is possible to do PCBs on this sort of set up but it is not easy to get good results."

View Gerber files online for free at gerblook.org.

More recently, I found this pcb2gcode that will taker gerber files directly from KiCAD and generate g-code (the commandline parameters are somewhat extensive, so the pcb2gcodeGUI is recommended).

Install of pcb2gcode and pcb2gcodeGUI was fairly straighforward on WSL:
cd /mnt/c/workspace
sudo apt-get update
sudo apt-get install git build-essential automake autoconf autoconf-archive 
sudo apt-get install libtool librsvg2-dev
sudo apt-get install libboost-program-options-dev libgtkmm-2.4-dev gerbv 
git clone https://github.com/pcb2gcode/pcb2gcode.git
cd pcb2gcode

autoreconf -fvi
./configure
make
sudo make install

cd /mnt/c/workspace
sudo apt-get install build-essential git qt5-default libqt5svg5-dev
git clone https://github.com/pcb2gcode/pcb2gcodeGUI.git
cd pcb2gcodeGUI/
qmake
make
sudo make install
Of course to actually run on WSL, an X-Windows server is needed, such as VcXsrv. It can be either run from C:\Program Files\VcXsrv\ or launched directly from WSL:

"/mnt/c/Program Files/VcXsrv/vcxsrv.exe" & pcb2gcodeGUI & 
    
Note that both the Windows vcxsrv.exe and the pcb2gcodeGUI are blocking apps. So instead of having 2 additional, blocked WSL windows, the ampersands allow the commands to be launched in parallel. The trailing " & " allows for return to current terminal bash prompt (just press enter).
There are some comments about disabling OpenGL. I did have an odd problem with sigrok pulseview not sizing properly. Note to self to revisit the thread on discord to see if the OpenGL settings have any effect (in particular the iua for iCEBreaker).

There's the option of export LIBGL_ALWAYS_INDIRECT=0 or the passing the -wgl to vcxsrv. Note also the export LIBGL_ALWAYS_SOFTWARE=1 mentioned in the comments of my RISC-V on tinyFPGA-BX via WSL blog.

Note that most of the inexpensive CNC machines doe not have limit switches pre-installed. I bought some of the markerbot-style boards

There's a comment on GitHub about "endstop PCBs connect the NC switch terminal directly to +5 V, in addition to having a pullup resistor on the C terminal" so care should be taken on the wiring. This is easily solved by snipping off the NC pin as show on the MPCNC: Makerbot-style Endstop Switch Modification blog.

Find gojimmypi at gojimmypi.github.io

I'm currently working on my new blog home at  gojimmypi.github.io After implementing a variety of features such as dark mode , syntax hi...