Browse Source

Prevent current step-down going negative

Addressing #11348
Scott Lahteine 6 years ago
parent
commit
b779b42ffd
1 changed files with 1 additions and 1 deletions
  1. 1
    1
      Marlin/src/feature/tmc_util.cpp

+ 1
- 1
Marlin/src/feature/tmc_util.cpp View File

153
     #if CURRENT_STEP_DOWN > 0
153
     #if CURRENT_STEP_DOWN > 0
154
       // Decrease current if is_otpw is true and driver is enabled and there's been more than 4 warnings
154
       // Decrease current if is_otpw is true and driver is enabled and there's been more than 4 warnings
155
       if (data.is_otpw && st.isEnabled() && st.otpw_count > 4) {
155
       if (data.is_otpw && st.isEnabled() && st.otpw_count > 4) {
156
-        st.rms_current(st.getMilliamps() - (CURRENT_STEP_DOWN));
156
+        st.rms_current(MAX(int16_t(st.getMilliamps() - (CURRENT_STEP_DOWN)), 0));
157
         #if ENABLED(REPORT_CURRENT_CHANGE)
157
         #if ENABLED(REPORT_CURRENT_CHANGE)
158
           st.printLabel();
158
           st.printLabel();
159
           SERIAL_ECHOLNPAIR(" current decreased to ", st.getMilliamps());
159
           SERIAL_ECHOLNPAIR(" current decreased to ", st.getMilliamps());

Loading…
Cancel
Save