Marlin inspired Configuration.h for Reprap Firmware
-
I have been following RRF for sometime and decided to take the plunge and had some difficulties converting from Marlin. In my research I stumbled across the GCode Meta commands wiki and thought this would be a great opportunity to learn something new.
I have started creating a Configuration.g which will allow for a user to simply port over values from Marlin and have a similar printing experience. Right now I am focusing on cartesian support with a bltouch to see if this project is feasible.
If anyone has ideas, resources or advice for debugging I would greatly appreciate it.
Repo: https://github.com/brewpirate/marlin-rrf/
Configuration.g
;=========================================================================== ;============================= Getting Started ============================= ;=========================================================================== global CUSTOM_MACHINE_NAME = "Ender 3" ;=========================================================================== ;============================= Thermal Settings ============================ ;=========================================================================== ; @see https://duet3d.dozuki.com/Wiki/M308 ; ; Options ; --------------------- ; thermistor ; pt1000 ; rtd-max31865 ; thermocouple-max31855 ; thermocouple-max31856 ; linear-analog ; dht21 ; dht22 ; dhthumidity ; current-loop-pyro ; drivers ; mcu-temp ; drivers-duex global TEMP_SENSOR_0 = "thermistor" global TEMP_SENSOR_BED = "thermistor" global HEATER_0_MAXTEMP = 275 global BED_MAXTEMP = 150 ; PID Hotend ; --------------------- ;global PIDTEMP = true ;global BANG_MAX 255 ;global PID_K1 0.95 ;global DEFAULT_Kp_LIST { 22.20, 22.20 } ;global DEFAULT_Ki_LIST { 1.08, 1.08 } ;global DEFAULT_Kd_LIST { 114.00, 114.00 } ; PID Bed Heating ; --------------------- ;global PIDTEMPBED ;global MAX_BED_POWER 255 ;global DEFAULT_bedKp 10.00 ;global DEFAULT_bedKi .023 ;global DEFAULT_bedKd 305.4 ;=========================================================================== ;============================== Endstop Settings =========================== ;=========================================================================== ; Specify here all the endstop connectors that are connected to any endstop or probe. ; Almost all printers will be using one per axis. Probes will use one or more of the ; extra connectors. Leave undefined any used for non-endstop and non-probe purposes. global USE_XMIN_PLUG = true global USE_YMIN_PLUG = true global USE_ZMIN_PLUG = true ;global USE_XMAX_PLUG = true ;global SE_YMAX_PLUG = true ;global USE_ZMAX_PLUG = true ; Mechanical endstop with COM to ground and NC to Signal uses "false" here (most common setup). ;global X_MIN_ENDSTOP_INVERTING = true ; Set to true to invert the logic of the endstop. ;global Y_MIN_ENDSTOP_INVERTING = true ; Set to true to invert the logic of the endstop. ;global Z_MIN_ENDSTOP_INVERTING = true ; Set to true to invert the logic of the endstop. ;global X_MAX_ENDSTOP_INVERTING = true ; Set to true to invert the logic of the endstop. ;global Y_MAX_ENDSTOP_INVERTING = true ; Set to true to invert the logic of the endstop. ;global Z_MAX_ENDSTOP_INVERTING = true ; Set to true to invert the logic of the endstop. ;=========================================================================== ;============================= Mechanical Settings ========================= ;=========================================================================== ;============================================================================= ;============================== Movement Settings ============================ ;============================================================================= ;globalDEFAULT_AXIS_STEPS_PER_UNIT { 80, 80, 400, 500 } ;global DEFAULT_MAX_FEEDRATE { 300, 300, 5, 25 } ;global MAX_FEEDRATE_EDIT_VALUES { 600, 600, 10, 50 } ;global DEFAULT_MAX_ACCELERATION { 3000, 3000, 100, 10000 } ; X Axis ; --------------------- global X_MAX_CURRENT = 800 global X_MICROSTEPS = 16 global X_STEPS_PER_MM = 80.00 global X_MAX_SPEED = 9000.00 global X_MAX_SPEED_CHANGE = 1200.00 global X_ACCELERATION = 500.00 ;global INVERT_X_DIR = false ; Y Axis ; --------------------- global Y_MAX_CURRENT = 800 global Y_MICROSTEPS = 16 global Y_STEPS_PER_MM = 80.00 global Y_MAX_SPEED = 9000.00 global Y_MAX_SPEED_CHANGE = 1200.00 global Y_ACCELERATION = 500.00 ;global INVERT_Y_DIR = false ; Z Axis ; --------------------- global Z_MAX_CURRENT = 800 global Z_MICROSTEPS = 16 global Z_STEPS_PER_MM = 400.00 global Z_MAX_SPEED = 180.00 global Z_MAX_SPEED_CHANGE = 24.00 global Z_ACCELERATION = 100.00 ;global INVERT_Z_DIR = false ; Extruder ; --------------------- global E0_MAX_CURRENT = 800 global E0_MICROSTEPS = 16 global E0_STEPS_PER_MM = 93.00 global E0_MAX_SPEED = 6000.00 global E0_MAX_SPEED_CHANGE = 300.00 global E0_ACCELERATION = 5000.00 ;global INVERT_E0_DIR = false ; Jerk ; --------------------- ;global DEFAULT_XJERK 10.0 ;global DEFAULT_YJERK 10.0 ;global DEFAULT_ZJERK 0.3 ;=========================================================================== ;============================= Z Probe Options ============================= ;=========================================================================== ;/** ; * Probe Type ; * ; * Allen Key Probes, Servo Probes, Z-Sled Probes, FIX_MOUNTED_PROBE, etc. ; * Activate one of these to use Auto Bed Leveling below. ; */ ;** ; * The BLTouch probe uses a Hall effect sensor and emulates a servo. ; */ ;global BLTOUCH ;** ; * Nozzle-to-Probe offsets { X, Y, Z } ; * ; * X and Y offset ; * Use a caliper or ruler to measure the distance from the tip of ; * the Nozzle to the center-point of the Probe in the X and Y axes. ; * ; * Z offset ; * - For the Z offset use your best known value and adjust at runtime. ; * - Common probes trigger below the nozzle and have negative values for Z offset. ; * - Probes triggering above the nozzle height are uncommon but do exist. When using ; * probes such as this, carefully set Z_CLEARANCE_DEPLOY_PROBE and Z_CLEARANCE_BETWEEN_PROBES ; * to avoid collisions during probing. ; * ; * Tune and Adjust ; * - Probe Offsets can be tuned at runtime with 'M851', LCD menus, babystepping, etc. ; * - PROBE_OFFSET_WIZARD (configuration_adv.h) can be used for setting the Z offset. ; * ; * Assuming the typical work area orientation: ; * - Probe to RIGHT of the Nozzle has a Positive X offset ; * - Probe to LEFT of the Nozzle has a Negative X offset ; * - Probe in BACK of the Nozzle has a Positive Y offset ; * - Probe in FRONT of the Nozzle has a Negative Y offset ; * ; * ; * +-- BACK ---+ ; * | [+] | ; * L | 1 | R <-- Example "1" (right+, back+) ; * E | 2 | I <-- Example "2" ( left-, back+) ; * F |[-] N [+]| G <-- Nozzle ; * T | 3 | H <-- Example "3" (right+, front-) ; * | 4 | T <-- Example "4" ( left-, front-) ; * | [-] | ; * O-- FRONT --+ ; */ ;global NOZZLE_TO_PROBE_OFFSET { 10, 10, 0 } ; Most probes should stay away from the edges of the bed, but ; with NOZZLE_AS_PROBE this can be negative for a wider probing area. ;global PROBING_MARGIN 10 ; X and Y axis travel speed (mm/min) between probes ;global XY_PROBE_FEEDRATE (133*60) ; Feedrate (mm/min) for the first approach when double-probing (MULTIPLE_PROBING == 2) ;globalZ_PROBE_FEEDRATE_FAST (4*60) ; Feedrate (mm/min) for the "accurate" probe of each point ;global Z_PROBE_FEEDRATE_SLOW (Z_PROBE_FEEDRATE_FAST / 2) ; The size of the printable area global X_BED_SIZE = 235 global Y_BED_SIZE = 235 ; Travel limits (mm) after homing, corresponding to endstop positions. global X_MIN_POS = 0 global Y_MIN_POS = 0 global Z_MIN_POS = 0 global Z_MAX_POS = 260
config.g
; Configuration file for Duet Maestro (firmware version 3.3) ; executed by the firmware on start-up ; ; generated by RepRapFirmware Configuration Tool v3.3.10 on Wed Feb 23 2022 07:28:14 GMT-0800 (Pacific Standard Time) ; Load Configuration M98 P"Configuration.g" ; General preferences G90 ; send absolute coordinates... M83 ; ...but relative extruder moves M550 P{global.CUSTOM_MACHINE_NAME} ; set printer name ; Network M98 P"modules/network.g" ; Drives M98 P"modules/drives.g" ; Axis Limits M208 X{global.X_MIN_POS} Y{global.Y_MIN_POS} Z{global.Z_MIN_POS} S1 ; set axis minima M208 X{global.X_BED_SIZE} Y{global.Y_BED_SIZE} Z{global.Z_MAX_POS} S0 ; set axis maxima ; Endstops M98 P"modules/endstops.g" ; Z-Probe M98 P"modules/zprobe.g" ; Heaters M98 P"modules/thermal.g" ; Fans M98 P"modules/fans.g" ; Tools M98 P"modules/tools.g" ; Custom settings are not defined ; Miscellaneous M501 ; load saved parameters from non-volatile memory M911 S10 R11 P"M913 X0 Y0 G91 M83 G1 Z3 E-5 F1000" ; set voltage thresholds and actions to run on power loss
/sys/modules/endstops.g
; Declare base pin names for endstops var X_MIN_PIN_BASE = "xstop" var Y_MIN_PIN_BASE = "ystop" var Z_MIN_PIN_BASE = "zstop" var X_MAX_PIN_BASE = "xstop" var Y_MAX_PIN_BASE = "ystop" var Z_MAX_PIN_BASE = "zstop" ; X if exists(global.USE_XMIN_PLUG) var X_MIN_PIN = {exists(global.X_MIN_ENDSTOP_INVERTING) ? ("!" ^ var.X_MIN_PIN_BASE) : var.X_MIN_PIN_BASE} M574 X1 S1 P{var.X_MIN_PIN} if exists(global.USE_XMAX_PLUG) var X_MAX_PIN = {exists(global.X_MAX_ENDSTOP_INVERTING) ? ("!" ^ var.X_MAX_PIN_BASE) : var.X_MAX_PIN_BASE} M574 X2 S1 P{var.X_MAX_PIN} ; Y if exists(global.USE_YMIN_PLUG) var Y_MIN_PIN = {exists(global.Y_MIN_ENDSTOP_INVERTING) ? ("!" ^ var.Y_MIN_PIN_BASE) : var.Y_MIN_PIN_BASE} M574 Y1 S1 P{var.Y_MIN_PIN} if exists(global.USE_YMAX_PLUG) var Y_MAX_PIN = {exists(global.Y_MAX_ENDSTOP_INVERTING) ? ("!" ^ var.Y_MAX_PIN_BASE) : var.Y_MAX_PIN_BASE} M574 Y2 S1 P{var.Y_MAX_PIN} ; Z if exists(global.USE_ZMIN_PLUG) var Z_MIN_PIN = {exists(global.Z_MIN_ENDSTOP_INVERTING) ? ("!" ^ var.Z_MIN_PIN_BASE) : var.Z_MIN_PIN_BASE} M574 Z1 S1 P{var.Z_MIN_PIN} if exists(global.USE_ZMAX_PLUG) var Z_MAX_PIN = {exists(global.Z_MAX_ENDSTOP_INVERTING) ? ("!" ^ var.Z_MAX_PIN_BASE) : var.Z_MAX_PIN_BASE} M574 Z2 S1 P{var.Z_MAX_PIN}
-
Have you tested this on different boards? I ran into issues with using too many variables in the past and have since cut back ...
-
I have not tested many boards, I am very early into this project so I will have to keep that in mind. I was planning on having a machine type gcode
/sys/machine/cartesian.g
that would create all the global variables and then those values would be set with conditional Gcode. Would prevent creating unnecessary variables but without knowing what that limit is... guess I need to do some more research!I do not see a way to unset variables so I might have to be more strict with the use of local vs global variables. Hummm....
-
Since most of the global variables created in the configuration file.g are no longer needed after config.g runs, and if "too many globals" can become a problem as @oliof says, then this is a good use case for a way to "undeclare" a global variable and free up the memory. I could see an additional gcode file called from the end of config.g that would do the cleanup.
-
I would not use a limited and valuable resource like variables to hold constant values such as those needed for configuration.
Frederick
-
Maybe it'd be better to have this static configuration file be processed and generating a normal config.g. If you want you can do this with metacommands/gcode, but it probably would be nicer to do it with some kind of web based configurator ... since most people find the Configuration.h and Configuration_adv.h unwieldy unless they've spent a lot of time with it (I am more comfortable with it than I'd like to admit).
-
I appreciate all the feedback, I have been thinking about this and going to scrap the idea and take a stab at a configuration plugin. The deeper I get the more problems I am seeing with using GCode and being a sr. frontend Vue developer I should be able to tackle this.
Stay tuned