Since I started making my own PCB I always complained how boring and tricky is hand drilling all the holes in the right place. Owning a CNC router I could have the work done in a hurry neverthless I prefer etching my own boards and have the drills done by the router. The main problem is how tricky is aligning the board under the machine, furthermore there may be some scaling problem related to the master mask precision. Thus I started coding a little tool which could help me in this process allowing me to not care about all the stuff I just explained above. The goal is to compute a new gcode given the real coordinates of some known holes. Linear algebra here comes in help, in particular here we are doing an affine transformation of the plane. Known three points is quite simple to find the transformation matrix: let be the following matrix
, , ,
Where every column is the vector representing the respective point. To represent affine transformation with matrix we can use homogeneous coordinates, thus a 2-vector is represented as
Let be the matrix representing the three points original coordinates:
, , ,
The transform matrix is simply the matrix multiplication of and the inverse of
Now we can obtain the new point’s coordinates just right multiplying to our vector
Referring to my setup, a camera is attached near the spindle to allow me for detecting the holes coordinates relative to my machine axis. Hence the translation vector represent the distance between the camera center and the spindle’s axis. The tool I coded simply allow to load a gcode file and input the real coordinates in a popup windows which shows up when we select a point. After choosing three points all we need to do is to compute the transformation and save the gcode. In the next article I’ll show how everything works.