Maker.Bot.Party.Mode – GCode Tips & Tricks for the Practical Botter
Recently, I posted an introduction to partymode and uploaded my own sample partymode scripts to Thingiverse to kick things off.
Today, I want to share a few more details to help you play in the ReplicatorG-flavored G-Code sandbox. For those uncertain about the value of creating short movement bot scripts should remember that this is a great opportunity for you to learn just enough about G-code to tweak your prints and personalizing the start.gcode and end.gcode files in your skeinforge profiles for better, more efficient MakerBotting.
Also, why not add a bit of musical hijinx to your prints? Why doesn’t your bot play music after every print? Mine does.1
Please enable Javascript and Flash to view this Blip.tv video.I’m going to bribe you to improve your G-code fluency by introducing you to a stupidly simple trick you will want to use every time you skein a model.
MakerBot Operators grumble about navigating down through the ReplicatorG file structure to adjust the Start.gcode files for a Skeinforge profile. But do you know what happens if you don’t do this step? The nozzle drops down to 20mm-40mm above the platform and attempts to print in the air. Not so successfully, as it turns out.
Well, that little snipped of gcode you must change in your Start.gcode file appears again right near the top of the gcode that you generate when you slice a model. Here’s the chunk in question just a little ways down the G-code document I have just generated for an Octopus model I am super eager to print on my bot. Want to make an adjustment? You can punch up the code right in ReplicatorG without touching your Start.gcode document.
(**** begin homing ****)G162 Z F500 (home Z axis maximum)G161 X Y F2500 (home XY axes minimum)G92 Z80 ( ---=== Set Z axis maximum ===---)G92 X-57.5 Y-57 (set zero for X and Y)(**** end homing ****)
“Hmmm,” you say. “So this is the Homing section. And Set Z axis maximum lists only 80mm for the height of my build envelope. You’d better change that to your bot’s printing height ( 120.3mm) and then save your file!”
Thank you, bot-friend! You have just shown me how to use ReplicatorG to tune and save g-code!2 You can perform this trick right within ReplicatorG or open a plaintext editor and change the file there.
I suggest you take a look at this homing block every time you skein a new model to make sure that the correct value has propagated through. (Sometimes it helps to adjust your z-height by a 10th of a millimeter up or down — that first layer is ultra crucial when you aren’t printing a raft, especially on stepper-driven extruders.)
Do you want to know the handful of G-Code commands every Operator should recognize on sight! Learn more after the jump.
What is G-Code?
G-Code is but the most common name for a cluster of mildly conflicting, diversely-implemented programming languages3 that are typically in use for computer numerical control (CNC) machines. In fact, the actual “G-codes”4 are just a subset, along with M-codes5, and in some implementations all letters are used somewhere in the language.
You see an example of G-code, however briefly, every time you “skein” up a model in ReplicatorG and establish the set of instructions for printing. The “Generate G-code” button remains as a gentle reminder that this is the stuff you really need for 3D printing objects, even if you immediately turn around and process the g-code into a serial printer file format (.S3G) for SD card printing by using the “Build to File” or “Build to SD Card” buttons.
As far as languages go — and as far as implementations of g-code are concerned — the ReplicatorG-flavor of G-code is tremendously simplified, more like BASIC: a list of commands to run in the order that they are listed, with the subroutines and GOTO removed. With a tiny bit of practice, it is quite human readable – if dull reading. A typical document is a long series of G1 command (“Go to this x/y/z position and this speed”) sandwiched between M101 (start extrusion) and M103 (stop extrusion) commands, with all of the fussy machine mode setting and pre-heating and cooling at the head and tail of the print.
As all of the fine details including curves tend to be rendered as a series of small segments rather than long straight runs, reading G-code by eye without a G-Code visualizing tool can be difficult. But as the positioning information tends to be absolute, based on a point (X0, Y0, Z0) right at the center, top surface of the build platform, you can look through a script and always know where you are. In an ideal world, you could navigate through to the tiny machine move you’d like to run faster or slower or a little the left and make that change there. In a less ideal world, we tend to tune Skeinforge to make these adjustments for us by triggering python slicing tools analyzing the model for behaviors.
G-Code Cheat Sheet
While next to no one writes G-code manually anymore thanks to the broad range of CAD/CAM tools to generate it having the flexibility to eyeball G-code gives you a little more control over your MakerBot. (Take a look at the ReplicatorG G-Code primer for more!)
Here are the most frequently appearing and useful G-Code calls:
- G1 – Coordinated Motion
- G4 – Dwell
- G21 – Millimeters as units
- G90 – Absolute Positioning
- G91 – Incremental Positioning
- G92 – Set current as home
Here are a few useful M-Codes as well:
- M0 Automatic halt (not used when printing from SD)
- M1 Optional halt (not used when printing from SD)
- M2 End of program (not used when printing from SD)
- M6 Typically used as “wait for Extruder to heat up” though this is something of a hack.
- M101 Extruder on, fwd
- M102 Extruder on, reverse
- M103 Extruder off
- M104 S## set temperature in degrees Celsius
- M105 get extruder temperature
- M106 turn fan on
- M107 turn fan off
- M108 S### extruder speed in PWM
- M109 S### set build platform temperature in degrees Celsuis
G-Code/M-Code Arguments (follows a G- or M-Code call)
- X absolute position
- Y absolute position
- Z absolute position
- F feed rate
- S servo position
G-code Throwdown – Create Your First “partymode” Script
Now that you can recognize most of the common G-Code commands, it is high time you create your first “partymode” script. This could be a tiny bit of music to play at the end of your print. Or a test to make sure that your build platform is perfectly level. Or tie a pen to your toolhead and turn your MakerBot into a code-fed, manual Etch A Sketch or solve a maze. (Don’t forget the Thingiverse Tag: “partymode”)
- Well, my Cupcake prints do. [↩]
- Most G-code is practically as simple — thanks to lots and lots of commenting in Skeinforge and the user configurable Start.gcode and End.gcode. [↩]
- other names/variants include RS-274D, ISO 6983, RS276NGC, DIN 66025, PN-73M-55256, PN-93/M-5525, or “That Cursed G-Garbage We Put Up With Because Everyone Else Does” [↩]
- the G + number code “preparatory commands” for telling machine what mode to shift into [↩]
- M-codes typically control specific tools with the machine such as fans, valves, servos, etc [↩]
| Tagged with | basic, botsounds, cnc, g-code, music, partymode, replicatorg, skeinforge, start.gcode, Thingiverse | One comment |





One Comment so far
JJ
*Disclaimer*
Don’t try and home without endstops installed.
*End Disclaimer*