I have a Grbl/M4 (laser mode) script that is used exactly as Ryan’s original script… and assumes the lens assembly has already been positioned for a desired focal length (no further adjustment required) and you have a fully-implemented, gcode-controlled, Z axis.
To use… initially – and intentionally – set Z “too close” to the material surface for proper focus and then run the script. It draws a series of 10 lines… with each line displaced 1mm in Y and 2mm in Z from its neighbor. At script end, you are 10mm in Y and 20mm in Z above where you started. Now, simply count lines back to the finest/thinnest (best focused) line and multiply by 2mm… and then lower your Z axis by that amount for best focus on the surface of the material.
Here the 5th line from the top is finest/thinnest (to my old, tired, eyes)… so I lower Z from its current position by 10mm (5 lines X 2mm) and I now have “best focus” on the surface of the material.
The script is easily edited to change speed and power for your laser and material… here, it is set for 600 mm/min and 25% (S250) power.
M4Focus.zip (473 Bytes)
– David

