The printer defaults that are wrong for a robot arm

Marlin's defaults are good defaults for a 3D printer. A few of them are quietly wrong for a robot arm, and you only find out when the arm does something odd.

Code: marlin-firmware on GitHub · Watch: Pick and place with a new gripper · Smooth arm motion

Marlin’s defaults are good defaults for a 3D printer. A few of them are quietly wrong for a robot arm, and you only find out when the arm does something odd. Some of these show up as fixes in the fork’s commit history. A couple are still sitting in the config.

1. Motors that switch off when idle

Stock Marlin turns idle motors off after two minutes:

#define DEFAULT_STEPPER_TIMEOUT_SEC 120 #define DISABLE_IDLE_X #define DISABLE_IDLE_Y #define DISABLE_IDLE_Z // Disable if the nozzle could fall onto your printed part!

On a printer, that saves power and keeps the motors cool. On an arm, it means two minutes after the last move, the shoulder lets go and the arm folds under its own weight. Worse, Marlin still thinks every joint is where it left it, so the next move starts from a position that isn’t true any more.

That comment on Z says it all: on an arm, every joint is a Z axis. One of the first commits in the fork comments all three out:

//#define DISABLE_IDLE_X
//#define DISABLE_IDLE_Y
//#define DISABLE_IDLE_Z

The motors can still be switched off on purpose with M84 (the “motors off” button in Pronterface sends it). If you want a safety net for that, Marlin has two options, both still commented out in this config, that its own comments suggest using together:

#define NO_MOTION_BEFORE_HOMING // refuse to move until homed #define HOME_AFTER_DEACTIVATE // after motors go off, require homing again

2. Limits that start from the wrong place

Software endstops keep each joint inside its range, which on an arm is what protects the cables. But they’re measured from home, and at power-on Marlin doesn’t know where home is. It assumes every axis is at 0.

If the arm was switched off halfway through a move, “0” is wherever it happens to be resting. A move to 150° might be legal by the numbers and still drive a joint into its own frame. NO_MOTION_BEFORE_HOMING from above fixes this too, by refusing to move at all until you’ve run G28.

3. A 300 ms pause after every servo command

Printers mostly use servos to deploy a bed probe, so Marlin waits after each servo command to let it get there:

#define SERVO_DELAY { 300 }

The arm uses M280 for the gripper, several times in every pick and place. At 300 ms each, that’s a pause around every grab and every release. In May that went down to 10 ms for both servos:

#define NUM_SERVOS 2
#define SERVO_DELAY { 10, 10 }

The catch is that the next move now starts before the gripper has finished closing. An MG90S needs about 0.1 s per 60° with no load. So the pause moves from the firmware into the G-code, only where it matters:

M280 P0 S20    ; close the gripper
G4 P200        ; wait 200 ms before moving with it
G1 Z30 F600    ; move away

Opening the gripper over a drop point doesn’t need the wait. Closing it on a part does.

4. Acceleration sized for a print head

Stock Marlin allows 3000 mm/s² on X and Y, because a print head is light and short. The fork’s history goes 1000, then 800, and settles on:

#define DEFAULT_MAX_ACCELERATION { 500, 500, 500, 500, 500, 500 }  // degrees/s²

Angular acceleration gets multiplied by distance at the tip. 500°/s² is about 8.7 rad/s², so a gripper 30 cm from the shoulder sees about 2.6 m/s². That’s already a lot for a printed arm holding something.

5. Stop means stop

Normally Marlin runs commands in order. With a few commands waiting in the input buffer and up to 16 moves in the planner, an M112 sent in a panic sits behind all of them.

The emergency parser fixes that. It watches the serial input as bytes arrive and acts on a few commands immediately. It’s off by default, and the fork turns it on in its first config commit:

#define EMERGENCY_PARSER

Then you have two buttons:

  • M410 stops all motors straight away, with no deceleration. They stay powered and hold the arm, but Marlin’s idea of position may now be off, so home again.
  • M112 kills everything and needs a reset.

For an arm that’s about to hit something, M410 is usually the better button, because a killed arm can drop. Either way, a software stop is not a safety system. A physical switch that cuts motor power doesn’t depend on the firmware listening.

6. Defines that do nothing

This one isn’t a Marlin default. It’s a C habit worth knowing about.

The config has these lines, added with the extra axes and the servos:

#define X_ROTATES #define Y_ROTATES #define Z_ROTATES

#define SERVO0_MIN_ANGLE 0 #define SERVO0_MAX_ANGLE 180

They look reasonable, and the build is happy. But Marlin never reads them. AXIS4_ROTATES and friends exist for the extra axes, and nothing like them exists for X, Y and Z, which stay linear axes as far as Marlin knows. It still works, because steps per unit doesn’t care what the unit is called: one “millimetre” on X is simply one degree of that joint.

The servo commit also added a SERVO1_PIN line to the STM32F4 Octopus pin file. The Octopus Pro V1.1 uses an STM32H7 chip and a different pin file, so that edit has no effect either. What actually makes the second servo work is the same line in Configuration.h.

The preprocessor never warns about a define nobody reads. It’s the firmware version of a misspelled key in a config object with no schema. The check is one command:

grep -rn “SERVO0_MIN_ANGLE” Marlin/src # no results: Marlin never reads it grep -rn “AXIS4_ROTATES” Marlin/src # results: this one does something

If a define you added doesn’t appear anywhere in Marlin/src, it isn’t doing anything, whatever its name suggests.