The program flow

Here the flow of the converter program:

Check if a previous
exists, delete it.

Check if an input file
exists, if not the program will abort.

Create an output file called c:\pcb_laser\ and depending of checkbox2 (9600 baud / no LCD) put G-code M117 Laser active in it. The cheap Banggood laser engraver stops on the M117 commands, so we have to skip it. If checkbox1 checked put the G-c0de G28 X0 Y0 Z0 in the file. Banggood laser engraver has no Z-axis. Speed G-code is placed.

Replace all lines starting with ; % # M G36 G21 G90 with a line starting with a T

Replace all G01 Z-3.80 with a letter B. This is the actual drill hole.
Replace all G00 Z03.80 with a letter T
Replace all G01 Z-2.00 (start milling) with a letter T
Replace all G00 Z02.00 with a letter T

While going through the file find the maximum and minimum X and Y and put them in a few variables.

Place some lines as footer in the file
M05 for laser OFF
G0 F <speed move with laser OFF> X0 Y0

Place the Offset X and Offset Y on the screen

Take care of the extra offsets that might be given in the GUI.

Pre-scan done
Now put the offsets at work…
Put the speeds in the commands
Put the laser code in the commands

All variables are fetched from the GUI. Speed moving laser off, speed moving laser on, distance Z-axis, should Z-code be generated. When you just finished a laser job you can skip this to speed up the process.

Create a final output file pcb_laser_output

Do you find a B in the file, then that is a Drill command. G04 P100 delay-command. Is the laser on, output a G04 P1 delay (no delay).

Put a M117 CenterPoint message in the output file

Place 8 laser point G-code commands around this centerpoint

Put on the GUI that file exists and how many lines it has.

Disable the convert button
Enable the send to laser button


While sending of the output file, a progress bar appears.

At G-code M03 (laser ON) and M05 (laser OFF) a laser-status bit is set or reset. Is the Quit button pressed a confirm screen is shown. Laser is turned off. Is the Quit not confirmed then the laser is put on or off depending of the laser-status variable, and the job is continued.

During the different phases of the conversion, you can check the input and output files with GRBL-controller.

M117 message command

The result of a M117 G-code command. In the Posts you can read that in the Marlin firmware, I have named my Laser Engraver ‘My Laser’. A message ‘My Laser ready’ on the bottom line of the display. I have noticed that the GRBL-driven laser engravers don’t like these M117 commands, so in the GUI of the converter there is an option the disable generation of these messages. Also a Prusa I3 with an Ramp 1.4 controller is working on 250000 baud (yes, a strange value), the Banggood laser engravers are working on 9600 baud.

What should the converter do?

What should the converter do? Remove all empty lines, remove all comment lines, remove all Tool commands, remove all comments half way at the lines. Change the origin of the PCB. Put some extra dots around drill holes to make them a bit more solid.

This is the output of a Eagle PCB milling .nc file. The origin 0,0 is at lower right. The origin of the Prusa I3 is lower left. So the converter should shift the whole PCB its size to the right. You can see that happen in the output file of the converter. It does a pre-scan to get the dimensions of the board.

Furthermore, the drill holes are only on one location and the Z-axis will drill a hole of 3.8 mm. This has to be replaced by a piece of G-code with a center point surrounded by several laser dots.

Because of shifting the origin of the PCB the X and Y coordinates are a bit different. At the left selecting drill tool 1, running to the spot where the drill should make a hole, with drill on drill a hole 3.8 mm deep. At the right the translation of these lines. Laser on with M03, a small delay so the laser will have it’s full power (G04 P100), with a M117 a message on the LCD display, going to the center point, place dot and with speed F10 laser 8 dot’s around this center point. After that change the message on the LCD display and put the laser off.

*note: these are not the final PCB’s the converter has generated, these are PCB’s from a earlier test.