2013-02-26

Java program to probe Z for PCB milling

 In my first attempt at PCB milling last weekend I had my PCB bend by as little as 0.04mm.
Clamping a PCB in a vice the center will bend upwards or one side be lower/higher then the other.
Even if you can't see it and can't meassure it with hand tools but only with the z-probe of your CNC.
Given a cutting depth of 0.02mm to barely remove the copper layer, this is too much.
So last night at the CCC-Freiburg meeting I wrote myself a small Java program.

It takes the g-code output of PCB2GCode. (See last blog posting about parameters.)
You have to have your PCB mounted already, positioned your cutting tool and set an initial Z=0.
You also need an electrical Z probe (simple cable clamped to the PCB and your actual cutting tool with an input pin configured as probe shortened to GND or VCC when both touch).

Then it determines the position and size of the PCB and asks you to take a number of Z-probe meassurements on your CNC to see very precicely what height the PCB actually starts at in these locations.
(It will be more likely to be Z=-0.0123 or Z=0.0234 instad of a perfect Z=0.00000)
It tells you exactly the G-code you have to copy&past&run for MACH3.
(including G20/G21 setup of the proper unit first, to raise yourtool  and jog to the right location.)
By default it asks for a 3x3 grid of 9 meassurements.
One per corner, one in the center and one in the center of each side.

Then it reads the g-code again and writes a new g-code file with the following changes:
  1. Adds a bilinear interpolation of you real position Z=0 as an offset for each Z position mentioned in the code.
  2. Adds a Z value to all movements in X+Y that don't already have one using the last Z position seen plus the offset.
  3. Breaks up all movements that are longer then 1/6th of the diagonal of your PCB into smaller movements to follow the curvature of the PCB.

Update: Version 2

Keine Kommentare: