Beta 3.1.1 inserting your own gcode in the generated files


John Johnson <johnatl@...>
 

This overview moves kind of quickly, but hopefully will be useful:

Run the setup program from the board editor
run pcb-gcode-setup

Turn on the files you want generated (top, bottom, etc.)

Click on the tab called GCode Options
Under the Other Options group, turn on 'Use user gcode'.

Click the 'Accept and make my board' button.
Your files will be generated and named boardbot.nc, boardtop.nc, etc.

Open the file you want to insert code in.

In the places you want to add gcode, there should be a comment. So let's say you have some custom code for the tool change routine in the drill files. Look through the file, and you will see something like this:

(Tool change begin)
M05
G00 X0.2500 Y0.2500 Z1.2500
M06 T05 ; 0.1102
(Tool changed)
(Tool zero begin)
G01 Z0.0000
M06 T05 ; 0.1102
(Tool zero end)
G00 Z0.0200
M03
G04 P3.000000
(Tool change end)

Now, let's say you wanted to add a G55 (Change coordinates) where (Tool change begin) is.
Open the user-gcode.h file in your favorite editor.
Look through it until you find (Tool change begin):

// Tool change code.
string TOOL_CHANGE_BEGIN = "(Tool change begin)&#92;n";
string TOOL_CHANGED = "(Tool changed)&#92;n";
string TOOL_ZERO_BEGIN = "(Tool zero begin)&#92;n";
string TOOL_ZERO_END = "(Tool zero end)&#92;n";
string TOOL_CHANGE_END = "(Tool change end)&#92;n";

The first line is where the (Tool change begin) came from. Change that line to this:

// Tool change code.
string TOOL_CHANGE_BEGIN = "G55&#92;n";
string TOOL_CHANGED = "(Tool changed)&#92;n";
string TOOL_ZERO_BEGIN = "(Tool zero begin)&#92;n";
string TOOL_ZERO_END = "(Tool zero end)&#92;n";
string TOOL_CHANGE_END = "(Tool change end)&#92;n";

Save the file, rerun pcb-gcode and in your boardtd.nc and boardbd.nc files, you should see:


G55
M05
G00 X0.2500 Y0.2500 Z1.2500
M06 T05 ; 0.1102
(Tool changed)
(Tool zero begin)
G01 Z0.0000
M06 T05 ; 0.1102
(Tool zero end)
G00 Z0.0200
M03
G04 P3.000000
(Tool change end)

You can also insert multiple lines. For example:

// Tool change code.
string TOOL_CHANGE_BEGIN = "G55 (Change to tool-change coordinates)&#92;n"
"G00 X0 Y0 Z0 (Go home)&#92;n"
"M05 (Spindle off)&#92;n"
"G04 P3 (Wait for the motor to stop)&#92;n";
string TOOL_CHANGED = "(Tool changed)&#92;n";
string TOOL_ZERO_BEGIN = "(Tool zero begin)&#92;n";
string TOOL_ZERO_END = "(Tool zero end)&#92;n";
string TOOL_CHANGE_END = "(Tool change end)&#92;n";

The extra space before the lines just makes it more readable. Note that each line has a &#92;n just before the closing ". Also notice that only the last line of the 4 ends with a ;.

When run run pcb-gcode again, your boardbd and boardtd files will look like this:

G55 (Change to tool-change coordinates)
G00 X0 Y0 Z0 (Go home)
M05 (Spindle off)
G04 P3 (Wait for the motor to stop)
M05
G00 X0.2500 Y0.2500 Z1.2500
M06 T05 ; 0.1102
(Tool changed)
(Tool zero begin)
G01 Z0.0000
M06 T05 ; 0.1102
(Tool zero end)
G00 Z0.0200
M03
G04 P3.000000
(Tool change end)

I'm thinking about ways to make the code editing easier, such as pages in the setup program.

Regards,
JJ

---
Help everyone. If you can't do that, then at least be nice.