linuxcnc-demo.hal 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 watchdog num_inputs=1
  6. loadrt and2 count=1
  7. loadrt edge count=1
  8. loadusr -W hal_manualtoolchange
  9. # Base thread
  10. addf stepgen.make-pulses base-thread
  11. # Servo thread
  12. addf stepgen.capture-position servo-thread
  13. addf motion-command-handler servo-thread
  14. addf motion-controller servo-thread
  15. addf stepgen.update-freq servo-thread
  16. addf charge-pump servo-thread
  17. addf watchdog.process servo-thread
  18. addf watchdog.set-timeouts servo-thread
  19. addf and2.0 servo-thread
  20. addf edge.0 servo-thread
  21. # Spindle control
  22. net spindle-cw <= spindle.0.forward
  23. net spindle-ccw <= spindle.0.reverse
  24. # Coolant control
  25. net coolant-mist <= iocontrol.0.coolant-mist
  26. net coolant-flood <= iocontrol.0.coolant-flood
  27. # Out-heartbeat generator
  28. setp charge-pump.enable 1
  29. net heartbeat <= charge-pump.out-4
  30. # In-heartbeat watchdog
  31. setp edge.0.both 0
  32. setp edge.0.in-edge 1 # falling
  33. setp edge.0.out-width-ns 500000000
  34. net emc-enable => edge.0.in
  35. net watchdog-en edge.0.out-invert => watchdog.enable-in
  36. setp watchdog.timeout-0 0.5
  37. net awlsim-heartbeat => watchdog.input-0
  38. net watchdog-ok <= watchdog.ok-out
  39. # Emergency stop logic
  40. net estop-out-not <= iocontrol.0.user-enable-out
  41. net estop-in-not => and2.0.in0
  42. net watchdog-ok => and2.0.in1
  43. net emc-enable and2.0.out => iocontrol.0.emc-enable-in
  44. # Manual tool change
  45. net tool-change iocontrol.0.tool-change => hal_manualtoolchange.change
  46. net tool-changed iocontrol.0.tool-changed <= hal_manualtoolchange.changed
  47. net tool-number iocontrol.0.tool-prep-number => hal_manualtoolchange.number
  48. net tool-prepare-loopback iocontrol.0.tool-prepare => iocontrol.0.tool-prepared
  49. # X axis
  50. setp stepgen.0.position-scale [JOINT_0]SCALE
  51. setp stepgen.0.steplen [STEPCONF]STEPLEN
  52. setp stepgen.0.stepspace [STEPCONF]STEPSPACE
  53. setp stepgen.0.dirhold [STEPCONF]DIRHOLD
  54. setp stepgen.0.dirsetup [STEPCONF]DIRSETUP
  55. setp stepgen.0.maxaccel [JOINT_0]STEPGEN_MAXACCEL
  56. net xpos-cmd joint.0.motor-pos-cmd => stepgen.0.position-cmd
  57. net xpos-fb stepgen.0.position-fb => joint.0.motor-pos-fb
  58. net xstep <= stepgen.0.step
  59. net xdir <= stepgen.0.dir
  60. net xenable joint.0.amp-enable-out => stepgen.0.enable
  61. net home-x => joint.0.home-sw-in
  62. net limit-x => joint.0.neg-lim-sw-in
  63. net limit-x => joint.0.pos-lim-sw-in
  64. # Y axis
  65. setp stepgen.1.position-scale [JOINT_1]SCALE
  66. setp stepgen.1.steplen [STEPCONF]STEPLEN
  67. setp stepgen.1.stepspace [STEPCONF]STEPSPACE
  68. setp stepgen.1.dirhold [STEPCONF]DIRHOLD
  69. setp stepgen.1.dirsetup [STEPCONF]DIRSETUP
  70. setp stepgen.1.maxaccel [JOINT_1]STEPGEN_MAXACCEL
  71. net ypos-cmd joint.1.motor-pos-cmd => stepgen.1.position-cmd
  72. net ypos-fb stepgen.1.position-fb => joint.1.motor-pos-fb
  73. net ystep <= stepgen.1.step
  74. net ydir <= stepgen.1.dir
  75. net yenable joint.1.amp-enable-out => stepgen.1.enable
  76. net home-y => joint.1.home-sw-in
  77. net limit-y => joint.1.neg-lim-sw-in
  78. net limit-y => joint.1.pos-lim-sw-in
  79. # Z axis
  80. setp stepgen.2.position-scale [JOINT_2]SCALE
  81. setp stepgen.2.steplen [STEPCONF]STEPLEN
  82. setp stepgen.2.stepspace [STEPCONF]STEPSPACE
  83. setp stepgen.2.dirhold [STEPCONF]DIRHOLD
  84. setp stepgen.2.dirsetup [STEPCONF]DIRSETUP
  85. setp stepgen.2.maxaccel [JOINT_2]STEPGEN_MAXACCEL
  86. net zpos-cmd joint.2.motor-pos-cmd => stepgen.2.position-cmd
  87. net zpos-fb stepgen.2.position-fb => joint.2.motor-pos-fb
  88. net zstep <= stepgen.2.step
  89. net zdir <= stepgen.2.dir
  90. net zenable joint.2.amp-enable-out => stepgen.2.enable
  91. net home-z => joint.2.home-sw-in
  92. net limit-z => joint.2.neg-lim-sw-in
  93. net limit-z => joint.2.pos-lim-sw-in