target_cncjoints.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Input->output connection definitions
  3. * for the joint-switches of a CNC machining center.
  4. */
  5. static DEF_OUTPUT(C, 5, OUTPUT_INVERT); /* X joint limit */
  6. static DEF_OUTPUT(C, 4, NONE); /* X joint REF */
  7. static DEF_OUTPUT(C, 3, OUTPUT_INVERT); /* Y joint limit */
  8. static DEF_OUTPUT(C, 2, NONE); /* Y joint REF */
  9. static DEF_OUTPUT(C, 1, OUTPUT_INVERT); /* Z joint limit */
  10. static DEF_OUTPUT(C, 0, NONE); /* Z joint REF */
  11. static struct connection connections[] = {
  12. { /* X+ joint limit input --> Joint limits common output */
  13. DEF_INPUT(D, 0, INPUT_INVERT),
  14. .out = &output_pin_C5,
  15. },
  16. { /* X- joint limit input --> Joint limits common output */
  17. DEF_INPUT(D, 1, INPUT_INVERT),
  18. .out = &output_pin_C5,
  19. },
  20. { /* X joint REF input --> X joint REF output */
  21. DEF_INPUT(D, 2, INPUT_INVERT),
  22. .out = &output_pin_C4,
  23. },
  24. { /* Y+ joint limit input --> Joint limits common output */
  25. DEF_INPUT(D, 3, INPUT_INVERT),
  26. .out = &output_pin_C3,
  27. },
  28. { /* Y- joint limit input --> Joint limits common output */
  29. DEF_INPUT(D, 4, INPUT_INVERT),
  30. .out = &output_pin_C3,
  31. },
  32. { /* Y joint REF input --> Y joint REF output */
  33. DEF_INPUT(D, 5, INPUT_INVERT),
  34. .out = &output_pin_C2,
  35. },
  36. { /* Z+ joint limit input --> Joint limits common output */
  37. DEF_INPUT(D, 6, INPUT_INVERT),
  38. .out = &output_pin_C1,
  39. },
  40. { /* Z- joint limit input --> Joint limits common output */
  41. DEF_INPUT(D, 7, INPUT_INVERT),
  42. .out = &output_pin_C1,
  43. },
  44. { /* Z joint REF input --> Z joint REF output */
  45. DEF_INPUT(B, 0, INPUT_INVERT),
  46. .out = &output_pin_C0,
  47. },
  48. };
  49. static void emergency_shutdown(void)
  50. {
  51. /* Assert all limit pins.
  52. * Limit pins are active-low, so clear the bit. */
  53. PORTC &= ~(1 << 5);
  54. PORTC &= ~(1 << 3);
  55. PORTC &= ~(1 << 1);
  56. }
  57. /* Pin for debugging. */
  58. #define TEST_PORT PORTB
  59. #define TEST_DDR DDRB
  60. #define TEST_BIT 1
  61. /* Debounce timing. */
  62. #define DEBOUNCE_DWELL_TIME MSEC_TO_USEC(100)
  63. /* We tolerate a joint move of max 5 microns for the ACTIVE_TIME.
  64. * That's good enough for limits and refs. */
  65. #define DEBOUNCE_ACTIVE_TIME 200 /* microseconds */