Advertisement
Guest User

LinuxCNC hal file

a guest
Aug 7th, 2014
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.70 KB | None | 0 0
  1. # #######################################
  2. #
  3. # HAL file for HostMot2 with 3 servos
  4. #
  5. # Derived from Ted Hyde's original hm2-servo config
  6. #
  7. # Based up work and discussion with Seb & Peter & Jeff
  8. # GNU license references - insert here. www.linuxcnc.org
  9. #
  10. #
  11. # ########################################
  12. # Firmware files are in /lib/firmware/hm2/7i43/
  13. # Must symlink the hostmot2 firmware directory of sanbox to
  14. # /lib/firmware before running EMC2...
  15. # sudo ln -s $HOME/emc2-sandbox/src/hal/drivers/mesa-hostmot2/firmware /lib/firmware/hm2
  16. #
  17. # See also:
  18. # <http://www.linuxcnc.org/docs/devel/html/man/man9/hostmot2.9.html#config%20modparam>
  19. # and http://wiki.linuxcnc.org/cgi-bin/emcinfo.pl?HostMot2
  20. #
  21. # #####################################################################
  22.  
  23.  
  24. # ###################################
  25. # Core EMC/HAL Loads
  26. # ###################################
  27.  
  28. # kinematics
  29. loadrt trivkins
  30.  
  31. # motion controller, get name and thread periods from ini file
  32. loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[TRAJ]AXES
  33.  
  34. # standard components
  35. loadrt pid num_chan=3
  36.  
  37. # only the 7i43 needs this, but it doesnt hurt the others
  38. loadrt probe_parport
  39.  
  40. # hostmot2 driver
  41. # if you have any firmware trouble, enable the debug flags here and see what's going on in the syslog
  42. #loadrt hostmot2 debug_idrom=1 debug_module_descriptors=1 debug_pin_descriptors=1 debug_modules=1
  43. loadrt hostmot2
  44.  
  45. # load low-level driver
  46. loadrt [HOSTMOT2](DRIVER) config=[HOSTMOT2](CONFIG)
  47.  
  48. setp hm2_[HOSTMOT2](BOARD).0.pwmgen.pwm_frequency 24000
  49.  
  50. setp hm2_[HOSTMOT2](BOARD).0.watchdog.timeout_ns 10000000
  51.  
  52. #terry playing,see google drive folder for component#
  53. #loading inverse deadband
  54. loadrt idb count=3
  55.  
  56.  
  57. # ################################################
  58. # THREADS
  59. # ################################################
  60.  
  61. addf hm2_[HOSTMOT2](BOARD).0.read servo-thread
  62.  
  63. addf motion-command-handler servo-thread
  64. addf motion-controller servo-thread
  65.  
  66. addf pid.0.do-pid-calcs servo-thread
  67. addf pid.1.do-pid-calcs servo-thread
  68. addf pid.2.do-pid-calcs servo-thread
  69.  
  70. addf hm2_[HOSTMOT2](BOARD).0.write servo-thread
  71. addf hm2_[HOSTMOT2](BOARD).0.pet_watchdog servo-thread
  72.  
  73. addf idb.0 servo-thread
  74. #addf idb.1 servo-thread
  75. #addf idb.2 servo-thread
  76.  
  77. # ######################################################
  78. # Axis-of-motion Specific Configs (not the GUI)
  79. # ######################################################
  80.  
  81.  
  82. # ################
  83. # X [0] Axis
  84. # ################
  85.  
  86. # axis enable chain
  87. newsig emcmot.00.enable bit
  88. sets emcmot.00.enable FALSE
  89. net emcmot.00.enable => pid.0.enable
  90. net emcmot.00.enable => hm2_[HOSTMOT2](BOARD).0.pwmgen.00.enable
  91. net emcmot.00.enable <= axis.0.amp-enable-out
  92.  
  93. setp hm2_[HOSTMOT2](BOARD).0.resolver.00.scale [AXIS_0]INPUT_SCALE
  94. net motor.00.pos-fb hm2_[HOSTMOT2](BOARD).0.resolver.00.position => pid.0.feedback
  95. net motor.00.pos-fb => axis.0.motor-pos-fb #push copy back to Axis GUI
  96.  
  97. # set PID loop gains from inifile
  98. setp pid.0.Pgain [AXIS_0]P
  99. setp pid.0.Igain [AXIS_0]I
  100. setp pid.0.Dgain [AXIS_0]D
  101. setp pid.0.bias [AXIS_0]BIAS
  102. setp pid.0.FF0 [AXIS_0]FF0
  103. setp pid.0.FF1 [AXIS_0]FF1
  104. setp pid.0.FF2 [AXIS_0]FF2
  105. setp pid.0.deadband [AXIS_0]DEADBAND
  106. setp pid.0.maxoutput [AXIS_0]MAX_OUTPUT
  107.  
  108. # position command signals
  109. setp hm2_[HOSTMOT2](BOARD).0.pwmgen.00.output-type 2 #up on pin1, down on pin2
  110. setp hm2_[HOSTMOT2](BOARD).0.pwmgen.00.scale [AXIS_0]OUTPUT_SCALE
  111.  
  112. net emcmot.00.pos-cmd axis.0.motor-pos-cmd => pid.0.command
  113.  
  114. #Setting wire Xoutput from pid.0.output to idb.0.in
  115. net Xoutput pid.0.output => idb.0.in
  116. #Setting idb/pwm base offset
  117. setp idb.0.amount 0.000
  118. #SEtting motor.00.command from idb.0.out to 7i49 pwm board
  119. net motor.00.command idb.0.out => hm2_[HOSTMOT2](BOARD).0.pwmgen.00.value
  120.  
  121. # ################
  122. # Y [1] Axis
  123. # ################
  124.  
  125. # axis enable chain
  126. newsig emcmot.01.enable bit
  127. sets emcmot.01.enable FALSE
  128. net emcmot.01.enable => pid.1.enable
  129. net emcmot.01.enable => hm2_[HOSTMOT2](BOARD).0.pwmgen.01.enable
  130. net emcmot.01.enable <= axis.1.amp-enable-out
  131.  
  132.  
  133. setp hm2_[HOSTMOT2](BOARD).0.resolver.01.scale [AXIS_1]INPUT_SCALE
  134. net motor.01.pos-fb hm2_[HOSTMOT2](BOARD).0.resolver.01.position => pid.1.feedback
  135. net motor.01.pos-fb => axis.1.motor-pos-fb #push copy back to Axis GUI
  136.  
  137. #net motor.01.command pid.1.output => idb.1.in
  138. #net idb.1.out => hm2_[HOSTMOT2](BOARD).1.pwmgen.01.value
  139.  
  140. # set PID loop gains from inifile
  141. setp pid.1.Pgain [AXIS_1]P
  142. setp pid.1.Igain [AXIS_1]I
  143. setp pid.1.Dgain [AXIS_1]D
  144. setp pid.1.bias [AXIS_1]BIAS
  145. setp pid.1.FF0 [AXIS_1]FF0
  146. setp pid.1.FF1 [AXIS_1]FF1
  147. setp pid.1.FF2 [AXIS_1]FF2
  148. setp pid.1.deadband [AXIS_1]DEADBAND
  149. setp pid.1.maxoutput [AXIS_1]MAX_OUTPUT
  150.  
  151.  
  152.  
  153. # position command signals
  154. setp hm2_[HOSTMOT2](BOARD).0.pwmgen.01.output-type 2 #up on pin1, down on pin2
  155. setp hm2_[HOSTMOT2](BOARD).0.pwmgen.01.scale [AXIS_1]OUTPUT_SCALE
  156.  
  157. net emcmot.01.pos-cmd axis.1.motor-pos-cmd => pid.1.command
  158. net motor.01.command pid.1.output => hm2_[HOSTMOT2](BOARD).0.pwmgen.01.value
  159.  
  160.  
  161. # ################
  162. # Z [2] Axis
  163. # ################
  164.  
  165. # axis enable chain
  166. newsig emcmot.02.enable bit
  167. sets emcmot.02.enable FALSE
  168. net emcmot.02.enable => pid.2.enable
  169. net emcmot.02.enable => hm2_[HOSTMOT2](BOARD).0.pwmgen.02.enable
  170. net emcmot.02.enable <= axis.2.amp-enable-out
  171.  
  172. setp hm2_[HOSTMOT2](BOARD).0.resolver.02.scale [AXIS_2]INPUT_SCALE
  173. net motor.02.pos-fb hm2_[HOSTMOT2](BOARD).0.resolver.02.position => pid.2.feedback
  174. net motor.02.pos-fb => axis.2.motor-pos-fb #push copy back to Axis GUI
  175.  
  176. #net pid.2.output => idb.2.in
  177.  
  178. # set PID loop gains from inifile
  179. setp pid.2.Pgain [AXIS_2]P
  180. setp pid.2.Igain [AXIS_2]I
  181. setp pid.2.Dgain [AXIS_2]D
  182. setp pid.2.bias [AXIS_2]BIAS
  183. setp pid.2.FF0 [AXIS_2]FF0
  184. setp pid.2.FF1 [AXIS_2]FF1
  185. setp pid.2.FF2 [AXIS_2]FF2
  186. setp pid.2.deadband [AXIS_2]DEADBAND
  187. setp pid.2.maxoutput [AXIS_2]MAX_OUTPUT
  188.  
  189. # position command signals
  190. setp hm2_[HOSTMOT2](BOARD).0.pwmgen.02.output-type 2 #up on pin1, down on pin2
  191. setp hm2_[HOSTMOT2](BOARD).0.pwmgen.02.scale [AXIS_2]OUTPUT_SCALE
  192.  
  193. net emcmot.02.pos-cmd axis.2.motor-pos-cmd => pid.2.command
  194. net motor.02.command pid.2.output => hm2_[HOSTMOT2](BOARD).0.pwmgen.02.value
  195.  
  196. # ##################################################
  197. # Standard I/O Block - EStop, Etc
  198. # ##################################################
  199.  
  200. # create a signal for the estop loopback
  201. net estop-loop iocontrol.0.user-enable-out => iocontrol.0.emc-enable-in
  202.  
  203. # create signals for tool loading loopback
  204. net tool-prep-loop iocontrol.0.tool-prepare => iocontrol.0.tool-prepared
  205. net tool-change-loop iocontrol.0.tool-change => iocontrol.0.tool-changed
  206.  
  207.  
  208. #
  209. # homing
  210. #
  211.  
  212. #
  213. # In this example, each of the three axes have their own home switch. All
  214. # home switches are connected to GPIO 25, though hostmot2 boards generally
  215. # have enough GPIO pins to put each axis' home switch on its own pin.
  216. #
  217. # Each switch is normally open, momentarily closed. When the switch is open,
  218. # GPIO 25 floats high (because that is the hostmot2 way). When the switch is
  219. # closed, it shorts GPIO 25 to ground.
  220. #
  221. # EMC expects the value on the .home-sw-in HAL pin to be active high, ie
  222. # True when the switch is closed and False when the switch is open.
  223. # We get this behavior by linking the GPIO .in_not pin instead of the .in
  224. # pin.
  225. #
  226.  
  227. #net home-switch <= hm2_[HOSTMOT2](BOARD).0.gpio.025.in_not
  228. #net home-switch => axis.0.home-sw-in
  229. #net home-switch => axis.1.home-sw-in
  230. #net home-switch => axis.2.home-sw-in
  231.  
  232. # (wrong) only the Y servo has an index, X and Z home without using the index
  233. ###net y-index-enable hm2_[HOSTMOT2](BOARD).0.resolver.01.index-enable <=> ###axis.1.index-enable
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement