Archive for the “Cnc” Category

In some cases it might be convenient if we can split a gcode file into smaller pieces so they can be milled in small sections.

How does a typical gcode file, produced by pcb-gcode-3.5.2.11 look like? I suspect to find a header section like:

  • Initialisation
  • Move spindle up.

Sample of the top 15 lines of a test file. The section I consider header is in bold.

G21
(Absolute Coordinates)
G90
G00 X0.0000 Y0.0000
M03
G04 P3.000000
G00 Z2.5400
G00 X1.6917 Y9.2837
G01 Z-0.1778 F254
G01 X3.3883 Y9.2837 F508
G01 X3.5576 Y9.3174
G01 X3.7171 Y9.3834
G01 X3.8606 Y9.4793
etc
etc

First of all it looks like the file indeed has a header section. Let’s see what the codes mean.

G-CodeDescription
G21Programming in millimeters (mm)
G90Absolute programming.
Positioning defined with reference to part zero.
G00 X0.0000 Y0.0000G00 = Rapid positioning. The other two are coordinates. In this case move to the zero postion.
M03Spindle on
G04 P3.000000G04 = dwell (pause). Where P3.00000 means 3 seconds.
So it means that it pauzes for three seconds and then proceeds with the next gcode.
G00 Z2.5400G00 = Rapid positioning. In this case move the spidle up from the pcb.
Moving it up is needed becase the next step will be to move the spindle to the first line to be milled. You like this movement to be above the pcb, not through the pcb. 😉

That’s it. All there is to the header. I suspect to find a footer as well, but let’s look at the miling parts first.

When milling a line segment it can simply be defined as:

  • Position the spindly just above the linesegment to be milled
  • Move spindle down into the pcb (negative Z movement)
  • Move the spindle around (mill the line segment) without any changes to the height (Z movement)
  • Move spindle up from the pcb (positive Z movement)

G00 X1.6917  Y9.2837
G01 Z-0.1778 F254
G01 X3.3883  Y9.2837  F508
G01 X3.5576  Y9.3174
etc
G01 X1.5224  Y9.3174
G01 X1.6917  Y9.2837
G00 Z2.5400

G-CodeDescription
G00 X1.6917 Y9.2837G00 = Rapid positioning. In this case move the spidle to the starting point of your line segment.
G01 Z-0.1778 F254G01 = Linear interpolation. Move in a straight line (hence linear) to the coordinates specified.

F254 = feed rate. The speed at which the cutter moves.
G01 X3.3883 Y9.2837 F508G01 = Linear interpolation.
F254 = feed rate.
More codes like:
G01 X-position Y-position
G01 = Linear interpolation.
Milling of subsequent parts of the line segment
G00 Z2.5400G00 = Rapid positioning. In this case move the spidle up from the pcb.
Moving it up is needed becase the next step will be to move the spindle to the first line to be milled. You like this movement to be above the pcb, not through the pcb. 😉

Milling a line segment by means of the G01 linear Interpolation is in fact pretty straight forward it seems.

Let’s try to identify the footer. It wraps up operation so it will look like:

  •  Move the spindle out of the way
  • Stop the spindle
  • Stop the program

 

G01 X-0.6316 Y0.4907
G01 X-0.6316 Y0.4907
etc
G01 X1.8840  Y0.9641
G00 Z2.5400
G00 Z12.7000
M05
M02

G-CodeDescription
G00 Z12.7000 G00 = Rapid positioning. In this case move the spidle way up and out of the way.
M05Spindle stop
M02End of program

All in all it looks like a relative simple gcode file like this can be split into smaller sub programs complete with header and footer.

 

Comments Comments Off on Gcode analysis – can we split it?