My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

stepper.h 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. stepper.h - stepper motor driver: executes motion plans of planner.c using the stepper motors
  3. Part of Grbl
  4. Copyright (c) 2009-2011 Simen Svale Skogsrud
  5. Grbl is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. Grbl is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with Grbl. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef stepper_h
  17. #define stepper_h
  18. #include "planner.h"
  19. #include "stepper_indirection.h"
  20. #if EXTRUDERS > 3
  21. #define E_STEP_WRITE(v) { if(current_block->active_extruder == 3) { E3_STEP_WRITE(v); } else { if(current_block->active_extruder == 2) { E2_STEP_WRITE(v); } else { if(current_block->active_extruder == 1) { E1_STEP_WRITE(v); } else { E0_STEP_WRITE(v); }}}}
  22. #define NORM_E_DIR() { if(current_block->active_extruder == 3) { E3_DIR_WRITE( !INVERT_E3_DIR); } else { if(current_block->active_extruder == 2) { E2_DIR_WRITE(!INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { E1_DIR_WRITE(!INVERT_E1_DIR); } else { E0_DIR_WRITE(!INVERT_E0_DIR); }}}}
  23. #define REV_E_DIR() { if(current_block->active_extruder == 3) { E3_DIR_WRITE(INVERT_E3_DIR); } else { if(current_block->active_extruder == 2) { E2_DIR_WRITE(INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { E1_DIR_WRITE(INVERT_E1_DIR); } else { E0_DIR_WRITE(INVERT_E0_DIR); }}}}
  24. #elif EXTRUDERS > 2
  25. #define E_STEP_WRITE(v) { if(current_block->active_extruder == 2) { E2_STEP_WRITE(v); } else { if(current_block->active_extruder == 1) { E1_STEP_WRITE(v); } else { E0_STEP_WRITE(v); }}}
  26. #define NORM_E_DIR() { if(current_block->active_extruder == 2) { E2_DIR_WRITE(!INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { E1_DIR_WRITE(!INVERT_E1_DIR); } else { E0_DIR_WRITE(!INVERT_E0_DIR); }}}
  27. #define REV_E_DIR() { if(current_block->active_extruder == 2) { E2_DIR_WRITE(INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { E1_DIR_WRITE(INVERT_E1_DIR); } else { E0_DIR_WRITE(INVERT_E0_DIR); }}}
  28. #elif EXTRUDERS > 1
  29. #ifndef DUAL_X_CARRIAGE
  30. #define E_STEP_WRITE(v) { if(current_block->active_extruder == 1) { E1_STEP_WRITE(v); } else { E0_STEP_WRITE(v); }}
  31. #define NORM_E_DIR() { if(current_block->active_extruder == 1) { E1_DIR_WRITE(!INVERT_E1_DIR); } else { E0_DIR_WRITE(!INVERT_E0_DIR); }}
  32. #define REV_E_DIR() { if(current_block->active_extruder == 1) { E1_DIR_WRITE(INVERT_E1_DIR); } else { E0_DIR_WRITE(INVERT_E0_DIR); }}
  33. #else
  34. extern bool extruder_duplication_enabled;
  35. #define E_STEP_WRITE(v) { if(extruder_duplication_enabled) { E0_STEP_WRITE(v); E1_STEP_WRITE(v); } else if(current_block->active_extruder == 1) { E1_STEP_WRITE(v); } else { E0_STEP_WRITE(v); }}
  36. #define NORM_E_DIR() { if(extruder_duplication_enabled) { E0_DIR_WRITE(!INVERT_E0_DIR); E1_DIR_WRITE(!INVERT_E1_DIR); } else if(current_block->active_extruder == 1) { E1_DIR_WRITE(!INVERT_E1_DIR); } else { E0_DIR_WRITE(!INVERT_E0_DIR); }}
  37. #define REV_E_DIR() { if(extruder_duplication_enabled) { E0_DIR_WRITE(INVERT_E0_DIR); E1_DIR_WRITE(INVERT_E1_DIR); } else if(current_block->active_extruder == 1) { E1_DIR_WRITE(INVERT_E1_DIR); } else { E0_DIR_WRITE(INVERT_E0_DIR); }}
  38. #endif
  39. #else
  40. #define E_STEP_WRITE(v) E0_STEP_WRITE(v)
  41. #define NORM_E_DIR() E0_DIR_WRITE(!INVERT_E0_DIR)
  42. #define REV_E_DIR() E0_DIR_WRITE(INVERT_E0_DIR)
  43. #endif
  44. #ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
  45. extern bool abort_on_endstop_hit;
  46. #endif
  47. // Initialize and start the stepper motor subsystem
  48. void st_init();
  49. // Block until all buffered steps are executed
  50. void st_synchronize();
  51. // Set current position in steps
  52. void st_set_position(const long &x, const long &y, const long &z, const long &e);
  53. void st_set_e_position(const long &e);
  54. // Get current position in steps
  55. long st_get_position(uint8_t axis);
  56. // Get current position in mm
  57. float st_get_position_mm(AxisEnum axis);
  58. // The stepper subsystem goes to sleep when it runs out of things to execute. Call this
  59. // to notify the subsystem that it is time to go to work.
  60. void st_wake_up();
  61. void checkHitEndstops(); //call from somewhere to create an serial error message with the locations the endstops where hit, in case they were triggered
  62. void endstops_hit_on_purpose(); //avoid creation of the message, i.e. after homing and before a routine call of checkHitEndstops();
  63. void enable_endstops(bool check); // Enable/disable endstop checking
  64. void checkStepperErrors(); //Print errors detected by the stepper
  65. void finishAndDisableSteppers();
  66. extern block_t *current_block; // A pointer to the block currently being traced
  67. void quickStop();
  68. void digitalPotWrite(int address, int value);
  69. void microstep_ms(uint8_t driver, int8_t ms1, int8_t ms2);
  70. void microstep_mode(uint8_t driver, uint8_t stepping);
  71. void digipot_init();
  72. void digipot_current(uint8_t driver, int current);
  73. void microstep_init();
  74. void microstep_readings();
  75. #ifdef Z_DUAL_ENDSTOPS
  76. void In_Homing_Process(bool state);
  77. void Lock_z_motor(bool state);
  78. void Lock_z2_motor(bool state);
  79. #endif
  80. #ifdef BABYSTEPPING
  81. void babystep(const uint8_t axis,const bool direction); // perform a short step with a single stepper motor, outside of any convention
  82. #endif
  83. #endif