Browse Source

Document set current command.

Marek Bel 4 years ago
parent
commit
8c7015df53
2 changed files with 77 additions and 1 deletions
  1. 2 1
      Firmware/Marlin_main.cpp
  2. 75 0
      Firmware/tmc2130.cpp

+ 2 - 1
Firmware/Marlin_main.cpp

@@ -7444,11 +7444,12 @@ Sigma_Exit:
     break;
 #endif
 
-    //! ### M907 - Set digital trimpot motor current using axis codes
+    //! ### M907 - Set digital trimpot motor current in mA using axis codes
     // ---------------------------------------------------------------
     case 907:
     {
 #ifdef TMC2130
+        //! See tmc2130_cur2val() for translation to 0 .. 63 range
         for (int i = 0; i < NUM_AXIS; i++)
 			if(code_seen(axis_codes[i]))
 			{

+ 75 - 0
Firmware/tmc2130.cpp

@@ -1,3 +1,5 @@
+//! @file
+
 #include "Marlin.h"
 
 #ifdef TMC2130
@@ -1009,6 +1011,79 @@ bool tmc2130_home_calibrate(uint8_t axis)
 	return true;
 }
 
+
+//! @brief Translate current to tmc2130 vsense and IHOLD or IRUN
+//! @param cur current in mA
+//! @return 0 .. 63
+//! @n most significant bit is CHOPCONF vsense bit (sense resistor voltage based current scaling)
+//! @n rest is to be used in IRUN or IHOLD register
+//!
+//! | mA   | trinamic register | note |
+//! | ---  | ---               | ---  |
+//! |    0 |  0 | doesn't mean current off, lowest current is 1/32 current with vsense low range |
+//! |   30 |  1 | |
+//! |   40 |  2 | |
+//! |   60 |  3 | |
+//! |   90 |  4 | |
+//! |  100 |  5 | |
+//! |  120 |  6 | |
+//! |  130 |  7 | |
+//! |  150 |  8 | |
+//! |  180 |  9 | |
+//! |  190 | 10 | |
+//! |  210 | 11 | |
+//! |  230 | 12 | |
+//! |  240 | 13 | |
+//! |  250 | 13 | |
+//! |  260 | 14 | |
+//! |  280 | 15 | |
+//! |  300 | 16 | |
+//! |  320 | 17 | |
+//! |  340 | 18 | |
+//! |  350 | 19 | |
+//! |  370 | 20 | |
+//! |  390 | 21 | |
+//! |  410 | 22 | |
+//! |  430 | 23 | |
+//! |  450 | 24 | |
+//! |  460 | 25 | |
+//! |  480 | 26 | |
+//! |  500 | 27 | |
+//! |  520 | 28 | |
+//! |  535 | 29 | |
+//! |  N/D | 30 | extruder default |
+//! |  540 | 33 | |
+//! |  560 | 34 | |
+//! |  580 | 35 | |
+//! |  590 | 36 | farm mode extruder default |
+//! |  610 | 37 | |
+//! |  630 | 38 | |
+//! |  640 | 39 | |
+//! |  660 | 40 | |
+//! |  670 | 41 | |
+//! |  690 | 42 | |
+//! |  710 | 43 | |
+//! |  720 | 44 | |
+//! |  730 | 45 | |
+//! |  760 | 46 | |
+//! |  770 | 47 | |
+//! |  790 | 48 | |
+//! |  810 | 49 | |
+//! |  820 | 50 | |
+//! |  840 | 51 | |
+//! |  850 | 52 | |
+//! |  870 | 53 | |
+//! |  890 | 54 | |
+//! |  900 | 55 | |
+//! |  920 | 56 | |
+//! |  940 | 57 | |
+//! |  950 | 58 | |
+//! |  970 | 59 | |
+//! |  980 | 60 | |
+//! | 1000 | 61 | |
+//! | 1020 | 62 | |
+//! | 1029 | 63 | |
+
 uint8_t tmc2130_cur2val(float cur)
 {
 	if (cur < 0) cur = 0; //limit min