RepRap Firmware G-Codes
The RepRap Firmware (abbreviated RRF) does use more G-codes than other firmwares notably because all configuration is done with G-Codes. Another reason is that it does have extended functionalities.
This page list G-codes interpreted by RepRap Firmware. This list cover DC42 and Chrishamm fork, which are more complete than the original version. Some G-Codes are common between RepRap Firmware and other firmwares, but with extended syntax or specific interpretation. They are listed in a specific paragraph.
Contents
With RepRap firmware, everything is G-code
The RepRap Firmware philosophy is that every operation is done with G-code, notably all configuration, which is mainly stored in config.g file, called at board start-up. A set of standard or specifically crafted G-codes macros is written for all commons printer operation.
All G-codes or macros could be send to the board while operating the printer, allowing instant feed-back for any configuration modification. As interactive modifications are lost at next board start-up, the successfully tested G-Codes shall be manually introduced in the configuration file.
This interactive configuration makes the printer tuning easier than with other firmware.
Typical parameters
Most commands (M or G) are associated with parameters, typically Pnnn, Paaa or Xnnn. It shall be noted that the parameter qualifying letter is NOT part of the parameter, e.g. parameter PMyName is "MyName".
Commonly used parameter qualifiers are :
- Pnnn or Paaa - Main parameter
- Rnnn - other parameter
- Snnn - other parameter, also often used to modify command behaviour (S0~S9)
- Tnnn - typically Tool number, trigger number for M581 and M582
- Xnnn, Ynnn, Znnn - parameter associated with an axis
- Fnnn - feedrate
- Hnnn or Hn:n:n - Height or Heater/sensor number
- En or En:n:n - Parameter associated with extruder 0,1, etc. to 5
- Dn or Dn:n:n - Hardware drive reference defaults are 0:X; 1:Y; 2:Z; 3:E0; 4:E1; 5:E2; 6:E3; 7:E4; 8:E5
- Rn - enable value - for different hardware needing positive or negative signal to be enabled - M569
- Bnnn - Safe printing radius (M665), baud rate (M575)
- Wnnn - maximum value of PWM used (limit the power) from 0 to 255 (255 = 100%) - M301 & M304
Sometimes a "-1" value is used to cancel a command.
It shall be noted that Extruder number, Tool number, Heater number and Drive number are separated entities which need to be associated one with the other. There are default associations between drives and movement/extruder axis.
Default values
Most configuration G-codes have default values, and if the default are acceptable, you don't need to enter the G-Code, so config.g could be for some printers very simple.
However, sometimes the default values got modified in firmware update, so it is wise to explicitly define all your parameters, to avoid troubles while updating and also to document them. Some default values (DC42 fork rev 1.11):
- PID parameters ( M301) for hotend heater : P10 I0.1 D100 T0.4 W180 B30
- Bed control default is bang-bang (P-1)( M304), other parameters: I5 D500 T2.7 W255 B5 -for PID control, you may start with P85
- PWM frequency 10Hz for Bed and Chamber heaters (SSR compatible) and ?? Hz for Hotend heaters - not adjustable
- Thermistors - all- ( M305): T100000 B4138 R1000 L0 H0 X3
- Steps/mm ( M92): X200 Y200 Z200 E304.5:304.5:420:420:420:420
- Maximum feedrates mm/min (M203): X25000 Y25000 Z25000 E8000:8000:1200:1200:1200:1200
- Accelerations mm/s^2 (M201): X500 Y500 Z20 E250:250:250:250:250:250 - for comparison gravity acceleration is 9810 mm/s^2
- Maximum jerk rates mm/min (M566): X1200 Y1200 Z800 E500:500:120:120:120:120
- Time allowed to get to temperature on hotend heaters (M570): 150 seconds.
- Filament (M404) width: 1.75mm, nozzle diameter: 0.50mm
- Controllable fans (M106): Fan0, inverted, 500Hz. Fan1, inverted, 500Hz, thermostatic mode, 45°C.
Codes specific to RepRap Firmware
Macros and physical interfacing
- M98: Call Macro/Subprogram
- M99: Return from Macro/Subprogram
- M42: Switch I/O pin Change status of a pin. Hardware dependant - also used by other firmware.
- M571: Set output on extrude - Activate a pin while extruding
- M577: Wait until endstop is triggered
- M581: Configure external trigger Run macro, pause or stop from a pin state change. See expansion connector pinout - In progress -
- M582: Check external trigger Check pin status associated with a trigger - In Progress -
Heaters
- M135: Set PID sample interval
- M143: Maximum hot-end temperature - NEW -
- M144: Stand By Your Bed
- M570: Set heater timeout - common to all tools
- M562: Reset temperature fault
- M563: Define or remove a tool
Ethernet communication
- M540: Set MAC address - all printers on same network shall have different MAC addresses
- M550: Set Name - Name for web page call and for FTP
- M551: Set Password - For FTP and Web Control/firmware exchange
- M552: Set IP address - Optional
- M553: Set Netmask - if IP address defined
- M554: Set Gateway - if IP address defined
Miscellaneous Configuration
- M555: Set compatibility - G-code style compatibility
- M558: Set Z probe type
- M566: Set allowable instantaneous speed change - 'jerk' values: speed change while cornering
- M569: Set axis direction and enable values - Change stepper directions without replug
- M906: Set motor currents - digital potentiometers for steppers
- M574: Set endstop configuration
- M572: Set or report extruder elasticity compensation
- M575: Set serial comms parameters - Presently used by PanelDue for communication with the Duet
Web control (DWC)
Firmware configuration
- M559: Upload configuration file
- M997: Perform in-application firmware update - NEW - firmware update without USB connection
Reporting - also used by DWC
- M36: Return file information Return information about a file on the SD card - JSON format
- M122: Diagnose
- M573: Report heater PWM
- M408: Report JSON-style response - Return printer status data
- M503: Print settings - Display config.g content
Geometry
- M208: Set axis max travel
- M556: Axis compensation - X/Y angular correction
- M564: Limit axes
- M579: Scale Cartesian axes - X/Y/Z scale compensation for deltas
- M667: Select CoreXY mode
- M668: Set Z-offset compensations polynomial - in development ?
Miscellaneous commands
- M37: Simulation mode - Run a print simulation for time estimation : slow
Specialised machines
- M567: Set tool mix ratios
- M568: Turn off/on tool mix ratios
- M578: Fire inkjet bits
- M580: Select Roland
G-codes with specific or extended syntax
Movement and geometry
- G0 & G1: Move - Flags are used to bypass endstops or move carriage on delta
- G10: Tool Offset Define standby and operating tool temperature / Retract if no parameter, see M207 (NEW)
- M207: Set retract length RRF add unretract length parameter - NEW -
- M208: Set axis max travel Used for unretract length in other firmware
- M665: Set delta configuration Add height, maximum usable radius and column angular position
Heating
- M105: Get Extruder Temperature
- M135: Set PID sample interval
- M141: Set Chamber Temperature (Fast) - in RRF also define the chamber heater
- M301: Set PID parameters RRF add PID band, PWM scaling and other parameters
- M305: Set thermistor and ADC parameters add external thermocouple (using SPI)
Miscellaneous
- M106: Fan On - RRF use to configure controllable fans. Fan1 configured in thermostatic mode by default. Deactivate with "M106 P1 H-1".
- M302: Allow cold extrudes add cancelling of the command
- M561: Set Identity Transform - reset the transformation from calibration
Non specific G-codes
Movement
- G11: Unretract Used while Firmware retraction is configured in your slicer, along G10
- G28: Move to Origin (Home) run macro home.g or homedelta.g
- G90: Set to Absolute Positioning
- G91: Set to Relative Positioning
- G92: Set Position Define actual position to be defined coordinates (zero if no parameters)
- M82: Set extruder to absolute mode
- M83: Set extruder to relative mode To be preferred for reliability
- M114: Get Current Position
Operation
- M0: Stop or Unconditional stop
- M3: Spindle On, Clockwise (CNC_specific)
- M18: Disable all stepper motors
- M84: Stop idle hold
- M80: ATX Power On
- M81: ATX Power Off
- M107: Fan Off
- M112: Emergency Stop
- M116: Wait
- M400: Wait for current moves to finish
- M220: Set speed factor override percentage
- M221: Set extrude factor override percentage
- M999: Restart after being stopped by error
Probing
- G30: Single Z-Probe
- G31: Set or Report Current Probe status Also allow probe offset definition
- G32: Probe Z and calculate Z plane
- M557: Set Z probe point
- M561: Set Identity Transform
Printing
- M20: List SD card
- M23: Select SD file
- M24: Start/resume SD print
- M25: Pause SD print
- M26: Set SD position
- M27: Report SD print status
- M28: Begin write to SD card
- M29: Stop writing to SD card
- M30: Delete a file on the SD card
- M32: Select file and start SD print
- M226: Gcode Initiated Pause
- M302: Allow cold extrudes
Physical interface
Heating
- M104: Set Extruder Temperature
- M105: Get Extruder Temperature
- M109: Set Extruder Temperature and Wait
- M140: Set Bed Temperature (Fast)
- M141: Set_Chamber Temperature (Fast)
- M190: Wait for bed temperature to reach target temp
Useful G-codes
- M206 Set home offset. Could be used to adjust head above bed during printing. M206 Z0.1 move up by 0.1mm
Configuration
- G21: Set Units to Millimeters
- M201: Set max printing_acceleration
- M203: Set maximum feedrate
- M206: Set home offset
- M304: Set PID parameters - Bed PID parameters for Bed - equivalent to M301 H0
- M350: Set microstepping mode
- M404: Filament width and nozzle diameter
- M502: Revert to the default "factory_settings."
- M666: Set delta endstop adjustment