Advertisement
Guest User

Untitled

a guest
May 1st, 2014
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.06 KB | None | 0 0
  1. # #######################################
  2. #
  3. # HAL file for HostMot2 with 3 smart serial analog 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.  
  38. # hostmot2 driver
  39. # if you have any firmware trouble, enable the debug flags here and see what's going on in the syslog
  40. loadrt hostmot2 debug_idrom=1 debug_module_descriptors=1 debug_pin_descriptors=1 debug_modules=1
  41. #loadrt hostmot2
  42.  
  43. # load low-level driver
  44. loadrt [HOSTMOT2](DRIVER) config=[HOSTMOT2](CONFIG)
  45.  
  46.  
  47. setp hm2_[HOSTMOT2](BOARD).0.watchdog.timeout_ns 10000000
  48.  
  49.  
  50. # ################################################
  51. # THREADS
  52. # ################################################
  53.  
  54. addf hm2_[HOSTMOT2](BOARD).0.read servo-thread
  55.  
  56. addf motion-command-handler servo-thread
  57. addf motion-controller servo-thread
  58.  
  59. addf pid.0.do-pid-calcs servo-thread
  60. addf pid.1.do-pid-calcs servo-thread
  61. addf pid.2.do-pid-calcs servo-thread
  62.  
  63. addf hm2_[HOSTMOT2](BOARD).0.write servo-thread
  64. addf hm2_[HOSTMOT2](BOARD).0.pet_watchdog servo-thread
  65.  
  66.  
  67. # ######################################################
  68. # Axis-of-motion Specific Configs (not the GUI)
  69. # ######################################################
  70.  
  71.  
  72. # ################
  73. # X [0] Axis
  74. # ################
  75.  
  76. # axis enable chain
  77. newsig emcmot.00.enable bit
  78. sets emcmot.00.enable FALSE
  79. net emcmot.00.enable => pid.0.enable
  80. net emcmot.00.enable => hm2_[HOSTMOT2](BOARD).0.7i77.0.1.analogena
  81. net emcmot.00.enable <= axis.0.amp-enable-out
  82.  
  83. # encoder feedback
  84. setp hm2_[HOSTMOT2](BOARD).0.encoder.00.counter-mode 0
  85. setp hm2_[HOSTMOT2](BOARD).0.encoder.00.filter 1
  86. setp hm2_[HOSTMOT2](BOARD).0.encoder.00.index-invert 0
  87. setp hm2_[HOSTMOT2](BOARD).0.encoder.00.index-mask 0
  88. setp hm2_[HOSTMOT2](BOARD).0.encoder.00.index-mask-invert 0
  89.  
  90. setp hm2_[HOSTMOT2](BOARD).0.encoder.00.scale [AXIS_0]INPUT_SCALE
  91. net motor.00.pos-fb hm2_[HOSTMOT2](BOARD).0.encoder.00.position => pid.0.feedback
  92. net motor.00.pos-fb => axis.0.motor-pos-fb #push copy back to Axis GUI
  93.  
  94. # set PID loop gains from inifile
  95. setp pid.0.Pgain [AXIS_0]P
  96. setp pid.0.Igain [AXIS_0]I
  97. setp pid.0.Dgain [AXIS_0]D
  98. setp pid.0.bias [AXIS_0]BIAS
  99. setp pid.0.FF0 [AXIS_0]FF0
  100. setp pid.0.FF1 [AXIS_0]FF1
  101. setp pid.0.FF2 [AXIS_0]FF2
  102. setp pid.0.deadband [AXIS_0]DEADBAND
  103. setp pid.0.maxoutput [AXIS_0]MAX_OUTPUT
  104.  
  105. # position command signals
  106.  
  107. # setp hm2_[HOSTMOT2](BOARD).0.7i77.0.1.analogout0-scalemax [AXIS_0]OUTPUT_SCALE
  108.  
  109. net emcmot.00.pos-cmd axis.0.motor-pos-cmd => pid.0.command
  110. net motor.00.command pid.0.output => hm2_[HOSTMOT2](BOARD).0.7i77.0.1.analogout0
  111.  
  112.  
  113. # ################
  114. # Y [1] Axis
  115. # ################
  116.  
  117. # axis enable chain
  118. newsig emcmot.01.enable bit
  119. sets emcmot.01.enable FALSE
  120. net emcmot.01.enable => pid.1.enable
  121. net emcmot.01.enable <= axis.1.amp-enable-out
  122.  
  123. # encoder feedback
  124. setp hm2_[HOSTMOT2](BOARD).0.encoder.01.counter-mode 0
  125. setp hm2_[HOSTMOT2](BOARD).0.encoder.01.filter 1
  126. setp hm2_[HOSTMOT2](BOARD).0.encoder.01.index-invert 0
  127. setp hm2_[HOSTMOT2](BOARD).0.encoder.01.index-mask 0
  128. setp hm2_[HOSTMOT2](BOARD).0.encoder.01.index-mask-invert 0
  129.  
  130. setp hm2_[HOSTMOT2](BOARD).0.encoder.01.scale [AXIS_1]INPUT_SCALE
  131. net motor.01.pos-fb hm2_[HOSTMOT2](BOARD).0.encoder.01.position => pid.1.feedback
  132. net motor.01.pos-fb => axis.1.motor-pos-fb #push copy back to Axis GUI
  133.  
  134. # set PID loop gains from inifile
  135. setp pid.1.Pgain [AXIS_1]P
  136. setp pid.1.Igain [AXIS_1]I
  137. setp pid.1.Dgain [AXIS_1]D
  138. setp pid.1.bias [AXIS_1]BIAS
  139. setp pid.1.FF0 [AXIS_1]FF0
  140. setp pid.1.FF1 [AXIS_1]FF1
  141. setp pid.1.FF2 [AXIS_1]FF2
  142. setp pid.1.deadband [AXIS_1]DEADBAND
  143. setp pid.1.maxoutput [AXIS_1]MAX_OUTPUT
  144.  
  145. # position command signals
  146.  
  147. # setp hm2_[HOSTMOT2](BOARD).0.7i77.0.1.analogout1-scalemax [AXIS_1]OUTPUT_SCALE
  148.  
  149. net emcmot.01.pos-cmd axis.1.motor-pos-cmd => pid.1.command
  150. net motor.01.command pid.1.output => hm2_[HOSTMOT2](BOARD).0.7i77.0.1.analogout1
  151.  
  152.  
  153. # ################
  154. # Z [2] Axis
  155. # ################
  156.  
  157. # axis enable chain
  158. newsig emcmot.02.enable bit
  159. sets emcmot.02.enable FALSE
  160. net emcmot.02.enable => pid.2.enable
  161. net emcmot.02.enable <= axis.2.amp-enable-out
  162.  
  163. # encoder feedback
  164. setp hm2_[HOSTMOT2](BOARD).0.encoder.02.counter-mode 0
  165. setp hm2_[HOSTMOT2](BOARD).0.encoder.02.filter 1
  166. setp hm2_[HOSTMOT2](BOARD).0.encoder.02.index-invert 0
  167. setp hm2_[HOSTMOT2](BOARD).0.encoder.02.index-mask 0
  168. setp hm2_[HOSTMOT2](BOARD).0.encoder.02.index-mask-invert 0
  169.  
  170. setp hm2_[HOSTMOT2](BOARD).0.encoder.02.scale [AXIS_2]INPUT_SCALE
  171. net motor.02.pos-fb hm2_[HOSTMOT2](BOARD).0.encoder.02.position => pid.2.feedback
  172. net motor.02.pos-fb => axis.2.motor-pos-fb #push copy back to Axis GUI
  173.  
  174. # set PID loop gains from inifile
  175. setp pid.2.Pgain [AXIS_2]P
  176. setp pid.2.Igain [AXIS_2]I
  177. setp pid.2.Dgain [AXIS_2]D
  178. setp pid.2.bias [AXIS_2]BIAS
  179. setp pid.2.FF0 [AXIS_2]FF0
  180. setp pid.2.FF1 [AXIS_2]FF1
  181. setp pid.2.FF2 [AXIS_2]FF2
  182. setp pid.2.deadband [AXIS_2]DEADBAND
  183. setp pid.2.maxoutput [AXIS_2]MAX_OUTPUT
  184.  
  185. # position command signals
  186.  
  187. #setp hm2_[HOSTMOT2](BOARD).0.7i77.0.1.analogout2-scalemax [AXIS_2]OUTPUT_SCALE
  188.  
  189. net motor.02.command pid.2.output => hm2_[HOSTMOT2](BOARD).0.7i77.0.1.analogout2
  190. net emcmot.02.pos-cmd axis.2.motor-pos-cmd => pid.2.command
  191. #######################################################
  192.  
  193. # Jog Pendant
  194.  
  195. loadrt mux4 count=1
  196. addf mux4.0 servo-thread
  197. loadrt gray2bin count=1
  198. addf gray2bin.0 servo-thread
  199.  
  200.  
  201. # for absolute mode (for every click you get a move ie, if you spin the dial it may keep moving after you stop the dial)
  202. # default so does not need to be set
  203. #axis.0.jog-vel-mode 0
  204.  
  205. # for velocity mode (when you stop spinning the dial the axis stops)
  206. # must be set for each axis
  207. setp axis.0.jog-vel-mode 1
  208. setp axis.1.jog-vel-mode 1
  209. setp axis.2.jog-vel-mode 1
  210.  
  211. # "times 4 mode" one count per full quadrature cycle, instead of the usual one count per edge.
  212. # mpg jog wheels often have a full quadrature cycle per "click" . 0 for off and 1 for on.
  213. # setp encoder.3.x4-mode 1
  214.  
  215. setp mux4.0.in0 0.06666667
  216. setp mux4.0.in1 0.01
  217. setp mux4.0.in2 0.001
  218.  
  219. net scale1 mux4.0.sel0 <= hm2_[HOSTMOT2](BOARD).0.7i77.0.0.input-04
  220. net scale2 mux4.0.sel1 <= hm2_[HOSTMOT2](BOARD).0.7i77.0.0.input-05
  221.  
  222. net pend-scale axis.0.jog-scale <= mux4.0.out
  223. net pend-scale axis.1.jog-scale
  224. net pend-scale axis.2.jog-scale
  225.  
  226. setp hm2_[HOSTMOT2](BOARD).0.encoder.03.counter-mode 1
  227. setp hm2_[HOSTMOT2](BOARD).0.encoder.03.filter 1
  228. setp hm2_[HOSTMOT2](BOARD).0.encoder.03.index-invert 0
  229. setp hm2_[HOSTMOT2](BOARD).0.encoder.03.index-mask 0
  230. setp hm2_[HOSTMOT2](BOARD).0.encoder.03.index-mask-invert 0
  231. setp hm2_[HOSTMOT2](BOARD).0.encoder.03.scale 1
  232. setp hm2_[HOSTMOT2](BOARD).0.encoder.03.vel-timeout .1
  233.  
  234. #net mpg-count hm2_7i43.0.encoder.03.count
  235. #net mpg-count => axis.0.jog-counts
  236. #net mpg-count => axis.1.jog-counts
  237. #net mpg-count => axis.2.jog-counts
  238.  
  239. net mpg-x axis.0.jog-enable <= hm2_[HOSTMOT2](BOARD).0.7i77.0.0.input-06
  240. net mpg-y axis.1.jog-enable <= hm2_[HOSTMOT2](BOARD).0.7i77.0.0.input-07
  241. net mpg-z axis.2.jog-enable <= hm2_[HOSTMOT2](BOARD).0.7i77.0.0.input-08
  242.  
  243. net pend-counts axis.0.jog-counts <= hm2_[HOSTMOT2](BOARD).0.encoder.03.count
  244. net pend-counts axis.1.jog-counts
  245. net pend-counts axis.2.jog-counts
  246.  
  247.  
  248. # ##################################################
  249. # Standard I/O Block - EStop, Etc
  250. # ##################################################
  251.  
  252. # create a signal for the estop loopback
  253. #net estop-loop iocontrol.0.user-enable-out => iocontrol.0.emc-enable-in
  254.  
  255. # create signals for tool loading loopback
  256. net tool-prep-loop iocontrol.0.tool-prepare => iocontrol.0.tool-prepared
  257. net tool-change-loop iocontrol.0.tool-change => iocontrol.0.tool-changed
  258. #
  259. #MACHINE ON CONTROL
  260.  
  261. net machine-on halui.machine.on ==> hm2_[HOSTMOT2](BOARD).0.7i77.0.0.input-00
  262. net machine-off halui.machine.off ==> hm2_[HOSTMOT2](BOARD).0.7i77.0.0.input-01
  263. net machine-onlt halui.machine.is-on <== hm2_[HOSTMOT2](BOARD).0.7i77.0.0.output-00
  264.  
  265. #estop
  266.  
  267. net estop-loop hm2_[HOSTMOT2](BOARD).0.7i77.0.0.input-03 iocontrol.0.emc-enable-in
  268.  
  269.  
  270.  
  271. ########
  272. ## Spindle
  273.  
  274. net SpindleStart hm2_[HOSTMOT2](BOARD).0.7i77.0.0.input-02 => halui.spindle.start
  275. net SpindleStop hm2_[HOSTMOT2](BOARD).0.7i77.0.0.input-09-not => halui.spindle.stop
  276. net SpindleForward hm2_[HOSTMOT2](BOARD).0.7i77.0.0.input-10 => halui.spindle.forward
  277. net SpindleReverse hm2_[HOSTMOT2](BOARD).0.7i77.0.0.input-11 => halui.spindle.reverse
  278.  
  279. net spindle-enable <= motion.spindle-on
  280. net spindle-cw <= motion.spindle-forward
  281. net spindle-ccw <= motion.spindle-reverse
  282.  
  283. net spindle-enable => hm2_[HOSTMOT2](BOARD).0.7i77.0.0.output-01
  284. net spindle-cw => hm2_[HOSTMOT2](BOARD).0.7i77.0.0.output-02
  285. net spindle-ccw => hm2_[HOSTMOT2](BOARD).0.7i77.0.0.output-03
  286.  
  287. #
  288. # homing
  289. #
  290.  
  291.  
  292. #net home-switch <= hm2_[HOSTMOT2](BOARD).0.7i77.0.0.input-00
  293. #net home-switch => axis.0.home-sw-in
  294. #net home-switch => axis.1.home-sw-in
  295. #net home-switch => axis.2.home-sw-in
  296.  
  297. # only the Y servo has an index, X and Z home without using the index
  298. #net y-index-enable hm2_[HOSTMOT2](BOARD).0.encoder.01.index-enable <=> axis.1.index-enable
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement