How to get or set Trinamic TMC stepper motor current in Marlin firmware
In Marlin, you can dynamically configure the stepper motor current for Trinamic stepper drivers like the TMC2208 or the TMC5160.
Changing the motor current via G-Code
The easiest option is by using G-Codes. In order to set the stepper motor current for X , Y and Z to 2 Amperes (2000 mA), use M906 like this:
set_trinamic_current.gcode
M906X2000Y2000Z2000Now save the settings to the EEPROM using
save_eeprom.gcode
M500You can also query the current stepper motor current using
m906_output.txt
M906
X driver current: 2000
Y driver current: 2000
Z driver current: 2000
E driver current: 800
okChanging the motor current in the config file
You can also set default stepper motor current values in the Marlin config files. Note that these will be overridden by any value in the EEPROM.
In Configuration_adv.h, look for
Configuration_adv.h
#if HAS_TRINAMIC_CONFIGwhich contains axis definitions like
Configuration_adv.h
#if AXIS_IS_TMC(X)
#define X_CURRENT 800 // (mA) RMS current. Multiply by 1.414 for peak current.
#define X_CURRENT_HOME X_CURRENT // (mA) RMS current for sensorless homing
#define X_MICROSTEPS 32 // 0..256
#define X_RSENSE 0.11
#define X_CHAIN_POS -1 // -1..0: Not chained. 1: MCU MOSI connected. 2: Next in chain, ...
//#define X_INTERPOLATE true // Enable to override 'INTERPOLATE' for the X axis
#endifChange the value in the line
Configuration_adv.h
#define X_CURRENT 800 // (mA) RMS current. Multiply by 1.414 for peak current.
so, for example to set 2A (=2000 mA), set it to
Configuration_adv.h
#define X_CURRENT 2000 // (mA) RMS current. Multiply by 1.414 for peak current.
Check out similar posts by category:
3D Printing
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow