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.