How to fix Marlin random driver error detected coil short circuit crash (Trinamic TMC)
Problem:
When using Trinamic drivers with the Marlin 3D printer firmware, you might occasionally experience errors like
Send: N4193 G1 X12.345 Y34.567 E122.15252
Recv:
Recv: E driver error detected: 0x10136000
Recv: coil short circuit
Recv: X Y Z E
Recv: Enabled true true true true
Recv: Set current 2000 2000 2000 1000
Recv: RMS current 1999 1999 1999 990
Recv: MAX current 2819 2819 2819 1396
Recv: Run current 31/31 31/31 31/31 19/31
Recv: Hold current 15/31 15/31 15/31 9/31
Recv: Global scaler 167/256 167/256 167/256 133/256
Recv: CS actual 31/31 31/31 22/31 19/31
Recv: PWM scale 196716 33095745 65576 33488924
Recv: vsense
Recv: stealthChop true true true true
Recv: msteps 128 128 128 128
Recv: interp true true true true
Recv: tstep 171 678 max 1580
Recv: PWM thresh. 24 24 411 13
Recv: [mm/s] 102 102 3 41
Recv: OT prewarn false false false false
Recv: triggered
Recv: OTP false false false false
Recv: off time 4 4 4 4
Recv: blank time 24 24 24 24
Recv: hysteresis
Recv: -end 2 2 2 2
Recv: -start 1 1 1 1
Recv: Stallguard thrs 0 0 0 0
Recv: uStep count 62 32 227 497
Recv: DRVSTATUS X Y Z E
Recv: sg_result 0 0 395 0
Recv: stallguard
Recv: fsactive
Recv: stst * * *
Recv: olb
Recv: ola
Recv: s2gb *
Recv: s2ga
Recv: otpw
Recv: ot
Recv: Driver registers:
Recv: X 0x00:1F:40:00
Recv: Y 0x00:1F:40:00
Recv: Z 0x80:16:41:8B
Recv: E 0x10:13:60:00
Recv:
Recv:
Recv: echo:Driver error
Recv: Error:Printer halted. kill() called!
Changing monitoring state from "Printing" to "Error"
Solution
If the error always occurs at the start of each print, be sure to check your stepper motor setup for actual shorts! Measure the inducitivity using an LCR meter to be sure, it should be around the rated value for your motor! See this post for information about typical stepper motor inductivity.
If the error occurs occasionally, it is recommended in the datasheet that you use more conservative short detection settings.
You need to make the change this in Marlin/src/module/stepper/trinamic.cpp
.
Go to the section for the driver type you are using. In my example, this would be
#if HAS_DRIVER(TMC5160)
// ...
void tmc_init(/* ... */) {
// NOTE: tmc_init() is the function we need to insert code in!
}
#endif
Now insert, justĀ before the TERN(HYBRID_THRESHOLD, /* ... */)
line (if such a line does not exist, insert at the end of the function:
// Set more conservative short detection settings
st.shortfilter(3); // 3us SHORT filter
st.s2vs_level(15); // Lowest sensitivity short to supply voltage protection
st.s2g_level(15); // Lowest sensitivity short to ground protection
st.shortdelay(1); // 1.5us instead of 0.75us short delay
These are the most conservative settings possible using this setup.
Now retry your print.
In case this still doesn’t help, you can disable short protection entirely. Note that short protection exists to prevent damage to your stepper motor, your mainboard and your cabling, so you should only disable it if there is no other choice!
In order to disable short protection entirely, insert this code blockĀ instead of the conservative setting code block from above:
// Disable short protection entirely
st.diss2g(true);
st.diss2vs(true);
Tested with Marlin version 2.0.9.1