Using Transform Matrix for PCB Drilling – Part 1

Matrix
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 T_1 be the following matrix

T_1= \begin{array}{|ccc|} x_1&x_2&x_3 \\ y_1&y_2&y_3 \\ 1&1&1 \end{array} , A'= \begin{array}{|c|} x_1 \\ y_1\end{array} , B'= \begin{array}{|c|} x_2 \\ y_2\end{array} , C'= \begin{array}{|c|} x_3 \\ y_3\end{array}

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 (x,y,1)
Let T_2 be the matrix representing the three points original coordinates:

T_2= \begin{array}{|ccc|} X_1&X_2&X_3 \\ Y_1&Y_2&Y_3 \end{array} , A= \begin{array}{|c|} X_1 \\ Y_1\end{array} , B= \begin{array}{|c|} X_2 \\ Y_2\end{array} , C= \begin{array}{|c|} X_3 \\ Y_3\end{array}

The transform matrix M is simply the matrix multiplication of T_2 and the inverse of T_1

M=T_2 \times {T_1}^{-1}

Now we can obtain the new point’s coordinates just right multiplying M to our vector

\begin{pmatrix}x\\y\\1 \end{pmatrix} = M \times \begin{pmatrix}x_1\\y_1\\1 \end{pmatrix}+t
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 t 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.

Matrix

Don’t miss the second part !


Warning: count(): Parameter must be an array or an object that implements Countable in /home/mhd-01/www.alessiovaleri.it/htdocs/wp-includes/class-wp-comment-query.php on line 399

9 thoughts on “Using Transform Matrix for PCB Drilling – Part 1

  1. Annirak

    This is a great first step, but it can be improved. The commercial PCB manufacturing industry uses fiducial markers to deal with issues similar to this. Fiducials are more for positioning of fine-pitched components, but they would allow for similar compensation on a project like this. It does take some more hardware and software, however.

    First, a camera has to pass over the each expected fiducial location and determine an offset, optionally repeating the process until the alignment is corrected. Using this as a starting point, it’s possible to calculate transform matrices between the fiducials in much the same way as you are doing with the existing holes.

    The benefit is that this automates the entire procedure.

    Reply
    1. alex89rm Post author

      You are totally right, I’m playing around OpenCV to have a completly automated procedure ! 😉

      Regards

      Reply
      1. Abhishek

        Hi, Have you done with the part 2? Also would like to know if you succeeded as I am working on the same thing.

        Reply
  2. Guilherme Schallenbach

    Are you drilling the board after the etching/masking process?
    I always thought doing it beforehand: Drilling >> Etching >> Masking (solder mask), so you can use the pre-drilled holes to align the circuit to be etched/masked.

    Reply
  3. Pingback: Dejar [Euler] ayudar con la fabricación de PCB - | Indagadores |Seguridad informatica |Seguridad en internet

  4. Pingback: Letting [Euler] help out with PCB fabrication | Cool Internet Projects

Leave a Reply to alex89rm Cancel reply

Your email address will not be published. Required fields are marked *