linuxcnc-demo.hal 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. loadrt [KINS]KINEMATICS
  2. loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EMCMOT]SERVO_PERIOD traj_period_nsec=[EMCMOT]SERVO_PERIOD key=[EMCMOT]SHMEM_KEY num_joints=[KINS]JOINTS
  3. loadrt stepgen step_type=0,0,0
  4. loadrt charge_pump
  5. loadrt comp count=3
  6. loadusr -W hal_manualtoolchange
  7. # Base thread
  8. addf stepgen.make-pulses base-thread
  9. # Servo thread
  10. addf stepgen.capture-position servo-thread
  11. addf motion-command-handler servo-thread
  12. addf motion-controller servo-thread
  13. addf stepgen.update-freq servo-thread
  14. addf charge-pump servo-thread
  15. addf comp.0 servo-thread
  16. addf comp.1 servo-thread
  17. addf comp.2 servo-thread
  18. # Spindle control
  19. net spindle-cw <= spindle.0.forward
  20. net spindle-ccw <= spindle.0.reverse
  21. # Coolant control
  22. net coolant-mist <= iocontrol.0.coolant-mist
  23. net coolant-flood <= iocontrol.0.coolant-flood
  24. # heartbeat generator
  25. setp charge-pump.enable 1
  26. net heartbeat <= charge-pump.out-4
  27. # Emergency stop logic
  28. net estop-out-not <= iocontrol.0.user-enable-out
  29. net estop-in-not => iocontrol.0.emc-enable-in
  30. # Manual tool change
  31. net tool-change iocontrol.0.tool-change => hal_manualtoolchange.change
  32. net tool-changed iocontrol.0.tool-changed <= hal_manualtoolchange.changed
  33. net tool-number iocontrol.0.tool-prep-number => hal_manualtoolchange.number
  34. net tool-prepare-loopback iocontrol.0.tool-prepare => iocontrol.0.tool-prepared
  35. # X axis
  36. setp stepgen.0.position-scale [JOINT_0]SCALE
  37. setp stepgen.0.steplen [STEPCONF]STEPLEN
  38. setp stepgen.0.stepspace [STEPCONF]STEPSPACE
  39. setp stepgen.0.dirhold [STEPCONF]DIRHOLD
  40. setp stepgen.0.dirsetup [STEPCONF]DIRSETUP
  41. setp stepgen.0.maxaccel [JOINT_0]STEPGEN_MAXACCEL
  42. net xpos-cmd joint.0.motor-pos-cmd => stepgen.0.position-cmd
  43. net xpos-fb stepgen.0.position-fb => joint.0.motor-pos-fb
  44. net xstep <= stepgen.0.step
  45. net xdir <= stepgen.0.dir
  46. net xenable joint.0.amp-enable-out => stepgen.0.enable
  47. net home-x => joint.0.home-sw-in
  48. net limit-x => joint.0.neg-lim-sw-in
  49. net limit-x => joint.0.pos-lim-sw-in
  50. # Y axis
  51. setp stepgen.1.position-scale [JOINT_1]SCALE
  52. setp stepgen.1.steplen [STEPCONF]STEPLEN
  53. setp stepgen.1.stepspace [STEPCONF]STEPSPACE
  54. setp stepgen.1.dirhold [STEPCONF]DIRHOLD
  55. setp stepgen.1.dirsetup [STEPCONF]DIRSETUP
  56. setp stepgen.1.maxaccel [JOINT_1]STEPGEN_MAXACCEL
  57. net ypos-cmd joint.1.motor-pos-cmd => stepgen.1.position-cmd
  58. net ypos-fb stepgen.1.position-fb => joint.1.motor-pos-fb
  59. net ystep <= stepgen.1.step
  60. net ydir <= stepgen.1.dir
  61. net yenable joint.1.amp-enable-out => stepgen.1.enable
  62. net home-y => joint.1.home-sw-in
  63. net limit-y => joint.1.neg-lim-sw-in
  64. net limit-y => joint.1.pos-lim-sw-in
  65. # Z axis
  66. setp stepgen.2.position-scale [JOINT_2]SCALE
  67. setp stepgen.2.steplen [STEPCONF]STEPLEN
  68. setp stepgen.2.stepspace [STEPCONF]STEPSPACE
  69. setp stepgen.2.dirhold [STEPCONF]DIRHOLD
  70. setp stepgen.2.dirsetup [STEPCONF]DIRSETUP
  71. setp stepgen.2.maxaccel [JOINT_2]STEPGEN_MAXACCEL
  72. net zpos-cmd joint.2.motor-pos-cmd => stepgen.2.position-cmd
  73. net zpos-fb stepgen.2.position-fb => joint.2.motor-pos-fb
  74. net zstep <= stepgen.2.step
  75. net zdir <= stepgen.2.dir
  76. net zenable joint.2.amp-enable-out => stepgen.2.enable
  77. net home-z => joint.2.home-sw-in
  78. net limit-z => joint.2.neg-lim-sw-in
  79. net limit-z => joint.2.pos-lim-sw-in
  80. # Simulate home switches
  81. net xpos-cmd => comp.0.in0
  82. setp comp.0.in1 0
  83. setp comp.0.hyst 0.1
  84. net home-x <= comp.0.out
  85. net ypos-cmd => comp.1.in0
  86. setp comp.1.in1 0
  87. setp comp.1.hyst 0.1
  88. net home-y <= comp.1.out
  89. net zpos-cmd => comp.2.in0
  90. setp comp.2.in1 0
  91. setp comp.2.hyst 0.1
  92. net home-z <= comp.2.out
  93. # Simulate hardware limit switches
  94. sets limit-x 0
  95. sets limit-y 0
  96. sets limit-z 0