Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2014
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.81 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. setp hm2_5i23.0.3pwmgen.00.deadtime 0
  50. setp hm2_5i23.0.3pwmgen.01.deadtime 0
  51.  
  52. # ################################################
  53. # THREADS
  54. # ################################################
  55.  
  56. addf hm2_5i23.0.read servo-thread
  57.  
  58. addf motion-command-handler servo-thread
  59. addf motion-controller servo-thread
  60.  
  61. addf pid.0.do-pid-calcs servo-thread
  62. addf pid.1.do-pid-calcs servo-thread
  63. addf pid.2.do-pid-calcs servo-thread
  64.  
  65. addf hm2_5i23.0.write servo-thread
  66. addf hm2_5i23.0.pet_watchdog servo-thread
  67.  
  68.  
  69. # ######################################################
  70. # Axis-of-motion Specific Configs (not the GUI)
  71. # ######################################################
  72.  
  73. #Enable for all three axis
  74.  
  75. net emcmot.00.enable => hm2_5i23.0.3pwmgen.00.enable
  76.  
  77. # ################
  78. # X [0] Axis
  79. # ################
  80.  
  81. # axis enable chain
  82. #newsig emcmot.00.enable bit
  83. #sets emcmot.00.enable FALSE
  84. #net emcmot.00.enable => pid.0.enable
  85. #net emcmot.00.enable => hm2_5i23.0.3pwmgen.00.A-value.enable
  86. net emcmot.00.enable <= axis.0.amp-enable-out
  87.  
  88. # encoder feedback
  89. setp hm2_5i23.0.encoder.00.counter-mode 0
  90. setp hm2_5i23.0.encoder.00.filter 1
  91. setp hm2_5i23.0.encoder.00.index-invert 0
  92. setp hm2_5i23.0.encoder.00.index-mask 0
  93. setp hm2_5i23.0.encoder.00.index-mask-invert 0
  94.  
  95. setp hm2_5i23.0.encoder.00.scale [AXIS_0]INPUT_SCALE
  96. net motor.00.pos-fb hm2_5i23.0.encoder.00.position => pid.0.feedback
  97. net motor.00.pos-fb => axis.0.motor-pos-fb #push copy back to Axis GUI
  98.  
  99. # set PID loop gains from inifile
  100. setp pid.0.Pgain [AXIS_0]P
  101. setp pid.0.Igain [AXIS_0]I
  102. setp pid.0.Dgain [AXIS_0]D
  103. setp pid.0.bias [AXIS_0]BIAS
  104. setp pid.0.FF0 [AXIS_0]FF0
  105. setp pid.0.FF1 [AXIS_0]FF1
  106. setp pid.0.FF2 [AXIS_0]FF2
  107. setp pid.0.deadband [AXIS_0]DEADBAND
  108. setp pid.0.maxoutput [AXIS_0]MAX_OUTPUT
  109.  
  110. # position command signals
  111. #setp hm2_5i23.0.3pwmgen.00.A-value.output-type 1 #pwm on pin1, dir on pin2
  112. #setp hm2_5i23.0.3pwmgen.00.A-value.scale [AXIS_0]OUTPUT_SCALE
  113.  
  114. net emcmot.00.pos-cmd axis.0.motor-pos-cmd => pid.0.command
  115. #net motor.00.command pid.0.output => hm2_5i23.0.3pwmgen.00.A-value.value
  116.  
  117.  
  118. # ################
  119. # Y [1] Axis
  120. # ################
  121.  
  122. # axis enable chain
  123. newsig emcmot.01.enable bit
  124. sets emcmot.01.enable FALSE
  125. #net emcmot.01.enable => pid.1.enable
  126. #net emcmot.01.enable => hm2_5i23.0.3pwmgen.00.B-value.enable
  127. net emcmot.01.enable <= axis.1.amp-enable-out
  128.  
  129. # encoder feedback
  130. setp hm2_5i23.0.encoder.01.counter-mode 0
  131. setp hm2_5i23.0.encoder.01.filter 1
  132. setp hm2_5i23.0.encoder.01.index-invert 0
  133. setp hm2_5i23.0.encoder.01.index-mask 0
  134. setp hm2_5i23.0.encoder.01.index-mask-invert 0
  135.  
  136. setp hm2_5i23.0.encoder.01.scale [AXIS_1]INPUT_SCALE
  137. net motor.01.pos-fb hm2_5i23.0.encoder.01.position => pid.1.feedback
  138. net motor.01.pos-fb => axis.1.motor-pos-fb #push copy back to Axis GUI
  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. # position command signals
  152. #setp hm2_5i23.0.3pwmgen.00.B-value.output-type 1 #pwm on pin1, dir on pin2
  153. #setp hm2_5i23.0.3pwmgen.00.B-value.scale [AXIS_1]OUTPUT_SCALE
  154.  
  155. net emcmot.01.pos-cmd axis.1.motor-pos-cmd => pid.1.command
  156. #net motor.01.command pid.1.output => hm2_5i23.0.3pwmgen.00.B-value1.value
  157.  
  158.  
  159. # ################
  160. # Z [2] Axis
  161. # ################
  162.  
  163. # axis enable chain
  164. newsig emcmot.02.enable bit
  165. sets emcmot.02.enable FALSE
  166. #net emcmot.02.enable => pid.2.enable
  167. #net emcmot.02.enable => hm2_5i23.0.3pwmgen.00.C-value.enable
  168. net emcmot.02.enable <= axis.2.amp-enable-out
  169.  
  170. # encoder feedback
  171. setp hm2_5i23.0.encoder.02.counter-mode 0
  172. setp hm2_5i23.0.encoder.02.filter 1
  173. setp hm2_5i23.0.encoder.02.index-invert 0
  174. setp hm2_5i23.0.encoder.02.index-mask 0
  175. setp hm2_5i23.0.encoder.02.index-mask-invert 0
  176.  
  177. setp hm2_5i23.0.encoder.02.scale [AXIS_2]INPUT_SCALE
  178. net motor.02.pos-fb hm2_5i23.0.encoder.02.position => pid.2.feedback
  179. net motor.02.pos-fb => axis.2.motor-pos-fb #push copy back to Axis GUI
  180.  
  181. # set PID loop gains from inifile
  182. setp pid.2.Pgain [AXIS_2]P
  183. setp pid.2.Igain [AXIS_2]I
  184. setp pid.2.Dgain [AXIS_2]D
  185. setp pid.2.bias [AXIS_2]BIAS
  186. setp pid.2.FF0 [AXIS_2]FF0
  187. setp pid.2.FF1 [AXIS_2]FF1
  188. setp pid.2.FF2 [AXIS_2]FF2
  189. setp pid.2.deadband [AXIS_2]DEADBAND
  190. setp pid.2.maxoutput [AXIS_2]MAX_OUTPUT
  191.  
  192. # position command signals
  193. #setp hm2_5i23.0.3pwmgen.00.C-value.output-type 1 #pwm on pin1, dir on #pin2
  194. #setp hm2_5i23.0.3pwmgen.00.C-value.scale [AXIS_2]OUTPUT_SCALE
  195.  
  196. net emcmot.02.pos-cmd axis.2.motor-pos-cmd => pid.2.command
  197. #net motor.02.command pid.2.output => hm2_5i23.0.3pwmgen.00.C-value.value
  198.  
  199.  
  200. # ##################################################
  201. # Standard I/O Block - EStop, Etc
  202. # ##################################################
  203.  
  204. # create a signal for the estop loopback
  205. net estop-loop iocontrol.0.user-enable-out => iocontrol.0.emc-enable-in
  206.  
  207. # create signals for tool loading loopback
  208. net tool-prep-loop iocontrol.0.tool-prepare => iocontrol.0.tool-prepared
  209. net tool-change-loop iocontrol.0.tool-change => iocontrol.0.tool-changed
  210.  
  211.  
  212. #
  213. # homing
  214. #
  215.  
  216. #
  217. # In this example, each of the three axes have their own home switch. All
  218. # home switches are connected to GPIO 25, though hostmot2 boards generally
  219. # have enough GPIO pins to put each axis' home switch on its own pin.
  220. #
  221. # Each switch is normally open, momentarily closed. When the switch is open,
  222. # GPIO 25 floats high (because that is the hostmot2 way). When the switch is
  223. # closed, it shorts GPIO 25 to ground.
  224. #
  225. # EMC expects the value on the .home-sw-in HAL pin to be active high, ie
  226. # True when the switch is closed and False when the switch is open.
  227. # We get this behavior by linking the GPIO .in_not pin instead of the .in
  228. # pin.
  229. #
  230.  
  231. net home-switch <= hm2_[HOSTMOT2](BOARD).0.gpio.025.in_not
  232. net home-switch => axis.0.home-sw-in
  233. net home-switch => axis.1.home-sw-in
  234. net home-switch => axis.2.home-sw-in
  235.  
  236. # only the Y servo has an index, X and Z home without using the index
  237. net y-index-enable hm2_5i23.0.encoder.01.index-enable <=> axis.1.index-enable
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement