Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2014
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.71 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.  
  74. # ################
  75. # X [0] Axis
  76. # ################
  77.  
  78. # axis enable chain
  79. newsig emcmot.00.enable bit
  80. sets emcmot.00.enable FALSE
  81. net emcmot.00.enable => pid.0.enable
  82. net emcmot.00.enable => hm2_5i23.0.3pwmgen.00.A-value.enable
  83. net emcmot.00.enable <= axis.0.amp-enable-out
  84.  
  85. # encoder feedback
  86. setp hm2_5i23.0.encoder.00.counter-mode 0
  87. setp hm2_5i23.0.encoder.00.filter 1
  88. setp hm2_5i23.0.encoder.00.index-invert 0
  89. setp hm2_5i23.0.encoder.00.index-mask 0
  90. setp hm2_5i23.0.encoder.00.index-mask-invert 0
  91.  
  92. setp hm2_5i23.0.encoder.00.scale [AXIS_0]INPUT_SCALE
  93. net motor.00.pos-fb hm2_5i23.0.encoder.00.position => pid.0.feedback
  94. net motor.00.pos-fb => axis.0.motor-pos-fb #push copy back to Axis GUI
  95.  
  96. # set PID loop gains from inifile
  97. setp pid.0.Pgain [AXIS_0]P
  98. setp pid.0.Igain [AXIS_0]I
  99. setp pid.0.Dgain [AXIS_0]D
  100. setp pid.0.bias [AXIS_0]BIAS
  101. setp pid.0.FF0 [AXIS_0]FF0
  102. setp pid.0.FF1 [AXIS_0]FF1
  103. setp pid.0.FF2 [AXIS_0]FF2
  104. setp pid.0.deadband [AXIS_0]DEADBAND
  105. setp pid.0.maxoutput [AXIS_0]MAX_OUTPUT
  106.  
  107. # position command signals
  108. setp hm2_5i23.0.3pwmgen.00.A-value.output-type 1 #pwm on pin1, dir on pin2
  109. setp hm2_5i23.0.3pwmgen.00.A-value.scale [AXIS_0]OUTPUT_SCALE
  110.  
  111. net emcmot.00.pos-cmd axis.0.motor-pos-cmd => pid.0.command
  112. net motor.00.command pid.0.output => hm2_5i23.0.3pwmgen.00.A-value.value
  113.  
  114.  
  115. # ################
  116. # Y [1] Axis
  117. # ################
  118.  
  119. # axis enable chain
  120. newsig emcmot.01.enable bit
  121. sets emcmot.01.enable FALSE
  122. net emcmot.01.enable => pid.1.enable
  123. net emcmot.01.enable => hm2_5i23.0.3pwmgen.00.B-value.enable
  124. net emcmot.01.enable <= axis.1.amp-enable-out
  125.  
  126. # encoder feedback
  127. setp hm2_5i23.0.encoder.01.counter-mode 0
  128. setp hm2_5i23.0.encoder.01.filter 1
  129. setp hm2_5i23.0.encoder.01.index-invert 0
  130. setp hm2_5i23.0.encoder.01.index-mask 0
  131. setp hm2_5i23.0.encoder.01.index-mask-invert 0
  132.  
  133. setp hm2_5i23.0.encoder.01.scale [AXIS_1]INPUT_SCALE
  134. net motor.01.pos-fb hm2_5i23.0.encoder.01.position => pid.1.feedback
  135. net motor.01.pos-fb => axis.1.motor-pos-fb #push copy back to Axis GUI
  136.  
  137. # set PID loop gains from inifile
  138. setp pid.1.Pgain [AXIS_1]P
  139. setp pid.1.Igain [AXIS_1]I
  140. setp pid.1.Dgain [AXIS_1]D
  141. setp pid.1.bias [AXIS_1]BIAS
  142. setp pid.1.FF0 [AXIS_1]FF0
  143. setp pid.1.FF1 [AXIS_1]FF1
  144. setp pid.1.FF2 [AXIS_1]FF2
  145. setp pid.1.deadband [AXIS_1]DEADBAND
  146. setp pid.1.maxoutput [AXIS_1]MAX_OUTPUT
  147.  
  148. # position command signals
  149. setp hm2_5i23.0.3pwmgen.00.B-value.output-type 1 #pwm on pin1, dir on pin2
  150. setp hm2_5i23.0.3pwmgen.00.B-value.scale [AXIS_1]OUTPUT_SCALE
  151.  
  152. net emcmot.01.pos-cmd axis.1.motor-pos-cmd => pid.1.command
  153. net motor.01.command pid.1.output => hm2_5i23.0.3pwmgen.00.B-value1.value
  154.  
  155.  
  156. # ################
  157. # Z [2] Axis
  158. # ################
  159.  
  160. # axis enable chain
  161. newsig emcmot.02.enable bit
  162. sets emcmot.02.enable FALSE
  163. net emcmot.02.enable => pid.2.enable
  164. net emcmot.02.enable => hm2_5i23.0.3pwmgen.00.C-value.enable
  165. net emcmot.02.enable <= axis.2.amp-enable-out
  166.  
  167. # encoder feedback
  168. setp hm2_5i23.0.encoder.02.counter-mode 0
  169. setp hm2_5i23.0.encoder.02.filter 1
  170. setp hm2_5i23.0.encoder.02.index-invert 0
  171. setp hm2_5i23.0.encoder.02.index-mask 0
  172. setp hm2_5i23.0.encoder.02.index-mask-invert 0
  173.  
  174. setp hm2_5i23.0.encoder.02.scale [AXIS_2]INPUT_SCALE
  175. net motor.02.pos-fb hm2_5i23.0.encoder.02.position => pid.2.feedback
  176. net motor.02.pos-fb => axis.2.motor-pos-fb #push copy back to Axis GUI
  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_5i23.0.3pwmgen.00.C-value.output-type 1 #pwm on pin1, dir on #pin2
  191. setp hm2_5i23.0.3pwmgen.00.C-value.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_5i23.0.3pwmgen.00.C-value.value
  195.  
  196.  
  197. # ##################################################
  198. # Standard I/O Block - EStop, Etc
  199. # ##################################################
  200.  
  201. # create a signal for the estop loopback
  202. net estop-loop iocontrol.0.user-enable-out => iocontrol.0.emc-enable-in
  203.  
  204. # create signals for tool loading loopback
  205. net tool-prep-loop iocontrol.0.tool-prepare => iocontrol.0.tool-prepared
  206. net tool-change-loop iocontrol.0.tool-change => iocontrol.0.tool-changed
  207.  
  208.  
  209. #
  210. # homing
  211. #
  212.  
  213. #
  214. # In this example, each of the three axes have their own home switch. All
  215. # home switches are connected to GPIO 25, though hostmot2 boards generally
  216. # have enough GPIO pins to put each axis' home switch on its own pin.
  217. #
  218. # Each switch is normally open, momentarily closed. When the switch is open,
  219. # GPIO 25 floats high (because that is the hostmot2 way). When the switch is
  220. # closed, it shorts GPIO 25 to ground.
  221. #
  222. # EMC expects the value on the .home-sw-in HAL pin to be active high, ie
  223. # True when the switch is closed and False when the switch is open.
  224. # We get this behavior by linking the GPIO .in_not pin instead of the .in
  225. # pin.
  226. #
  227.  
  228. net home-switch <= hm2_[HOSTMOT2](BOARD).0.gpio.025.in_not
  229. net home-switch => axis.0.home-sw-in
  230. net home-switch => axis.1.home-sw-in
  231. net home-switch => axis.2.home-sw-in
  232.  
  233. # only the Y servo has an index, X and Z home without using the index
  234. 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