Advertisement
Guest User

Untitled

a guest
Jul 21st, 2014
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.96 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_5i23.0.3pwmgen.frequency 1600
  49.  
  50.  
  51. # ################################################
  52. # THREADS
  53. # ################################################
  54.  
  55. addf hm2_[HOSTMOT2](BOARD).0.read servo-thread
  56.  
  57. addf motion-command-handler servo-thread
  58. addf motion-controller servo-thread
  59.  
  60. addf pid.0.do-pid-calcs servo-thread
  61. addf pid.1.do-pid-calcs servo-thread
  62. addf pid.2.do-pid-calcs servo-thread
  63.  
  64. addf hm2_[HOSTMOT2](BOARD).0.write servo-thread
  65. addf hm2_[HOSTMOT2](BOARD).0.pet_watchdog servo-thread
  66.  
  67.  
  68. # ######################################################
  69. # Axis-of-motion Specific Configs (not the GUI)
  70. # ######################################################
  71.  
  72.  
  73. # ################
  74. # X [0] Axis
  75. # ################
  76.  
  77. # axis enable chain
  78. newsig emcmot.00.enable bit
  79. sets emcmot.00.enable FALSE
  80. net emcmot.00.enable => pid.0.enable
  81. # net emcmot.00.enable => hm2_5i23.0.3pwmgen.00.A-value.enable
  82. net emcmot.00.enable <= axis.0.amp-enable-out
  83.  
  84. # encoder feedback
  85. setp hm2_[HOSTMOT2](BOARD).0.encoder.00.counter-mode 0
  86. setp hm2_[HOSTMOT2](BOARD).0.encoder.00.filter 1
  87. setp hm2_[HOSTMOT2](BOARD).0.encoder.00.index-invert 0
  88. setp hm2_[HOSTMOT2](BOARD).0.encoder.00.index-mask 0
  89. setp hm2_[HOSTMOT2](BOARD).0.encoder.00.index-mask-invert 0
  90.  
  91. setp hm2_[HOSTMOT2](BOARD).0.encoder.00.scale [AXIS_0]INPUT_SCALE
  92. net motor.00.pos-fb hm2_[HOSTMOT2](BOARD).0.encoder.00.position => pid.0.feedback
  93. net motor.00.pos-fb => axis.0.motor-pos-fb #push copy back to Axis GUI
  94.  
  95. # set PID loop gains from inifile
  96. setp pid.0.Pgain [AXIS_0]P
  97. setp pid.0.Igain [AXIS_0]I
  98. setp pid.0.Dgain [AXIS_0]D
  99. setp pid.0.bias [AXIS_0]BIAS
  100. setp pid.0.FF0 [AXIS_0]FF0
  101. setp pid.0.FF1 [AXIS_0]FF1
  102. setp pid.0.FF2 [AXIS_0]FF2
  103. setp pid.0.deadband [AXIS_0]DEADBAND
  104. setp pid.0.maxoutput [AXIS_0]MAX_OUTPUT
  105.  
  106. # position command signals
  107. # setp hm2_5i23.0.3pwmgen.00.A-value.output-type 1 #pwm on pin1, dir on pin2
  108. # setp hm2_5i23.0.3pwmgen.00.A-value.scale [AXIS_0]OUTPUT_SCALE
  109.  
  110. net emcmot.00.pos-cmd axis.0.motor-pos-cmd => pid.0.command
  111. # net motor.00.command pid.0.output => hm2_5i23.0.3pwmgen.00.A-value.value
  112.  
  113.  
  114. # ################
  115. # Y [1] Axis
  116. # ################
  117.  
  118. # axis enable chain
  119. newsig emcmot.01.enable bit
  120. sets emcmot.01.enable FALSE
  121. net emcmot.01.enable => pid.1.enable
  122. # net emcmot.01.enable => hm2_5i23.0.3pwmgen.00.B-value.enable
  123. net emcmot.01.enable <= axis.1.amp-enable-out
  124.  
  125. # encoder feedback
  126. setp hm2_[HOSTMOT2](BOARD).0.encoder.01.counter-mode 0
  127. setp hm2_[HOSTMOT2](BOARD).0.encoder.01.filter 1
  128. setp hm2_[HOSTMOT2](BOARD).0.encoder.01.index-invert 0
  129. setp hm2_[HOSTMOT2](BOARD).0.encoder.01.index-mask 0
  130. setp hm2_[HOSTMOT2](BOARD).0.encoder.01.index-mask-invert 0
  131.  
  132. setp hm2_[HOSTMOT2](BOARD).0.encoder.01.scale [AXIS_1]INPUT_SCALE
  133. net motor.01.pos-fb hm2_[HOSTMOT2](BOARD).0.encoder.01.position => pid.1.feedback
  134. net motor.01.pos-fb => axis.1.motor-pos-fb #push copy back to Axis GUI
  135.  
  136. # set PID loop gains from inifile
  137. setp pid.1.Pgain [AXIS_1]P
  138. setp pid.1.Igain [AXIS_1]I
  139. setp pid.1.Dgain [AXIS_1]D
  140. setp pid.1.bias [AXIS_1]BIAS
  141. setp pid.1.FF0 [AXIS_1]FF0
  142. setp pid.1.FF1 [AXIS_1]FF1
  143. setp pid.1.FF2 [AXIS_1]FF2
  144. setp pid.1.deadband [AXIS_1]DEADBAND
  145. setp pid.1.maxoutput [AXIS_1]MAX_OUTPUT
  146.  
  147. # position command signals
  148. # setp hm2_5i23.0.3pwmgen.00.B-value.output-type 1 #pwm on pin1, dir on pin2
  149. # setp hm2_5i23.0.3pwmgen.00.B-value.scale [AXIS_1]OUTPUT_SCALE
  150.  
  151. net emcmot.01.pos-cmd axis.1.motor-pos-cmd => pid.1.command
  152. # net motor.01.command pid.1.output => hm2_[HOSTMOT2]#(BOARD).0.pwmgen.01.value
  153.  
  154.  
  155. # ################
  156. # Z [2] Axis
  157. # ################
  158.  
  159. # axis enable chain
  160. newsig emcmot.02.enable bit
  161. sets emcmot.02.enable FALSE
  162. net emcmot.02.enable => pid.2.enable
  163. # net emcmot.02.enable => hm2_5i23.0.3pwmgen.00.C-value.enable
  164. net emcmot.02.enable <= axis.2.amp-enable-out
  165.  
  166. # encoder feedback
  167. setp hm2_[HOSTMOT2](BOARD).0.encoder.02.counter-mode 0
  168. setp hm2_[HOSTMOT2](BOARD).0.encoder.02.filter 1
  169. setp hm2_[HOSTMOT2](BOARD).0.encoder.02.index-invert 0
  170. setp hm2_[HOSTMOT2](BOARD).0.encoder.02.index-mask 0
  171. setp hm2_[HOSTMOT2](BOARD).0.encoder.02.index-mask-invert 0
  172.  
  173. setp hm2_[HOSTMOT2](BOARD).0.encoder.02.scale [AXIS_2]INPUT_SCALE
  174. net motor.02.pos-fb hm2_[HOSTMOT2](BOARD).0.encoder.02.position => pid.2.feedback
  175. net motor.02.pos-fb => axis.2.motor-pos-fb #push copy back to Axis GUI
  176.  
  177. # set PID loop gains from inifile
  178. setp pid.2.Pgain [AXIS_2]P
  179. setp pid.2.Igain [AXIS_2]I
  180. setp pid.2.Dgain [AXIS_2]D
  181. setp pid.2.bias [AXIS_2]BIAS
  182. setp pid.2.FF0 [AXIS_2]FF0
  183. setp pid.2.FF1 [AXIS_2]FF1
  184. setp pid.2.FF2 [AXIS_2]FF2
  185. setp pid.2.deadband [AXIS_2]DEADBAND
  186. setp pid.2.maxoutput [AXIS_2]MAX_OUTPUT
  187.  
  188. # position command signals
  189. # setp hm2_5i23.0.3pwmgen.00.C-value.output-type 1 #pwm on pin1, dir on #pin2
  190. # setp hm2_5i23.0.3pwmgen.00.C-value.scale [AXIS_2]OUTPUT_SCALE
  191.  
  192. net emcmot.02.pos-cmd axis.2.motor-pos-cmd => pid.2.command
  193. # net motor.02.command pid.2.output => hm2_5i23.0.3pwmgen.00.C-value.value
  194.  
  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. # only the Y servo has an index, X and Z home without using the index
  233. 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