From e8b10d2836a126d18c08a014afb53443e51efaee Mon Sep 17 00:00:00 2001 From: Elijah Snyder Date: Thu, 7 Jan 2016 11:05:30 -0600 Subject: [PATCH 1/2] Adding PWM_MOTOR_CURRENT flag to help expose PWM_MOTOR_CURRENTS in Configuration_adv.h similar to DIGIPOT_MOTOR_CURRENT --- Marlin/Configuration_adv.h | 3 +++ Marlin/stepper.cpp | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index ae167f9c05..e8f3dedca2 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -274,6 +274,9 @@ // Motor Current setting (Only functional when motor driver current ref pins are connected to a digital trimpot on supported boards) #define DIGIPOT_MOTOR_CURRENT {135,135,135,135,135} // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A) +// Motor Current controlled via PWM (Only functional when motor driver current is driven by PWM on supported boards) +#define PWM_MOTOR_CURRENT {1300, 1300, 1250} // Values in milliamps + // uncomment to enable an I2C based DIGIPOT like on the Azteeg X3 Pro //#define DIGIPOT_I2C // Number of channels available for I2C digipot, For Azteeg X3 Pro we have 8 diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index 1a4a167992..b7fb2c5378 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -88,7 +88,10 @@ static volatile char endstop_hit_bits = 0; // use X_MIN, Y_MIN, Z_MIN and Z_MIN_ #endif #if PIN_EXISTS(MOTOR_CURRENT_PWM_XY) - int motor_current_setting[3] = DEFAULT_PWM_MOTOR_CURRENT; + #ifndef PWM_MOTOR_CURRENT + #define PWM_MOTOR_CURRENT DEFAULT_PWM_MOTOR_CURRENT + #endif + int motor_current_setting[3] = PWM_MOTOR_CURRENT; #endif static bool check_endstops = true; From 0c48eaf3de45b4cdec2780d05fc9a612cccc60cf Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 11 Mar 2016 02:24:22 -0800 Subject: [PATCH 2/2] Expose motor current in more configs, disable by default --- Marlin/Configuration_adv.h | 4 ++-- Marlin/example_configurations/Felix/Configuration_adv.h | 3 +++ Marlin/example_configurations/Hephestos/Configuration_adv.h | 3 +++ Marlin/example_configurations/K8200/Configuration_adv.h | 3 +++ Marlin/example_configurations/RigidBot/Configuration_adv.h | 3 +++ Marlin/example_configurations/SCARA/Configuration_adv.h | 3 +++ Marlin/example_configurations/TAZ4/Configuration_adv.h | 3 +++ Marlin/example_configurations/WITBOX/Configuration_adv.h | 3 +++ .../example_configurations/delta/biv2.5/Configuration_adv.h | 3 +++ .../example_configurations/delta/generic/Configuration_adv.h | 3 +++ .../delta/kossel_mini/Configuration_adv.h | 3 +++ .../delta/kossel_pro/Configuration_adv.h | 3 +++ .../delta/kossel_xl/Configuration_adv.h | 3 +++ Marlin/example_configurations/makibox/Configuration_adv.h | 3 +++ .../example_configurations/tvrrug/Round2/Configuration_adv.h | 3 +++ Marlin/stepper.cpp | 2 +- 16 files changed, 45 insertions(+), 3 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index e8f3dedca2..edc48e3a91 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -274,8 +274,8 @@ // Motor Current setting (Only functional when motor driver current ref pins are connected to a digital trimpot on supported boards) #define DIGIPOT_MOTOR_CURRENT {135,135,135,135,135} // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A) -// Motor Current controlled via PWM (Only functional when motor driver current is driven by PWM on supported boards) -#define PWM_MOTOR_CURRENT {1300, 1300, 1250} // Values in milliamps +// Motor Current controlled via PWM (Overridable on supported boards with PWM-driven motor driver current) +//#define PWM_MOTOR_CURRENT {1300, 1300, 1250} // Values in milliamps // uncomment to enable an I2C based DIGIPOT like on the Azteeg X3 Pro //#define DIGIPOT_I2C diff --git a/Marlin/example_configurations/Felix/Configuration_adv.h b/Marlin/example_configurations/Felix/Configuration_adv.h index b8a35a8555..7d6cf00863 100644 --- a/Marlin/example_configurations/Felix/Configuration_adv.h +++ b/Marlin/example_configurations/Felix/Configuration_adv.h @@ -274,6 +274,9 @@ // Motor Current setting (Only functional when motor driver current ref pins are connected to a digital trimpot on supported boards) #define DIGIPOT_MOTOR_CURRENT {135,135,135,135,135} // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A) +// Motor Current controlled via PWM (Overridable on supported boards with PWM-driven motor driver current) +//#define PWM_MOTOR_CURRENT {1300, 1300, 1250} // Values in milliamps + // uncomment to enable an I2C based DIGIPOT like on the Azteeg X3 Pro //#define DIGIPOT_I2C // Number of channels available for I2C digipot, For Azteeg X3 Pro we have 8 diff --git a/Marlin/example_configurations/Hephestos/Configuration_adv.h b/Marlin/example_configurations/Hephestos/Configuration_adv.h index 33570f9fec..063b6c5723 100644 --- a/Marlin/example_configurations/Hephestos/Configuration_adv.h +++ b/Marlin/example_configurations/Hephestos/Configuration_adv.h @@ -274,6 +274,9 @@ // Motor Current setting (Only functional when motor driver current ref pins are connected to a digital trimpot on supported boards) #define DIGIPOT_MOTOR_CURRENT {135,135,135,135,135} // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A) +// Motor Current controlled via PWM (Overridable on supported boards with PWM-driven motor driver current) +//#define PWM_MOTOR_CURRENT {1300, 1300, 1250} // Values in milliamps + // uncomment to enable an I2C based DIGIPOT like on the Azteeg X3 Pro //#define DIGIPOT_I2C // Number of channels available for I2C digipot, For Azteeg X3 Pro we have 8 diff --git a/Marlin/example_configurations/K8200/Configuration_adv.h b/Marlin/example_configurations/K8200/Configuration_adv.h index ef1b849025..5fcecf308b 100644 --- a/Marlin/example_configurations/K8200/Configuration_adv.h +++ b/Marlin/example_configurations/K8200/Configuration_adv.h @@ -279,6 +279,9 @@ // Motor Current setting (Only functional when motor driver current ref pins are connected to a digital trimpot on supported boards) #define DIGIPOT_MOTOR_CURRENT {135,135,135,135,135} // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A) +// Motor Current controlled via PWM (Overridable on supported boards with PWM-driven motor driver current) +//#define PWM_MOTOR_CURRENT {1300, 1300, 1250} // Values in milliamps + // uncomment to enable an I2C based DIGIPOT like on the Azteeg X3 Pro //#define DIGIPOT_I2C // Number of channels available for I2C digipot, For Azteeg X3 Pro we have 8 diff --git a/Marlin/example_configurations/RigidBot/Configuration_adv.h b/Marlin/example_configurations/RigidBot/Configuration_adv.h index 9cdb3dd881..2a1ca9b706 100644 --- a/Marlin/example_configurations/RigidBot/Configuration_adv.h +++ b/Marlin/example_configurations/RigidBot/Configuration_adv.h @@ -274,6 +274,9 @@ // Motor Current setting (Only functional when motor driver current ref pins are connected to a digital trimpot on supported boards) #define DIGIPOT_MOTOR_CURRENT {135,135,135,135,135} // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A) +// Motor Current controlled via PWM (Overridable on supported boards with PWM-driven motor driver current) +//#define PWM_MOTOR_CURRENT {1300, 1300, 1250} // Values in milliamps + // uncomment to enable an I2C based DIGIPOT like on the Azteeg X3 Pro //#define DIGIPOT_I2C // Number of channels available for I2C digipot, For Azteeg X3 Pro we have 8 diff --git a/Marlin/example_configurations/SCARA/Configuration_adv.h b/Marlin/example_configurations/SCARA/Configuration_adv.h index f6bcaa43d3..de9cab4a86 100644 --- a/Marlin/example_configurations/SCARA/Configuration_adv.h +++ b/Marlin/example_configurations/SCARA/Configuration_adv.h @@ -274,6 +274,9 @@ // Motor Current setting (Only functional when motor driver current ref pins are connected to a digital trimpot on supported boards) #define DIGIPOT_MOTOR_CURRENT {135,135,135,135,135} // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A) +// Motor Current controlled via PWM (Overridable on supported boards with PWM-driven motor driver current) +//#define PWM_MOTOR_CURRENT {1300, 1300, 1250} // Values in milliamps + // uncomment to enable an I2C based DIGIPOT like on the Azteeg X3 Pro //#define DIGIPOT_I2C // Number of channels available for I2C digipot, For Azteeg X3 Pro we have 8 diff --git a/Marlin/example_configurations/TAZ4/Configuration_adv.h b/Marlin/example_configurations/TAZ4/Configuration_adv.h index 58bf4bd363..ef98c649bb 100644 --- a/Marlin/example_configurations/TAZ4/Configuration_adv.h +++ b/Marlin/example_configurations/TAZ4/Configuration_adv.h @@ -282,6 +282,9 @@ // Motor Current setting (Only functional when motor driver current ref pins are connected to a digital trimpot on supported boards) #define DIGIPOT_MOTOR_CURRENT {175,175,240,135,135} // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A) +// Motor Current controlled via PWM (Overridable on supported boards with PWM-driven motor driver current) +//#define PWM_MOTOR_CURRENT {1300, 1300, 1250} // Values in milliamps + // uncomment to enable an I2C based DIGIPOT like on the Azteeg X3 Pro //#define DIGIPOT_I2C // Number of channels available for I2C digipot, For Azteeg X3 Pro we have 8 diff --git a/Marlin/example_configurations/WITBOX/Configuration_adv.h b/Marlin/example_configurations/WITBOX/Configuration_adv.h index 33570f9fec..063b6c5723 100644 --- a/Marlin/example_configurations/WITBOX/Configuration_adv.h +++ b/Marlin/example_configurations/WITBOX/Configuration_adv.h @@ -274,6 +274,9 @@ // Motor Current setting (Only functional when motor driver current ref pins are connected to a digital trimpot on supported boards) #define DIGIPOT_MOTOR_CURRENT {135,135,135,135,135} // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A) +// Motor Current controlled via PWM (Overridable on supported boards with PWM-driven motor driver current) +//#define PWM_MOTOR_CURRENT {1300, 1300, 1250} // Values in milliamps + // uncomment to enable an I2C based DIGIPOT like on the Azteeg X3 Pro //#define DIGIPOT_I2C // Number of channels available for I2C digipot, For Azteeg X3 Pro we have 8 diff --git a/Marlin/example_configurations/delta/biv2.5/Configuration_adv.h b/Marlin/example_configurations/delta/biv2.5/Configuration_adv.h index 95671a88fb..390f81ef7d 100644 --- a/Marlin/example_configurations/delta/biv2.5/Configuration_adv.h +++ b/Marlin/example_configurations/delta/biv2.5/Configuration_adv.h @@ -276,6 +276,9 @@ // Motor Current setting (Only functional when motor driver current ref pins are connected to a digital trimpot on supported boards) #define DIGIPOT_MOTOR_CURRENT {135,135,135,135,135} // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A) +// Motor Current controlled via PWM (Overridable on supported boards with PWM-driven motor driver current) +//#define PWM_MOTOR_CURRENT {1300, 1300, 1250} // Values in milliamps + // uncomment to enable an I2C based DIGIPOT like on the Azteeg X3 Pro //#define DIGIPOT_I2C // Number of channels available for I2C digipot, For Azteeg X3 Pro we have 8 diff --git a/Marlin/example_configurations/delta/generic/Configuration_adv.h b/Marlin/example_configurations/delta/generic/Configuration_adv.h index e0097db346..b6aeaf6821 100644 --- a/Marlin/example_configurations/delta/generic/Configuration_adv.h +++ b/Marlin/example_configurations/delta/generic/Configuration_adv.h @@ -276,6 +276,9 @@ // Motor Current setting (Only functional when motor driver current ref pins are connected to a digital trimpot on supported boards) #define DIGIPOT_MOTOR_CURRENT {135,135,135,135,135} // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A) +// Motor Current controlled via PWM (Overridable on supported boards with PWM-driven motor driver current) +//#define PWM_MOTOR_CURRENT {1300, 1300, 1250} // Values in milliamps + // uncomment to enable an I2C based DIGIPOT like on the Azteeg X3 Pro //#define DIGIPOT_I2C // Number of channels available for I2C digipot, For Azteeg X3 Pro we have 8 diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h index f5517422e7..35f008678c 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h @@ -275,6 +275,9 @@ // Motor Current setting (Only functional when motor driver current ref pins are connected to a digital trimpot on supported boards) #define DIGIPOT_MOTOR_CURRENT {135,135,135,135,135} // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A) +// Motor Current controlled via PWM (Overridable on supported boards with PWM-driven motor driver current) +//#define PWM_MOTOR_CURRENT {1300, 1300, 1250} // Values in milliamps + // uncomment to enable an I2C based DIGIPOT like on the Azteeg X3 Pro //#define DIGIPOT_I2C // Number of channels available for I2C digipot, For Azteeg X3 Pro we have 8 diff --git a/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h index fa43ece788..07c1a45cc0 100644 --- a/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h @@ -279,6 +279,9 @@ // Motor Current setting (Only functional when motor driver current ref pins are connected to a digital trimpot on supported boards) #define DIGIPOT_MOTOR_CURRENT {135,135,135,135,135} // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A) +// Motor Current controlled via PWM (Overridable on supported boards with PWM-driven motor driver current) +//#define PWM_MOTOR_CURRENT {1300, 1300, 1250} // Values in milliamps + // uncomment to enable an I2C based DIGIPOT like on the Azteeg X3 Pro //#define DIGIPOT_I2C // Number of channels available for I2C digipot, For Azteeg X3 Pro we have 8 diff --git a/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h index bd1ffd7cb5..9fe1ce95b7 100644 --- a/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h @@ -274,6 +274,9 @@ // Motor Current setting (Only functional when motor driver current ref pins are connected to a digital trimpot on supported boards) #define DIGIPOT_MOTOR_CURRENT {135,135,135,135,135} // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A) +// Motor Current controlled via PWM (Overridable on supported boards with PWM-driven motor driver current) +//#define PWM_MOTOR_CURRENT {1300, 1300, 1250} // Values in milliamps + // uncomment to enable an I2C based DIGIPOT like on the Azteeg X3 Pro //#define DIGIPOT_I2C // Number of channels available for I2C digipot, For Azteeg X3 Pro we have 8 diff --git a/Marlin/example_configurations/makibox/Configuration_adv.h b/Marlin/example_configurations/makibox/Configuration_adv.h index 0f83ffbbb8..dc2564d4bd 100644 --- a/Marlin/example_configurations/makibox/Configuration_adv.h +++ b/Marlin/example_configurations/makibox/Configuration_adv.h @@ -274,6 +274,9 @@ // Motor Current setting (Only functional when motor driver current ref pins are connected to a digital trimpot on supported boards) #define DIGIPOT_MOTOR_CURRENT {135,135,135,135,135} // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A) +// Motor Current controlled via PWM (Overridable on supported boards with PWM-driven motor driver current) +//#define PWM_MOTOR_CURRENT {1300, 1300, 1250} // Values in milliamps + // uncomment to enable an I2C based DIGIPOT like on the Azteeg X3 Pro //#define DIGIPOT_I2C // Number of channels available for I2C digipot, For Azteeg X3 Pro we have 8 diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h index 07b8e4c25f..5cc4c77dd8 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h @@ -274,6 +274,9 @@ // Motor Current setting (Only functional when motor driver current ref pins are connected to a digital trimpot on supported boards) #define DIGIPOT_MOTOR_CURRENT {135,135,135,135,135} // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A) +// Motor Current controlled via PWM (Overridable on supported boards with PWM-driven motor driver current) +//#define PWM_MOTOR_CURRENT {1300, 1300, 1250} // Values in milliamps + // uncomment to enable an I2C based DIGIPOT like on the Azteeg X3 Pro //#define DIGIPOT_I2C // Number of channels available for I2C digipot, For Azteeg X3 Pro we have 8 diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index b7fb2c5378..6cb36fd068 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -91,7 +91,7 @@ static volatile char endstop_hit_bits = 0; // use X_MIN, Y_MIN, Z_MIN and Z_MIN_ #ifndef PWM_MOTOR_CURRENT #define PWM_MOTOR_CURRENT DEFAULT_PWM_MOTOR_CURRENT #endif - int motor_current_setting[3] = PWM_MOTOR_CURRENT; + const int motor_current_setting[3] = PWM_MOTOR_CURRENT; #endif static bool check_endstops = true;