M-codes for EEPROM config

From RepRap
Revision as of 12:14, 14 March 2011 by AlexRa (talk | contribs)
Jump to: navigation, search

(This is proposed by AlexRa on 11-March-2011. I have a TechZone's Huxley with a somewhat modified firmware and going to add these commands to it. Then it probably shouldn't be very difficult to port the changes over to RepRap's mainstream firmware. The idea is very obvious and I'm sure other people thought about it before. If you know of a better / different way to do the configuration, please contribute).


This page is intended as an extension of the GCode page and, if the proposed codes get accepted by the community, may be eventually merged into that page.


Motivation:

There is a number of physical parameters, such as steps-per-mm on the 3 axes and, especially, on the extruder, that normally require adjustment whenever a reprap is built, modified or the extruder hot-end replaced.

Currently, those parameters are constants hardcoded in the firmware. A user has to install a toolchain for the firmware modification and re-flashing (e.g. Arduino) and has to have at least some understanding of C programming to make the necessary adjustments.

However, every AVR MCU used in RepRap motherboards has persistent EEPROM memory where all such configurations can be conveniently saved.

Proposed solution:

The most obvious way to configure the settings is by some custom GCode commands. At the moment, M-commands in the range 250..255 seem to be available. Below is a proposed set of M-codes for writing persistent settings into the motherboard:

Command Parameters Action
M255 [Xnn] [Ynn] [Znn] [Ennn] [Tn] Steps per mm for the axes and the extruder.

The command writes only the specified axes, reports back all stored values in the "X: Y: Z: E:" format. If issued without any parameters, it just reports the current settings. The optional Tn parameter specifies the extruder to be set (on multiple-extruder repraps). If E is specified and T isn't, the extrusion rate is set for all available extruders (usually there is only one anyway). In the FiveD firmware, these settings should replace the X|Y|Z|E0|E1_STEPS_PER_MM constants in configuration.h.

M254 [Xn] [Yn] [Zn] Set safe axes boundaries (build volume) in mm.

This is essential for printers with only one set of end-stops. Any movement beyond the defined boundaries should be blocked by the firmware. The command returns the current settings.

M253 [Xn] [Yn] [Zn] [En] [Tn] Maximum speed (mm/sec) for any of the

axes and the extruder. Especially the limiting value for the extruder is important, because it is often the extruder speed that limits the printer performance. The command returns the current settings.

M252 [Sn] [Tn] Set the max allowed temperature for the specified (or the default)

extruder. That makes sure that any wild temperature setting sent in GCode will be detected by the firmware and won't cause uncontrolled overheating. Without the S parameter, reports the current setting.

M251 [Sn] Same as M252, but for the hot bed. This is particularly important,

as some known hot bed designs (e.g. PCB-based) are sensitive to overheating.

M250 [Zn] [S0/1] [G28] "Z homing overshoot", in mm. There is currently no such parameter in the FiveD firmware.

The idea is that instead of carefully adjusting the Z opto stop, we set it slightly higher (1-3mm) than needed, then tell the printer how much it must move the head down after reaching the stop. This has 2 benefits: 1-st and most important, fine Z-adjustments can be done digitally without touching the opto and 2-nd, that seeking up-and-down motion is done at a safe distance from the plate (no more squeezing hot plastic all over the extruder tip). Such a command makes sense with or without actually writing the setting to EEPROM, so make the setting temporary by specifying 'S0'. The optional 'G28' (used as a parameter, which actually makes no difference for the parser) immediately does the homing, but only on the Z axis.

M249 [Pn] Set the head stabilization delay, in sec, as used by the M109 command. This allows the default delay of 40 seconds to be changed.

Usage

For obvious reasons the commands above are not intended to be generated in the regular printing GCode. They are to be entered either manually or via some configuration UI utility on the host computer while calibrating the printer.