This guide is an introduction to G-code, containing a list of common commands and information about what they do. We have a full reference list for experienced users, which also includes a list of commands that are not supported.
At the heart of the Bantam Tools™ Desktop PCB Milling Machine is the TinyG motion controller, and the commands that Bantam Tools™ Desktop Milling Machine Software sends to it are called G-code. Regardless of what kind of file you import into the software, it all gets turned into G-code under the hood. These commands make the spindle turn on and off, control the X, Y, and Z axes inside the milling machine, and various other functions.
As a user, you can manually enter G-code commands into the software debug console (BitBreaker > Show Debug Console). This gives you direct access to the machine, so you can make it perform specific individual actions, such as moving the X carriage 50 mm to the left, or turning on the spindle. This is very useful if you just need the milling machine to do a few simple things, rather than mill a full design. This guide will give you the most common commands that someone entering G-code manually would use.
Before we get to the commands, we need to briefly talk about coordinate systems. Imagine a 3D grid inside the milling machine. Telling the milling machine a coordinate in space will cause it to move the tip of the tool to that coordinate. But where is zero? It needs a reference point. That’s where coordinate systems come in. The software mainly uses the coordinate system called G55. Within G55, the point (0,0,0) is located at the lower left corner of the spoilboard, at the top of the material.
There is also the machine coordinate system, called G53, where zero for each axis is at its limit switch, but you most likely won’t need to use it very often. All the examples below use G55 unless specifically stated. This will all make more sense once you start using G-code and looking at the examples.
Top 10 Common and Useful G-code Commands
|Name:||Straight traverse, aka rapid|
|What it does:||Moves the tool to a location at maximum velocity. Used for positioning the tool near the next cut. Colloquially referred to as “rapid”, as in “rapid to home”.|
|Example:||G0 X5 Y22
moves at full speed to coordinate X5 Y22
|Name:||Straight feed, aka coordinated move|
|Parameters:||Feed rate (mm/min), axes, coordinates|
|What it does:||Move the tool to a location at a specific feed rate. Used when the tool is milling the material.|
|Example:||G1 F500 X10 Y50
moves to coordinate X10 Y50 at 500 mm/min
|What it does:||Traverse commands entered after G90 will move to a specific location in space. This is usually one of the first commands in a g-code file, and it’s the software’s default mode, so it’s not necessary to set it unless you’ve been using G91.|
moves to coordinate X5
does the same thing because G90 is selected by default. Repeating the command would produce no movement, because the coordinate has already been reached.
|What it does:||Commands entered after G91 will move in increments rather than to an absolute location. This is really useful if you’re entering g-code manually and you want to move the tool a short distance from wherever it is. Just don’t forget what mode you’re in!|
moves 5mm in the positive X direction twice, for a total of 10 mm. Repeating the command G0 X5 produces movement each time, because you’re moving in increments rather than trying to get to a specific coordinate like with G90.
|Parameters:||Spindle speed (RPM)|
|What it does:||Turns the spindle on at the specified spindle speed, measured in revolutions per minute. If you try and mill an G-code file generated by non-Bantam Tools™ Desktop Milling Machine Software and the spindle doesn’t turn on, this command is probably missing from the file.|
turns the spindle on at 16,400 RPM
|What it does:||Stops the spindle. There’s not a whole lot else to say about this command.|
stops the spindle
|What it does:||Adds a comment to your g-code. Since the milling machine ignores comments, this is useful for informing yourself or others what the code is doing.|
|Example:||G0 X5 Y19 (rapid to left edge of part)
tells someone reading the g-code that this command makes the machine rapid to the left edge of the part
|Name:||Select absolute coordinate system|
|What it does:||After your machine homes itself, it creates the absolute or machine coordinate system. Commands entered in the same line as G53 will use this coordinate system, where zero for each axis is at its limit switch. All other commands will use G55 (see below).|
|Example:||G53 G0 X0 Y0 Z0
rapid to home position
|Name:||Select working coordinate system|
|What it does:||G55 is the default working coordinate system for any commands you enter, so you usually don’t need to type it. G55 can change depending on your actions within the software, but generally it uses the origin of your plan at the top of your material as X0 Y0 Z0. If you have multiple plans, G55 references the most recent one you began milling. In g-code files, it’s always near the top before any traverse commands. the software also adds it by default to the top of any imported G-code files, just to be safe.|
G1 F1000 X50
selects G55 coordinate system, then moves to location X50 at 1000 mm/min
|Example:||G1 F1000 X50
does the same thing, because G55 is selected by default
|Parameters:||Axes, coordinate, feed rate|
|What it does:||Moves the tool toward a given coordinate at a given speed until it touches conductive material that’s also touching the bed. This is the same command that the software uses when you locate a tool or the bracket. If your material is conductive (and is touching the bed), you can find the location of its edges and/or surface by reading the values returned by this command.
Note that this command uses the G53 coordinate system (see above) by default, so you’ll have to use G55 if you want it to reference the plan origin as zero. You can also use G91 if you want to move the tool a specific distance without guessing its coordinates.
|Example:||G38.2 Z-75 F500
moves the tool downward slowly (500 mm/min) until it touches the bed or something else conductive
|Example:||G55 G38.2 X0 F500
moves the tool slowly toward the origin of the plan along the X axis
|Example:||G91 G38.2 X20 F500
moves the tool 20 mm to the right (positive x) until it touches something conductive
If you want to get really into G-code and start writing your own programs, the folks over at CNC Cookbook have an enormous G-code learning module.