Two sided PCB without alignment pins! Alignment of sides on two-layer PCBs in hobby equipment is often done with alignment pins. Often getting the needed precision requires a lot of hands-on experience. This project attempts to get precision enough for 2.54 mil spacing using the rig itself as a measurement device and then computationally transforming the G-code to the machine coordinates. Several tutorials exist on doing two-sided pcb's on a cnc mill, such as the 3018. Most seem to use alignment holes, i.e. a peg of a predefined diameter stuck into the waste board to enabling the board to be placed in a corresponding position for the other side of the pcb to be aligned with the drill holes. Note! Use this tutorial as a complement to other tutorials matching your skill level. It is meant as an add-on for the really neat stuff already done but will not be sufficient for a absolute beginner in doing the full board process. One needs a basic understanding of PCB CAD programs, such as Eagle or KiCad, FlatCam or similar for the CAM and finally Candle or other to run the rig itself. Some simple knowledge on how to compile and run C-programs via a prompt in a shell is also useful here. The code I produced is bound to contain bugs so use with care and moderation! The "DIY TECH BROS" youtube channel is an excellent introduction to most other things you need. Especially the "FlatCam 2 sided PCB milling on a CNC" video is what I used as a base for my work https://www.youtube.com/watch?v=8cGf6NvubF Another source of hands-on information is the instructable "DIY Professional Double Sided PCB" which also describes using pegs and also how to add solder mask and silkscreen (out of scope for this article). https://www.instructables.com/DIY-Professional-Double-Sided-PCB/ Problems I encountered while trying to replicate this: Problem with wear and tear Being a novice at this I may be a bit clumsy and using playwood instead of MDF or HDF may have made my alignement attemts more flimsy. This may be remedable but since the lower holes are calculated from flatcam it may be a hazzle to get the same alignment holes for another pcb, possible a new sacrificial board will have to be used for each new board size? Also I have a habit of making 100 mil through-hole "zig-zag" busses for old-school retro computer stuff or simply producing a hat for a Raspberry connector makes requirements for hole matching ironically higher than when producing a more recent SMT board with lot smaller pitches than 100 mil. Anyhow, having a slight insight into how professional machines do alignments I decided I would have a go at flipping the board on a fairly course basis and then using the alignment holes to measure in the new coordinates, do some math and then convert the drill file and the backside pcb's g-code coordinates after this on-the-fly obtained data. The usability of end-switches. After having some near-detch 9/11 style crashes, the limit switches arrived. Somehow they where not tailored for the 3018 or I could not figure it out so I used hot glue and some imagination, they have been working great now for several weeks. The origo choice I had a few problems with this rather cheap machine, for various reasons the controller would sometimes reset. Normally your origo is a non-marked point on the board slightly to the left of the active area. Loosing the coordinates would mean I had to move the rig to that position somehow. Initially I used a "known" point such as a drilled hole and then traced my way back to there. After the installation of the limit switches I had the advantage of zero:ing the rig. However that would mean the origo would be placed "high in the sky, to the left". Just moving the rig to some point a few millimeters in on the board and defining that "my origo" is easy. The problems start when you need to restart the rig and then you need that exact same point for running, for instance, the second part of the milling if we imagine the tool breaking half-way. There are lots of tutorials on this one. Dont be afraid of the gcode seems to be the theme I used "James Dean Designs" even though this channel is about woodworking (where jobs can go on for days) it was a good introduction to the general process "Easily pause, restart or recover your CNC job - also how to split your job into 2 parts" https://www.youtube.com/watch?v=l5YSpALv-Nc My final process for this became: * Homing the machine. The machine should now stand at (-1, -1, -1) for its work coordinates. * Put on a new board and move to an approximate good point a few millimeters in on the board from the left and then use your judgment to place origo at the lower left corner of the board edges as defined from FlatCAM. You then need to leave some board left for the alignement holes. (Again check Tech Bros for this procedure) * Now take notes of these coordinates to save for possible restarts I just name a file "Origo.txt" or similar, typically on my machine it will be something like X=-214 and Y=-112 * When and if the machine looses its marbles, do the reset procedures to get it going again and then press the "Home" button on Candle (Only do this if you indeed have the limit switches working!!) * Check that the rig has its "work coordinates" at (-1, -1, -1) i.e with a margin from the limit switches. * Give the G-code coordinates to Candle: "G00 X-214.42 Y-112.11" or whatever you wrote down when beginning (You did do this didn't you?" So after a few iterations, load screams of horror mixed with irish blesssings, you should now have a board with aligment peg holes drilled and the front of the PCB milled. You dont need the pegs used in the other tutorials for this one, just the holes. So flip the board and try to put it within some millimeters of the old position. I did just draw a recangle on the waste board for this. Now we are prepared to go to the meassurments, but first here is the math section which may scare some off. For the more practically oriented, take a look at the pictures and roll forward to the "Obtaining the needed data" section, you still need to get the program compiled somehow. The math -- On the surface it seems like a trivial problem, you just project and x and y coordinate on a new coordinate system, linear transforms are not that hard are they? If one already knows how, this is only a few lines of python, right? Realizing it was some 30+ years since I took Linear Algebra at college I first broke down the problem into projecting a point from the coordinate system obtained from the cad data From it I could easily identify the corner points corresponding to the ones I chose in Flat cam. I defined them as "xmin, ymin, xmax and ymax". One can also get these data points from FlatCAM if more convinient. This forms a rectangle on the drawing, however it will be a slightly skewed dito on the actual machine board. So say I have point P in the cad drawings and I want to obtain the machine coordinates, PT. One way to do this would be to take the end points of one of the skewed rectangle sides forming a stretch, P1-P2 on which P resides. Then projecting this onto the "real" stretch as existing on the machine, call this P3-P4 onto which PT resides This is described in [Figure 1]. We have a difference in length which will boil down to only a scaling factor and we also have a direction in the form of a vector going from P3 to P4. (ev is the unity vector) So a scaling factor and a direction will simply give us the projection point on any one of the axis. The 4-axis final monster -- Looking at [figure 2] we see that we end up with four projection points, one for each rectangle. The humble assumption is now that the intersection between corresponding sides points, forming lines will finally yield the sought for point PT expressed in machine coordinates. Turning this into some code. I used C. Python, in all its glory, does have a tendency to obscure the precise math from the user so I ended up with a set of really simple but handy vector manipulation functions in 2-D, like a small model of modern code. After some runs which originally went pretty well, I ended up with some "mirror" effects implying the code did find a solution, going further into the analysis it was obvious the problem did not handle the rather common case where the point P was outside the box on either X, Y or both. Something is missing!!! -- As a wise man once put it, "The difficulty in math and physics lays often not in obtaining magnitudes of things but to decide in which direction it goes, if it has positive or negative charge or is a magnetic north or south pole or similar". In an early version of this math (and code) I used pythagoras and more basic math tools. After a lot of sweaty calculation I ended up with a second order equation, from which I naively assumed I could "always" throw away the most negative solution. Failing this I rewrote the whole thing using vector algebra and thought this problem would be solved automatically. To my despair the vector version of the program behaved exacly like the original math so finally I realized since the vector ev was always going in one direction you also needed to handle the case where the point P is placed outside of the P1-P2 stretch. As a remedy to this I came up with a "sign" variable. After a deep dive into vector analysis I realized this was simply the normalized scalar product of vector p->p1 and p1->p2. This is not shown in the picture but can be found in the code. After this addition it has been smooth sailing, well... Obtaining the needed data -- Following the tech bro's tutorial I ended up with an "Alignment drills" G-code file The four alignment drills where easily identifiable with the g-code data: ... G00 X10.0000 Y40.0000 ... This was the same numbers as I originally placed into FlatCam Four coordinates but only four unique values corresponding to my x/y min/max Obtaining the coordinates from the rig is a little more work, lacking the pro machines moving camera and image recognition software I had to resort to more basic methods. First I flipped the board, the accuracy has to be at least so good that the active area is still "on the board" Then I fired up Candle and after the "origo process" described above I jog the machine with some suitable tool and placed the tool as close to an centered to one of the holes, I tend to start with "lower left" since that is what the program I wrote will ask for first after the x/y min/max variables. When the machine tool is placed in the hole (no need to run the spindle) I noted the "work coordinates" in Candle and input them into the C-program. Proceed like this for all four alignement holes. Then if you want to test how its doing select a "known" hole, enter its CAD coordinates and move the rig to that position. Dont forget to raise Z before moving or you will get the "Gopher syndrome"!!!! Slowly lower the Z-drive and hopefully you will see the tool positioned with a decent accuracy in the hole. When you are somewhat convinced that the program will do the right thing just enter 'q' and then the program will prompt you for the name of the input file which should probably be the back-side pcb .nc file previously produced by FlatCAM Then one has to make another run for the drill file(s). I usually automate this by using the file redirect function "<" i.e. I produce a file that will enter all this data into the program and then do "prog[.exe] < do_drill_file_conversion.txt" from the prompt The Code -- The code is written in some fairly portable C, I have tried it on cygwin and some 64-bit Ubuntu linux. Sometimes one also have to add the "-lm" option to have it include the math libs. Improvements -- * The CAD data could be obtained automatically from the Alignement holes file * The Candle jogger could be improved or I simply have not found all the magic buttons yet. If I would make a wish list I would like to have x,y and z all controllable from a num pad, and also a "gear box" to select speed of motion like the 10,100 and 1000 I now tediously select inside a menu. I've seen rather prestigious joggers doing this with a Pro micro arduino (a cool little module that can emulate mouse-moves and key presses). * For now I copy the data manually from Candle, ideally the whole process might be integrated similarly to how the height meassurments are done. The "Oh" moment. -- This is where someone tells me this is already integrated into Candle via a secret well-hidden button on the front page menu.... In fact there are some transform menus in Flatcam but I dont now if they will map well to my meassurements of the Alignement Drills. Future enhancements -- Eliminating double-milling. It seems FlatCAM (or is it KiCad gerber?) only works with closed loop milling This meand in essence that one will have to pass between each 100 mil pitch leg four times at least. Ones for each leg one the opposing side and then two passes or the between-legs trace itself. This has shown to wreck most of the copper at least with the cheap mill bits I used. Doing some mapping and then skip one of the millings if two traces are to close to one another. Remembering the old rubbing symbols where one would get ready-made bus or IC symbols with a "dog bone" in-between each leg pair, it seems reasonable we should be able to do as good as that 40+ years later.