Browse Source

[2.0.x] Enable / disable PSU automatically (#9503)

pull/1/head
Scott Lahteine 7 years ago
committed by GitHub
parent
commit
b5e92f4f90
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      Marlin/Configuration.h
  2. 4
      Marlin/src/Marlin.cpp
  3. 9
      Marlin/src/Marlin.h
  4. 9
      Marlin/src/config/default/Configuration.h
  5. 9
      Marlin/src/config/examples/AlephObjects/TAZ4/Configuration.h
  6. 9
      Marlin/src/config/examples/AliExpress/CL-260/Configuration.h
  7. 9
      Marlin/src/config/examples/Anet/A6/Configuration.h
  8. 9
      Marlin/src/config/examples/Anet/A8/Configuration.h
  9. 9
      Marlin/src/config/examples/Azteeg/X5GT/Configuration.h
  10. 9
      Marlin/src/config/examples/BIBO/TouchX/Configuration.h
  11. 9
      Marlin/src/config/examples/BQ/Hephestos/Configuration.h
  12. 9
      Marlin/src/config/examples/BQ/Hephestos_2/Configuration.h
  13. 9
      Marlin/src/config/examples/BQ/WITBOX/Configuration.h
  14. 9
      Marlin/src/config/examples/Cartesio/Configuration.h
  15. 9
      Marlin/src/config/examples/Creality/CR-10/Configuration.h
  16. 9
      Marlin/src/config/examples/Creality/CR-10S/Configuration.h
  17. 9
      Marlin/src/config/examples/Creality/Ender/Configuration.h
  18. 9
      Marlin/src/config/examples/Felix/Configuration.h
  19. 9
      Marlin/src/config/examples/Felix/DUAL/Configuration.h
  20. 9
      Marlin/src/config/examples/FolgerTech/i3-2020/Configuration.h
  21. 9
      Marlin/src/config/examples/Geeetech/GT2560/Configuration.h
  22. 9
      Marlin/src/config/examples/Geeetech/I3_Pro_X-GT2560/Configuration.h
  23. 9
      Marlin/src/config/examples/Infitary/i3-M508/Configuration.h
  24. 9
      Marlin/src/config/examples/JGAurora/A5/Configuration.h
  25. 9
      Marlin/src/config/examples/MakerParts/Configuration.h
  26. 9
      Marlin/src/config/examples/Malyan/M150/Configuration.h
  27. 9
      Marlin/src/config/examples/Malyan/M200/Configuration.h
  28. 9
      Marlin/src/config/examples/Micromake/C1/basic/Configuration.h
  29. 9
      Marlin/src/config/examples/Micromake/C1/enhanced/Configuration.h
  30. 9
      Marlin/src/config/examples/Mks/Sbase/Configuration.h
  31. 9
      Marlin/src/config/examples/RepRapWorld/Megatronics/Configuration.h
  32. 9
      Marlin/src/config/examples/RigidBot/Configuration.h
  33. 9
      Marlin/src/config/examples/SCARA/Configuration.h
  34. 9
      Marlin/src/config/examples/STM32F10/Configuration.h
  35. 9
      Marlin/src/config/examples/Sanguinololu/Configuration.h
  36. 9
      Marlin/src/config/examples/TheBorg/Configuration.h
  37. 9
      Marlin/src/config/examples/TinyBoy2/Configuration.h
  38. 9
      Marlin/src/config/examples/Tronxy/X1/Configuration.h
  39. 9
      Marlin/src/config/examples/UltiMachine/Archim2/Configuration.h
  40. 9
      Marlin/src/config/examples/Velleman/K8200/Configuration.h
  41. 9
      Marlin/src/config/examples/Velleman/K8400/Configuration.h
  42. 9
      Marlin/src/config/examples/Velleman/K8400/Dual-head/Configuration.h
  43. 9
      Marlin/src/config/examples/Wanhao/Duplicator 6/Configuration.h
  44. 9
      Marlin/src/config/examples/adafruit/ST7565/Configuration.h
  45. 9
      Marlin/src/config/examples/delta/FLSUN/auto_calibrate/Configuration.h
  46. 9
      Marlin/src/config/examples/delta/FLSUN/kossel/Configuration.h
  47. 9
      Marlin/src/config/examples/delta/FLSUN/kossel_mini/Configuration.h
  48. 9
      Marlin/src/config/examples/delta/generic/Configuration.h
  49. 9
      Marlin/src/config/examples/delta/kossel_mini/Configuration.h
  50. 9
      Marlin/src/config/examples/delta/kossel_pro/Configuration.h
  51. 9
      Marlin/src/config/examples/delta/kossel_xl/Configuration.h
  52. 9
      Marlin/src/config/examples/gCreate/gMax1.5+/Configuration.h
  53. 9
      Marlin/src/config/examples/makibox/Configuration.h
  54. 9
      Marlin/src/config/examples/stm32f103ret6/Configuration.h
  55. 9
      Marlin/src/config/examples/tvrrug/Round2/Configuration.h
  56. 9
      Marlin/src/config/examples/wt150/Configuration.h
  57. 96
      Marlin/src/feature/power.cpp
  58. 42
      Marlin/src/feature/power.h
  59. 8
      Marlin/src/gcode/control/M80_M81.cpp
  60. 8
      Marlin/src/module/temperature.cpp
  61. 15
      Marlin/src/module/temperature.h

9
Marlin/Configuration.h

@ -245,6 +245,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

4
Marlin/src/Marlin.cpp

@ -236,9 +236,9 @@ void setup_powerhold() {
#endif
#if HAS_POWER_SWITCH
#if ENABLED(PS_DEFAULT_OFF)
OUT_WRITE(PS_ON_PIN, PS_ON_ASLEEP);
PSU_OFF();
#else
OUT_WRITE(PS_ON_PIN, PS_ON_AWAKE);
PSU_ON();
#endif
#endif
}

9
Marlin/src/Marlin.h

@ -42,6 +42,15 @@ void idle(
void manage_inactivity(bool ignore_stepper_queue = false);
// Auto Power Control
#if ENABLED(AUTO_POWER_CONTROL)
#define PSU_ON() powerManager.power_on()
#define PSU_OFF() powerManager.power_off()
#else
#define PSU_ON() OUT_WRITE(PS_ON_PIN, PS_ON_AWAKE)
#define PSU_OFF() OUT_WRITE(PS_ON_PIN, PS_ON_ASLEEP)
#endif
#if HAS_X2_ENABLE
#define enable_X() do{ X_ENABLE_WRITE( X_ENABLE_ON); X2_ENABLE_WRITE( X_ENABLE_ON); }while(0)
#define disable_X() do{ X_ENABLE_WRITE(!X_ENABLE_ON); X2_ENABLE_WRITE(!X_ENABLE_ON); axis_known_position[X_AXIS] = false; }while(0)

9
Marlin/src/config/default/Configuration.h

@ -245,6 +245,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/AlephObjects/TAZ4/Configuration.h

@ -245,6 +245,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/AliExpress/CL-260/Configuration.h

@ -245,6 +245,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/Anet/A6/Configuration.h

@ -245,6 +245,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/Anet/A8/Configuration.h

@ -246,6 +246,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/Azteeg/X5GT/Configuration.h

@ -245,6 +245,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/BIBO/TouchX/Configuration.h

@ -236,6 +236,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/BQ/Hephestos/Configuration.h

@ -245,6 +245,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/BQ/Hephestos_2/Configuration.h

@ -244,6 +244,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/BQ/WITBOX/Configuration.h

@ -245,6 +245,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/Cartesio/Configuration.h

@ -246,6 +246,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/Creality/CR-10/Configuration.h

@ -245,6 +245,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/Creality/CR-10S/Configuration.h

@ -236,6 +236,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/Creality/Ender/Configuration.h

@ -236,6 +236,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/Felix/Configuration.h

@ -245,6 +245,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/Felix/DUAL/Configuration.h

@ -245,6 +245,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/FolgerTech/i3-2020/Configuration.h

@ -246,6 +246,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/Geeetech/GT2560/Configuration.h

@ -245,6 +245,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/Geeetech/I3_Pro_X-GT2560/Configuration.h

@ -245,6 +245,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/Infitary/i3-M508/Configuration.h

@ -245,6 +245,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/JGAurora/A5/Configuration.h

@ -250,6 +250,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/MakerParts/Configuration.h

@ -256,6 +256,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/Malyan/M150/Configuration.h

@ -250,6 +250,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/Malyan/M200/Configuration.h

@ -236,6 +236,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/Micromake/C1/basic/Configuration.h

@ -245,6 +245,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/Micromake/C1/enhanced/Configuration.h

@ -245,6 +245,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/Mks/Sbase/Configuration.h

@ -245,6 +245,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/RepRapWorld/Megatronics/Configuration.h

@ -245,6 +245,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/RigidBot/Configuration.h

@ -248,6 +248,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/SCARA/Configuration.h

@ -275,6 +275,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/STM32F10/Configuration.h

@ -245,6 +245,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/Sanguinololu/Configuration.h

@ -245,6 +245,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/TheBorg/Configuration.h

@ -245,6 +245,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/TinyBoy2/Configuration.h

@ -267,6 +267,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/Tronxy/X1/Configuration.h

@ -236,6 +236,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/UltiMachine/Archim2/Configuration.h

@ -236,6 +236,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/Velleman/K8200/Configuration.h

@ -265,6 +265,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/Velleman/K8400/Configuration.h

@ -245,6 +245,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/Velleman/K8400/Dual-head/Configuration.h

@ -245,6 +245,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/Wanhao/Duplicator 6/Configuration.h

@ -236,6 +236,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/adafruit/ST7565/Configuration.h

@ -245,6 +245,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/delta/FLSUN/auto_calibrate/Configuration.h

@ -245,6 +245,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/delta/FLSUN/kossel/Configuration.h

@ -236,6 +236,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/delta/FLSUN/kossel_mini/Configuration.h

@ -245,6 +245,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/delta/generic/Configuration.h

@ -245,6 +245,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/delta/kossel_mini/Configuration.h

@ -245,6 +245,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/delta/kossel_pro/Configuration.h

@ -249,6 +249,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/delta/kossel_xl/Configuration.h

@ -245,6 +245,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/gCreate/gMax1.5+/Configuration.h

@ -250,6 +250,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/makibox/Configuration.h

@ -245,6 +245,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/stm32f103ret6/Configuration.h

@ -217,6 +217,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/tvrrug/Round2/Configuration.h

@ -245,6 +245,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

9
Marlin/src/config/examples/wt150/Configuration.h

@ -245,6 +245,15 @@
// Enable this option to leave the PSU off at startup.
// Power to steppers and heaters will need to be turned on with M80.
//#define PS_DEFAULT_OFF
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature

96
Marlin/src/feature/power.cpp

@ -0,0 +1,96 @@
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* power.cpp - power control
*/
#include "../inc/MarlinConfig.h"
#if ENABLED(AUTO_POWER_CONTROL)
#include "power.h"
#include "temperature.h"
#include "stepper_indirection.h"
Power powerManager;
millis_t Power::lastPowerOn;
bool Power::is_power_needed() {
#if ENABLED(AUTO_POWER_FANS)
for (uint8_t i = 0; i < FAN_COUNT; i++) if (fanSpeeds[i] > 0) return true;
#endif
#if ENABLED(AUTO_POWER_E_FANS)
HOTEND_LOOP() if (thermalManager.autofan_speed[e] > 0) return true;
#endif
#if ENABLED(AUTO_POWER_CONTROLLERFAN) && HAS_CONTROLLERFAN
if (controllerFanSpeed > 0) return true;
#endif
if (X_ENABLE_READ == X_ENABLE_ON || Y_ENABLE_READ == Y_ENABLE_ON || Z_ENABLE_READ == Z_ENABLE_ON ||
thermalManager.soft_pwm_bed > 0
|| E0_ENABLE_READ == E_ENABLE_ON // If any of the drivers are enabled...
#if E_STEPPERS > 1
|| E1_ENABLE_READ == E_ENABLE_ON
#if HAS_X2_ENABLE
|| X2_ENABLE_READ == X_ENABLE_ON
#endif
#if E_STEPPERS > 2
|| E2_ENABLE_READ == E_ENABLE_ON
#if E_STEPPERS > 3
|| E3_ENABLE_READ == E_ENABLE_ON
#endif
#endif
#endif
) return true;
HOTEND_LOOP() if (thermalManager.degTargetHotend(e) > 0) return true;
if (thermalManager.degTargetBed() > 0) return true;
return false;
}
void Power::check() {
static millis_t nextPowerCheck = 0;
millis_t ms = millis();
if (ELAPSED(ms, nextPowerCheck)) {
nextPowerCheck = ms + 2500UL;
if (is_power_needed())
power_on();
else if (!lastPowerOn || ELAPSED(ms, lastPowerOn + (POWER_TIMEOUT) * 1000UL))
power_off();
}
}
void Power::power_on() {
lastPowerOn = millis();
OUT_WRITE(PS_ON_PIN, PS_ON_AWAKE);
}
void Power::power_off() {
OUT_WRITE(PS_ON_PIN, PS_ON_ASLEEP);
}
#endif // AUTO_POWER_CONTROL

42
Marlin/src/feature/power.h

@ -0,0 +1,42 @@
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* power.h - power control
*/
#ifndef POWER_H
#define POWER_H
class Power {
public:
static void check();
static void power_on();
static void power_off();
private:
static millis_t lastPowerOn;
static bool is_power_needed();
};
extern Power powerManager;
#endif // POWER_H

8
Marlin/src/gcode/control/M80_M81.cpp

@ -36,6 +36,10 @@
#if HAS_POWER_SWITCH
#if ENABLED(AUTO_POWER_CONTROL)
#include "../../feature/power.h"
#endif
// Could be moved to a feature, but this is all the data
bool powersupply_on =
#if ENABLED(PS_DEFAULT_OFF)
@ -61,7 +65,7 @@
return;
}
OUT_WRITE(PS_ON_PIN, PS_ON_AWAKE); // GND
PSU_ON();
/**
* If you have a switch on suicide pin, this is useful
@ -114,7 +118,7 @@ void GcodeSuite::M81() {
stepper.synchronize();
suicide();
#elif HAS_POWER_SWITCH
OUT_WRITE(PS_ON_PIN, PS_ON_ASLEEP);
PSU_OFF();
powersupply_on = false;
#endif

8
Marlin/src/module/temperature.cpp

@ -63,10 +63,15 @@ Temperature thermalManager;
float Temperature::current_temperature[HOTENDS] = { 0.0 },
Temperature::current_temperature_bed = 0.0;
int16_t Temperature::current_temperature_raw[HOTENDS] = { 0 },
Temperature::target_temperature[HOTENDS] = { 0 },
Temperature::current_temperature_bed_raw = 0;
#if ENABLED(AUTO_POWER_E_FANS)
int16_t Temperature::autofan_speed[HOTENDS] = { 0 };
#endif
#if HAS_HEATER_BED
int16_t Temperature::target_temperature_bed = 0;
#endif
@ -529,6 +534,9 @@ int Temperature::getHeaterPower(int heater) {
const uint8_t bit = pgm_read_byte(&fanBit[f]);
if (pin >= 0 && !TEST(fanDone, bit)) {
uint8_t newFanSpeed = TEST(fanState, bit) ? EXTRUDER_AUTO_FAN_SPEED : 0;
#if ENABLED(AUTO_POWER_E_FANS)
autofan_speed[f] = newFanSpeed;
#endif
// this idiom allows both digital and PWM fan outputs (see M42 handling).
digitalWrite(pin, newFanSpeed);
analogWrite(pin, newFanSpeed);

15
Marlin/src/module/temperature.h

@ -28,11 +28,16 @@
#define TEMPERATURE_H
#include "thermistor/thermistors.h"
#include "../inc/MarlinConfig.h"
#if ENABLED(BABYSTEPPING)
extern bool axis_known_position[XYZ];
#endif
#if ENABLED(AUTO_POWER_CONTROL)
#include "power.h"
#endif
#if ENABLED(PID_EXTRUSION_SCALING)
#include "stepper.h"
#endif
@ -113,6 +118,10 @@ class Temperature {
target_temperature[HOTENDS],
current_temperature_bed_raw;
#if ENABLED(AUTO_POWER_E_FANS)
static int16_t autofan_speed[HOTENDS];
#endif
#if HAS_HEATER_BED
static int16_t target_temperature_bed;
#endif
@ -393,6 +402,9 @@ class Temperature {
else if (target_temperature[HOTEND_INDEX] == 0)
start_preheat_time(HOTEND_INDEX);
#endif
#if ENABLED(AUTO_POWER_CONTROL)
powerManager.power_on();
#endif
target_temperature[HOTEND_INDEX] = celsius;
#if WATCH_HOTENDS
start_watching_heater(HOTEND_INDEX);
@ -401,6 +413,9 @@ class Temperature {
static void setTargetBed(const int16_t celsius) {
#if HAS_HEATER_BED
#if ENABLED(AUTO_POWER_CONTROL)
powerManager.power_on();
#endif
target_temperature_bed =
#ifdef BED_MAXTEMP
min(celsius, BED_MAXTEMP)

Loading…
Cancel
Save