Advertisement
jtektool

OG sample.hal

May 11th, 2011
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.43 KB | None | 0 0
  1. 1. # standard pinout config file for 3-axis steppers
  2. 2. # with encoders using a parport for I/O
  3. 3. #
  4. 4. # first load the parport driver
  5. 5. loadrt hal_parport cfg="0x0378"
  6. 6. loadrt encoder num_chan=1
  7. 7. #
  8. 8. # next connect the parport functions to threads
  9. 9. # read inputs first
  10. 10. addf parport.0.read base-thread 1
  11. 11. addf encoder.update-counters base-thread
  12. 12. # write outputs last
  13. 13. addf parport.0.write base-thread -1
  14. 14. addf encoder.capture-position servo-thread
  15. 15. #
  16. 16. # hook stuff together
  17. 17. newsig Zpos-fb float
  18. 18.
  19. 19. setp encoder.0.position-scale [AXIS_0]INPUT_SCALE
  20. 20.
  21. 21. linkpp encoder.0.phase-A <= parport.0.pin-12-in
  22. 22. linkpp encoder.0.phase-B <= parport.0.pin-15-in
  23. 23.
  24. 24. linksp Zpos-fb <= encoder.0.position
  25. 25.
  26. 26. # finally connect physical pins to the signals
  27. 27. linksp Xstep => parport.0.pin-03-out
  28. 28. linksp Xdir => parport.0.pin-02-out
  29. 29. linksp Ystep => parport.0.pin-05-out
  30. 30. linksp Ydir => parport.0.pin-04-out
  31. 31. linksp Zstep => parport.0.pin-07-out
  32. 32. linksp Zdir => parport.0.pin-06-out
  33. 33.
  34. 34. # create a signal for the estop loopback
  35. 35. ## linkpp parport.0.pin-10-in iocontrol.0.emc-enable-in
  36. 36.
  37. 37. # create signal for external estop
  38. 38. newsig ext-estop bit
  39. 39. linksp ext-estop parport.0.pin-10-in
  40. 40. linksp ext-estop iocontrol.0.emc-enable-in
  41. 41.
  42. 42.
  43. 43. # create signals for tool loading loopback
  44. 44. linkpp iocontrol.0.tool-prepare iocontrol.0.tool-prepared
  45. 45. linkpp iocontrol.0.tool-change iocontrol.0.tool-changed
  46. 46.
  47. 47.
  48. 48. # create a signal for "spindle on"
  49. 49. newsig spindle-on bit
  50. 50. # connect the controller to it
  51. 51. linkps motion.spindle-on => spindle-on
  52. 52. # connect it to a physical pin
  53. 53. linksp spindle-on => parport.0.pin-09-out
  54. 54.
  55. 55.
  56. 56. # spindle signals "spindle forw,rev"
  57. 57. # spindle status has not been resolved
  58. 58. # a simple loop through is set here
  59. 59. linkpp motion.spindle-forward parport.0.pin-16-out
  60. 60. # linkpp motion.spindle-reverse parport.0.pin-17-out
  61. 61.
  62. 62.
  63. 63.
  64. 64. # Home/Limit Shared Switch on Same Pin
  65. 65.
  66. 66. newsig Xswitches bit
  67. 67. linkps parport.0.pin-11-in-not => Xswitches
  68. 68. linksp Xswitches => axis.0.home-sw-in
  69. 69. linksp Xswitches => axis.0.neg-lim-sw-in
  70. 70. linksp Xswitches => axis.0.pos-lim-sw-in
  71. 71.
  72. 72. #newsig Yswitches bit
  73. 73. #linkps parport.0.pin-12-in-not => Yswitches
  74. 74. #linksp Yswitches => axis.1.home-sw-in
  75. 75. #linksp Yswitches => axis.1.neg-lim-sw-in
  76. 76. #linksp Yswitches => axis.1.pos-lim-sw-in
  77. 77.
  78. 78. newsig Zswitches bit
  79. 79. linkps parport.0.pin-13-in-not => Zswitches
  80. 80. linksp Zswitches => axis.2.home-sw-in
  81. 81. linksp Zswitches => axis.2.neg-lim-sw-in
  82. 82. linksp Zswitches => axis.2.pos-lim-sw-in
  83. 83.
  84. 84.
  85. 85. # coolant signals
  86. 86. # note that these do NOT represent proper IO signals from iocontrol
  87. 87. # should separate command and status for production versions
  88. 88. # and run these through CL to test conditions
  89. 89. linkpp iocontrol.0.coolant-flood parport.0.pin-08-out
  90. 90. # linkpp iocontrol.0.coolant-mist parport.0.pin-09-out
  91. 91.
  92. 92. loadrt pwmgen output_type=1
  93. 93. addf pwmgen.update servo-thread
  94. 94. addf pwmgen.make-pulses base-thread
  95. 95. net spindle-speed-cmd motion.spindle-speed-out => pwmgen.0.value
  96. 96. net spindle-on motion.spindle-on => pwmgen.0.enable
  97. 97. net spindle-pwm pwmgen.0.pwm => parport.0.pin-09-out
  98. 98. setp pwmgen.0.scale 2000 # Change to your spindle & # 8217;s top speed in RPM
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement