Exporting Eagle milling file

In the menu, tools, with the board on the screen, select mill outlines.

Choose CNC as output and generate drill G-code commands.

Mirror is important.

Here you see the 3.8 mm Z-drill deep back for drilling a hole. In the converter this is converted to a centerpoint with 8 laserdots around it.

You can leave the name of the mill file and copy it later on to c:\pcb_laser\pcb_laser_input.nc
It has to have that name to be the input file of the converter.



Will put the ‘How to export from Eagle as a milling file’ here later on. Here some files to test the converter.

Export file from Eagle = input file for the converter

Output file from the converter to compare with your result.

You have to place the input file in c:\pcb_laser\ directory.

And here the executables of the converter. Will put the source on line later on. Must click setup.exe. Put the files also in c:\pcb_laser\ directory.

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\pcb_laser_output_pre.nc 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 pcb_laser_output_pre.nc 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 pcb_laser_output_pre.nc 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 pcb_laser_output.nc 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.

Modifications of the Marlin firmware

Here a link to the firmware of my Prusa I3 laser engraver with Ramps 1.4 controller

All modifications are made and I will describe them in detail here.

In Configuration.h
// This determines the communication speed of the printer
//#define BAUDRATE 250000
#define BAUDRATE 115200

Had to get a regular baud-rate, a baud-rate Visual Basic wil understand.

In Configuration.h
// 33 = RAMPS 1.3 / 1.4 (Power outputs: Extruder, Fan, Bed)
#define MOTHERBOARD 33

In Configuration.h
// Define this to set a custom name for your generic Mendel,
#define CUSTOM_MENDEL_NAME “My Laser”

In Configuration.h
#define TEMP_SENSOR_BED 0 // was 1

In Configuration.h
// ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: http://code.google.com/p/u8glib/wiki/u8glib

In Pins.h
#define FAN_PIN 8 // (Sprinter config)

In Pins.h
#define HEATER_BED_PIN -1 // NO BED
#define HEATER_BED_PIN 9 // BED
#define HEATER_BED_PIN 9 // BED

Pins D8 and D9 are exchanged. So the fan command will drive the MOSFET of the heatbed. On this MOSFET the laser is connected.

Now we have to change some G-code commands:

In Marlin_main.cpp

#if defined(FAN_PIN) && FAN_PIN > -1
//case 106: //M106 Fan On
case 03: //M03 Laser on
if (code_seen(‘S’)){
else {
//case 107: //M107 Fan Off
case 05: //M05 laser off
fanSpeed = 0;
#endif //FAN_PIN

In this case fan-commands M106 and M107 are disabled and renamed to M03 and M05. M03 has still PWM control.

Here the hardware details:

To get 5 volt for the laser I have used a step-down from 12 to 5 volt.


Visual Basic 2015 or 2017

It is what it is, free, fully-featured IDE for students, open-source and individual developers.

The files in the project.

Here a part of the user interface. The default values are:
Moving, laser off, speed 3600.
Moving, laser on, speed 1000.
Laser height at 32 mm above the PCB.
Generate Z-code. If you turn this on G-code will be generated to bring the Z-axis to zero and after that go to the 32 mm above the PCB. If you know your last laser project was PCB lasering, you can skip the Z-code generation, it will all be faster at start-up.
Offset X and Offset Y. If you want to laser more than one board you can shift the 0,0 origin.
Comm-port is the virtual port to use to communicate with the laser engraver. The baud-rate is fixed at 250000 or 115200, you will have to adapt that in the source code.
And the last option is for the Banggood (CE – Chinese Electronics ­čśë ) laser engraver. It will skip messages M117 to the LCD-display and put the baud-rate on 9600.

There are 3 buttons, Convert, Send to laser and Quit. You can use GRBL controller software to check the input file, and after a convert, check the output file. When you hit Quit by mistake, not to worry, a confirm box will be displayed. And as an extra, the laser will be turned off when it was turned on, and after hitting NO in the confirm box lasering will continue without any problem, the software has remembered the status of the laser.

In the user interface a check if an input file exist. If it doesn’t exist, the Convert button will keep grayed-out. pcb_laser_input.nc is the name used while exporting a milling-file from Eagle. A pre-scan file is created but also deleted after use. It is called pcb_laser_output_pre.nc It is used to do some work ahead and also check the dimension of the PCB laser file (offset X as mentioned in earlier posts).

In the user interface a note about the output file and also the number of G-code lines. This will later be used to check to progress of lasering the board. Convert button will be grayed-out and the Send to laser will be enabled.

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.