My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

stepper.h 3.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. #if EXTRUDERS > 2
  20. #define WRITE_E_STEP(v) { if(current_block->active_extruder == 2) { WRITE(E2_STEP_PIN, v); } else { if(current_block->active_extruder == 1) { WRITE(E1_STEP_PIN, v); } else { WRITE(E0_STEP_PIN, v); }}}
  21. #define NORM_E_DIR() { if(current_block->active_extruder == 2) { WRITE(!E2_DIR_PIN, INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { WRITE(!E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); }}}
  22. #define REV_E_DIR() { if(current_block->active_extruder == 2) { WRITE(E2_DIR_PIN, INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, INVERT_E0_DIR); }}}
  23. #elif EXTRUDERS > 1
  24. #define WRITE_E_STEP(v) { if(current_block->active_extruder == 1) { WRITE(E1_STEP_PIN, v); } else { WRITE(E0_STEP_PIN, v); }}
  25. #define NORM_E_DIR() { if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); }}
  26. #define REV_E_DIR() { if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, INVERT_E0_DIR); }}
  27. #else
  28. #define WRITE_E_STEP(v) WRITE(E0_STEP_PIN, v)
  29. #define NORM_E_DIR() WRITE(E0_DIR_PIN, !INVERT_E0_DIR)
  30. #define REV_E_DIR() WRITE(E0_DIR_PIN, INVERT_E0_DIR)
  31. #endif
  32. // Initialize and start the stepper motor subsystem
  33. void st_init();
  34. // Block until all buffered steps are executed
  35. void st_synchronize();
  36. // Set current position in steps
  37. void st_set_position(const long &x, const long &y, const long &z, const long &e);
  38. void st_set_e_position(const long &e);
  39. // Get current position in steps
  40. long st_get_position(uint8_t axis);
  41. // The stepper subsystem goes to sleep when it runs out of things to execute. Call this
  42. // to notify the subsystem that it is time to go to work.
  43. void st_wake_up();
  44. void checkHitEndstops(); //call from somwhere to create an serial error message with the locations the endstops where hit, in case they were triggered
  45. void endstops_hit_on_purpose(); //avoid creation of the message, i.e. after homeing and before a routine call of checkHitEndstops();
  46. void enable_endstops(bool check); // Enable/disable endstop checking
  47. void checkStepperErrors(); //Print errors detected by the stepper
  48. void finishAndDisableSteppers();
  49. extern block_t *current_block; // A pointer to the block currently being traced
  50. void quickStop();
  51. int digitalPotWrite(int address, int value);
  52. void microstep_ms(uint8_t driver, int8_t ms1, int8_t ms2);
  53. void microstep_mode(uint8_t driver, uint8_t stepping);
  54. void digipot_init();
  55. void digipot_current(uint8_t driver, int current);
  56. void microstep_init();
  57. void microstep_readings();
  58. #endif