Advertisement
Guest User

Jim Servo.hal

a guest
May 2nd, 2010
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.34 KB | None | 0 0
  1. jimbo@jimbo-mill:~/emc2/configs/hm2-servo$ more *servo.hal
  2. # #######################################
  3. #
  4. # HAL file for HostMot2 with 3 servos
  5. #
  6. # Derived from Ted Hyde's original hm2-servo config
  7. #
  8. # Based up work and discussion with Seb & Peter & Jeff
  9. # GNU license references - insert here. www.linuxcnc.org
  10. #
  11. #
  12. # ########################################
  13. # Firmware files are in /lib/firmware/hm2/7i43/
  14. # Must symlink the hostmot2 firmware directory of sanbox to
  15. # /lib/firmware before running EMC2...
  16. # sudo ln -s $HOME/emc2-sandbox/src/hal/drivers/mesa-hostmot2/firmware /lib/fi
  17. rmware/hm2
  18. #
  19. # See also:
  20. # <http://www.linuxcnc.org/docs/devel/html/man/man9/hostmot2.9.html#config%20m
  21. odparam>
  22. # and http://wiki.linuxcnc.org/cgi-bin/emcinfo.pl?HostMot2
  23. #
  24. # #####################################################################
  25.  
  26.  
  27. # ###################################
  28. # Core EMC/HAL Loads
  29. # ###################################
  30.  
  31. # kinematics
  32. loadrt trivkins
  33.  
  34. # motion controller, get name and thread periods from ini file
  35. loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[TRAJ]
  36. AXES
  37. loadusr -W hal_input -KRAL PoKeys
  38. loadusr -W hal_manualtoolchange
  39.  
  40.  
  41. # standard components
  42. loadrt pid num_chan=3
  43.  
  44. # only the 7i43 needs this, but it doesnt hurt the others
  45. loadrt probe_parport
  46.  
  47. # hostmot2 driver
  48. loadrt hostmot2 debug_idrom=1 debug_module_descriptors=1 debug_pin_descriptors
  49. =1 debug_modules=1
  50.  
  51. # load low-level driver
  52. loadrt [HOSTMOT2](DRIVER) config=[HOSTMOT2](CONFIG)
  53.  
  54. setp hm2_[HOSTMOT2](BOARD).0.pwmgen.pwm_frequency 40000
  55.  
  56. setp hm2_[HOSTMOT2](BOARD).0.watchdog.timeout_ns 10000000
  57.  
  58. # ################################################
  59. # THREADS
  60. # ################################################
  61.  
  62. addf hm2_[HOSTMOT2](BOARD).0.read servo-thread
  63.  
  64. addf motion-command-handler servo-thread
  65. addf motion-controller servo-thread
  66.  
  67. addf pid.0.do-pid-calcs servo-thread
  68. addf pid.1.do-pid-calcs servo-thread
  69. addf pid.2.do-pid-calcs servo-thread
  70.  
  71. addf hm2_[HOSTMOT2](BOARD).0.write servo-thread
  72. addf hm2_[HOSTMOT2](BOARD).0.pet_watchdog servo-thread
  73.  
  74.  
  75. # ######################################################
  76. # Axis-of-motion Specific Configs (not the GUI)
  77. # ######################################################
  78.  
  79.  
  80. # ################
  81. # X [0] Axis
  82. # ################
  83.  
  84. # axis enable chain
  85. # gpio.064.out SERVO Amp Enable
  86. newsig emcmot.00.enable bit
  87. sets emcmot.00.enable FALSE
  88. net emcmot.00.enable => pid.0.enable
  89. net emcmot.00.enable => hm2_[HOSTMOT2](BOARD).0.pwmgen.00.enable hm2_[HOSTMOT2
  90. ](BOARD).0.gpio.064.out
  91. net emcmot.00.enable <= axis.0.amp-enable-out
  92.  
  93. # encoder feedback
  94. setp hm2_[HOSTMOT2](BOARD).0.encoder.00.counter-mode 0
  95. setp hm2_[HOSTMOT2](BOARD).0.encoder.00.filter 1
  96. setp hm2_[HOSTMOT2](BOARD).0.encoder.00.index-invert 0
  97. setp hm2_[HOSTMOT2](BOARD).0.encoder.00.index-mask 0
  98. setp hm2_[HOSTMOT2](BOARD).0.encoder.00.index-mask-invert 0
  99.  
  100. net limit-x hm2_5i20.0.gpio.049.in => axis.0.neg-lim-sw-in axis.0.pos-lim-sw-i
  101. n
  102. net home-x hm2_5i20.0.gpio.048.in_not => axis.0.home-sw-in
  103.  
  104. setp hm2_[HOSTMOT2](BOARD).0.encoder.00.scale 25400
  105. net motor.00.pos-fb hm2_[HOSTMOT2](BOARD).0.encoder.00.position => pid.0.feedb
  106. ack
  107. net motor.00.pos-fb => axis.0.motor-pos-fb #push copy back to Axis GUI
  108.  
  109. # set PID loop gains from inifile
  110. setp pid.0.Pgain [AXIS_0]P
  111. setp pid.0.Igain [AXIS_0]I
  112. setp pid.0.Dgain [AXIS_0]D
  113. setp pid.0.bias [AXIS_0]BIAS
  114. setp pid.0.FF0 [AXIS_0]FF0
  115. setp pid.0.FF1 [AXIS_0]FF1
  116. setp pid.0.FF2 [AXIS_0]FF2
  117. setp pid.0.deadband [AXIS_0]DEADBAND
  118. setp pid.0.maxoutput [AXIS_0]MAX_VELOCITY
  119.  
  120. # position command signals
  121. setp hm2_[HOSTMOT2](BOARD).0.pwmgen.00.output-type 1 #pwm on pin1, dir on pin2
  122. setp hm2_[HOSTMOT2](BOARD).0.pwmgen.00.scale 1.0
  123.  
  124. net emcmot.00.pos-cmd axis.0.motor-pos-cmd => pid.0.command
  125. net motor.00.command pid.0.output => hm2_[HOSTMOT2](BOARD).0.pwmgen.00.valu
  126. e
  127.  
  128. # ################
  129. # Y [1] Axis
  130. # ################
  131.  
  132. # axis enable chain
  133. newsig emcmot.01.enable bit
  134. sets emcmot.01.enable FALSE
  135. net emcmot.01.enable => pid.1.enable
  136. net emcmot.01.enable => hm2_[HOSTMOT2](BOARD).0.pwmgen.01.enable
  137. net emcmot.01.enable <= axis.1.amp-enable-out
  138.  
  139. # encoder feedback
  140. setp hm2_[HOSTMOT2](BOARD).0.encoder.01.counter-mode 0
  141. setp hm2_[HOSTMOT2](BOARD).0.encoder.01.filter 1
  142. setp hm2_[HOSTMOT2](BOARD).0.encoder.01.index-invert 0
  143. setp hm2_[HOSTMOT2](BOARD).0.encoder.01.index-mask 0
  144. setp hm2_[HOSTMOT2](BOARD).0.encoder.01.index-mask-invert 0
  145.  
  146. net limit-y hm2_5i20.0.gpio.051.in => axis.1.neg-lim-sw-in axis.1.pos-lim-sw-i
  147. n
  148. net home-y hm2_5i20.0.gpio.050.in_not => axis.1.home-sw-in
  149.  
  150. setp hm2_[HOSTMOT2](BOARD).0.encoder.01.scale 25400
  151. net motor.01.pos-fb hm2_[HOSTMOT2](BOARD).0.encoder.01.position => pid.1.feedb
  152. ack
  153. net motor.01.pos-fb => axis.1.motor-pos-fb #push copy back to Axis GUI
  154.  
  155. # set PID loop gains from inifile
  156. setp pid.1.Pgain [AXIS_1]P
  157. setp pid.1.Igain [AXIS_1]I
  158. setp pid.1.Dgain [AXIS_1]D
  159. setp pid.1.bias [AXIS_1]BIAS
  160. setp pid.1.FF0 [AXIS_1]FF0
  161. setp pid.1.FF1 [AXIS_1]FF1
  162. setp pid.1.FF2 [AXIS_1]FF2
  163. setp pid.1.deadband [AXIS_1]DEADBAND
  164. setp pid.1.maxoutput [AXIS_1]MAX_VELOCITY
  165.  
  166. # position command signals
  167. setp hm2_[HOSTMOT2](BOARD).0.pwmgen.01.output-type 1 #pwm on pin1, dir on pin2
  168. setp hm2_[HOSTMOT2](BOARD).0.pwmgen.01.scale 1.0
  169.  
  170. net emcmot.01.pos-cmd axis.1.motor-pos-cmd => pid.1.command
  171. net motor.01.command pid.1.output => hm2_[HOSTMOT2](BOARD).0.pwmgen.01.valu
  172. e
  173.  
  174. # ################
  175. # Z [2] Axis
  176. # ################
  177.  
  178. # axis enable chain
  179. newsig emcmot.02.enable bit
  180. sets emcmot.02.enable FALSE
  181. net emcmot.02.enable => pid.2.enable
  182. net emcmot.02.enable => hm2_[HOSTMOT2](BOARD).0.pwmgen.02.enable
  183. net emcmot.02.enable <= axis.2.amp-enable-out
  184.  
  185. # encoder feedback
  186. setp hm2_[HOSTMOT2](BOARD).0.encoder.02.counter-mode 0
  187. setp hm2_[HOSTMOT2](BOARD).0.encoder.02.filter 1
  188. setp hm2_[HOSTMOT2](BOARD).0.encoder.02.index-invert 0
  189. setp hm2_[HOSTMOT2](BOARD).0.encoder.02.index-mask 0
  190. setp hm2_[HOSTMOT2](BOARD).0.encoder.02.index-mask-invert 0
  191.  
  192. net limit-z hm2_5i20.0.gpio.053.in => axis.2.neg-lim-sw-in axis.2.pos-lim-sw-i
  193. n
  194. net home-z hm2_5i20.0.gpio.052.in_not => axis.2.home-sw-in
  195.  
  196. setp hm2_[HOSTMOT2](BOARD).0.encoder.02.scale -50800
  197. net motor.02.pos-fb hm2_[HOSTMOT2](BOARD).0.encoder.02.position => pid.2.feedb
  198. ack
  199. net motor.02.pos-fb => axis.2.motor-pos-fb #push copy back to Axis GUI
  200.  
  201. # set PID loop gains from inifile
  202. setp pid.2.Pgain [AXIS_2]P
  203. setp pid.2.Igain [AXIS_2]I
  204. setp pid.2.Dgain [AXIS_2]D
  205. setp pid.2.bias [AXIS_2]BIAS
  206. setp pid.2.FF0 [AXIS_2]FF0
  207. setp pid.2.FF1 [AXIS_2]FF1
  208. setp pid.2.FF2 [AXIS_2]FF2
  209. setp pid.2.deadband [AXIS_2]DEADBAND
  210. setp pid.2.maxoutput [AXIS_2]MAX_VELOCITY
  211.  
  212. # position command signals
  213. setp hm2_[HOSTMOT2](BOARD).0.pwmgen.02.output-type 1 #pwm on pin1, dir on pin2
  214. setp hm2_[HOSTMOT2](BOARD).0.pwmgen.02.scale 1.0
  215.  
  216. net emcmot.02.pos-cmd axis.2.motor-pos-cmd => pid.2.command
  217. net motor.02.command pid.2.output => hm2_[HOSTMOT2](BOARD).0.pwmgen.02.valu
  218. e
  219.  
  220.  
  221. # ##################################################
  222. # Standard I/O Block - EStop, Etc
  223. # ##################################################
  224.  
  225.  
  226. # create a signal for the estop loopback
  227. # OUTPUT DEVICES Tied to ESTOP System
  228. # gpio.071 output for main contactor
  229. # gpio.070 output for oiler pump
  230. net estop-loop iocontrol.0.user-enable-out => iocontrol.0.emc-enable-in hm2_[H
  231. OSTMOT2](BOARD).0.gpio.071.out hm2_[HOSTMOT2](BOARD).0.gpio.070.out
  232.  
  233.  
  234. # create signals for tool loading loopback
  235. #net tool-prep-loop iocontrol.0.tool-prepare => iocontrol.0.tool-prepared
  236. #net tool-change-loop iocontrol.0.tool-change => iocontrol.0.tool-changed
  237. net tool-change iocontrol.0.tool-change => hal_manualtoolchange.change
  238. net tool-changed iocontrol.0.tool-changed <= hal_manualtoolchange.changed
  239. net tool-number iocontrol.0.tool-prep-number => hal_manualtoolchange.number
  240. net tool-prepare-loopback iocontrol.0.tool-prepare => iocontrol.0.tool-prepare
  241. d
  242.  
  243. #SETUP OUTPUTS
  244. setp hm2_[HOSTMOT2](BOARD).0.gpio.071.is_output 1
  245. setp hm2_[HOSTMOT2](BOARD).0.gpio.071.invert_output 1
  246. setp hm2_[HOSTMOT2](BOARD).0.gpio.070.is_output 1
  247. setp hm2_[HOSTMOT2](BOARD).0.gpio.070.invert_output 1
  248. setp hm2_[HOSTMOT2](BOARD).0.gpio.064.is_output 1
  249. setp hm2_[HOSTMOT2](BOARD).0.gpio.064.invert_output 1
  250. jimbo@jimbo-mill:~/emc2/configs/hm2-servo$
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement