Advertisement
Guest User

hal file

a guest
Apr 26th, 2010
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.13 KB | None | 0 0
  1. # #######################################
  2. #
  3. # HAL file for HostMot2 with 3 steppers
  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. # only the 7i43 needs this, but it doesnt hurt the others
  35. #loadrt probe_parport
  36.  
  37. # hostmot2 driver
  38. loadrt hostmot2
  39.  
  40. # load low-level driver
  41. loadrt [HOSTMOT2](DRIVER) config=[HOSTMOT2](CONFIG)
  42.  
  43. setp hm2_[HOSTMOT2](BOARD).0.watchdog.timeout_ns 10000000
  44.  
  45. # Load Classic ladder module that runs in real time
  46. loadrt classicladder_rt numPhysInputs=32 numPhysOutputs=20 numS32in=10 numS32out=10 numFloatIn=10 numFloatOut=10
  47.  
  48. loadrt not count=1
  49.  
  50.  
  51. # ################################################
  52. # THREADS
  53. # ################################################
  54.  
  55. addf hm2_[HOSTMOT2](BOARD).0.read servo-thread
  56. addf motion-command-handler servo-thread
  57. addf motion-controller servo-thread
  58. # revel in the free time here from not having to run PID
  59. addf hm2_[HOSTMOT2](BOARD).0.write servo-thread
  60. addf hm2_[HOSTMOT2](BOARD).0.pet_watchdog servo-thread
  61. addf not.0 servo-thread
  62. addf classicladder.0.refresh servo-thread
  63.  
  64.  
  65. # ######################################################
  66. # Axis-of-motion Specific Configs (not the GUI)
  67. # ######################################################
  68.  
  69.  
  70. # ################
  71. # X [0] Axis
  72. # ################
  73.  
  74. # axis enable chain
  75. newsig emcmot.00.enable bit
  76. sets emcmot.00.enable FALSE
  77.  
  78. net emcmot.00.enable <= axis.0.amp-enable-out
  79. net emcmot.00.enable => hm2_[HOSTMOT2](BOARD).0.stepgen.00.enable
  80.  
  81.  
  82. # position command and feedback
  83. net emcmot.00.pos-cmd <= axis.0.motor-pos-cmd
  84. net emcmot.00.pos-cmd => hm2_[HOSTMOT2](BOARD).0.stepgen.00.position-cmd
  85.  
  86. net motor.00.pos-fb <= hm2_[HOSTMOT2](BOARD).0.stepgen.00.position-fb
  87. net motor.00.pos-fb => axis.0.motor-pos-fb
  88.  
  89.  
  90. # timing parameters
  91. setp hm2_[HOSTMOT2](BOARD).0.stepgen.00.dirsetup [AXIS_0]DIRSETUP
  92. setp hm2_[HOSTMOT2](BOARD).0.stepgen.00.dirhold [AXIS_0]DIRHOLD
  93.  
  94. setp hm2_[HOSTMOT2](BOARD).0.stepgen.00.steplen [AXIS_0]STEPLEN
  95. setp hm2_[HOSTMOT2](BOARD).0.stepgen.00.stepspace [AXIS_0]STEPSPACE
  96.  
  97. setp hm2_[HOSTMOT2](BOARD).0.stepgen.00.position-scale [AXIS_0]SCALE
  98.  
  99. setp hm2_[HOSTMOT2](BOARD).0.stepgen.00.maxvel 0
  100. setp hm2_[HOSTMOT2](BOARD).0.stepgen.00.maxaccel 0
  101.  
  102. setp hm2_[HOSTMOT2](BOARD).0.stepgen.00.step_type 0
  103.  
  104.  
  105. # ################
  106. # Y [1] Axis
  107. # ################
  108.  
  109. # axis enable chain
  110. newsig emcmot.01.enable bit
  111. sets emcmot.01.enable FALSE
  112.  
  113. net emcmot.01.enable <= axis.1.amp-enable-out
  114. net emcmot.01.enable => hm2_[HOSTMOT2](BOARD).0.stepgen.01.enable
  115.  
  116.  
  117. # position command and feedback
  118. net emcmot.01.pos-cmd <= axis.1.motor-pos-cmd
  119. net emcmot.01.pos-cmd => hm2_[HOSTMOT2](BOARD).0.stepgen.01.position-cmd
  120.  
  121. net motor.01.pos-fb <= hm2_[HOSTMOT2](BOARD).0.stepgen.01.position-fb
  122. net motor.01.pos-fb => axis.1.motor-pos-fb
  123.  
  124.  
  125. # timing parameters
  126. setp hm2_[HOSTMOT2](BOARD).0.stepgen.01.dirsetup [AXIS_1]DIRSETUP
  127. setp hm2_[HOSTMOT2](BOARD).0.stepgen.01.dirhold [AXIS_1]DIRHOLD
  128.  
  129. setp hm2_[HOSTMOT2](BOARD).0.stepgen.01.steplen [AXIS_1]STEPLEN
  130. setp hm2_[HOSTMOT2](BOARD).0.stepgen.01.stepspace [AXIS_1]STEPSPACE
  131.  
  132. setp hm2_[HOSTMOT2](BOARD).0.stepgen.01.position-scale [AXIS_1]SCALE
  133.  
  134. setp hm2_[HOSTMOT2](BOARD).0.stepgen.01.maxvel 0
  135. setp hm2_[HOSTMOT2](BOARD).0.stepgen.01.maxaccel 0
  136.  
  137. setp hm2_[HOSTMOT2](BOARD).0.stepgen.01.step_type 0
  138.  
  139.  
  140. # ################
  141. # Z [2] Axis
  142. # ################
  143.  
  144. # axis enable chain
  145. newsig emcmot.02.enable bit
  146. sets emcmot.02.enable FALSE
  147.  
  148. net emcmot.02.enable <= axis.2.amp-enable-out
  149. net emcmot.02.enable => hm2_[HOSTMOT2](BOARD).0.stepgen.02.enable
  150.  
  151.  
  152. # position command and feedback
  153. net emcmot.02.pos-cmd <= axis.2.motor-pos-cmd
  154. net emcmot.02.pos-cmd => hm2_[HOSTMOT2](BOARD).0.stepgen.02.position-cmd
  155.  
  156. net motor.02.pos-fb <= hm2_[HOSTMOT2](BOARD).0.stepgen.02.position-fb
  157. net motor.02.pos-fb => axis.2.motor-pos-fb
  158.  
  159.  
  160. # timing parameters
  161. setp hm2_[HOSTMOT2](BOARD).0.stepgen.02.dirsetup [AXIS_2]DIRSETUP
  162. setp hm2_[HOSTMOT2](BOARD).0.stepgen.02.dirhold [AXIS_2]DIRHOLD
  163.  
  164. setp hm2_[HOSTMOT2](BOARD).0.stepgen.02.steplen [AXIS_2]STEPLEN
  165. setp hm2_[HOSTMOT2](BOARD).0.stepgen.02.stepspace [AXIS_2]STEPSPACE
  166.  
  167. setp hm2_[HOSTMOT2](BOARD).0.stepgen.02.position-scale [AXIS_2]SCALE
  168.  
  169. setp hm2_[HOSTMOT2](BOARD).0.stepgen.02.maxvel 0
  170. setp hm2_[HOSTMOT2](BOARD).0.stepgen.02.maxaccel 0
  171.  
  172. setp hm2_[HOSTMOT2](BOARD).0.stepgen.02.step_type 0
  173.  
  174. #
  175. # The Mesa AnyIO output pins can be in open-drain mode (drive low, float
  176. # high) or push/pull mode (drive low, drive high).
  177. #
  178. # When a logical output is 1 in open-drain mode, the FPGA lets the pin
  179. # float and it gets pulled high to +5V via a 10K resistor.
  180. #
  181. # When a logical output is 1 in push/pull mode, the FPGA pushes the pin
  182. # high but only to +3.3V. This is problematic on some kinds of inputs.
  183. #
  184. #setp hm2_[HOSTMOT2](BOARD).0.gpio.048.is_opendrain 1
  185. #setp hm2_[HOSTMOT2](BOARD).0.gpio.049.is_opendrain 1
  186. #setp hm2_[HOSTMOT2](BOARD).0.gpio.054.is_opendrain 1
  187. #setp hm2_[HOSTMOT2](BOARD).0.gpio.055.is_opendrain 1
  188. #setp hm2_[HOSTMOT2](BOARD).0.gpio.060.is_opendrain 1
  189. #setp hm2_[HOSTMOT2](BOARD).0.gpio.061.is_opendrain 1
  190.  
  191.  
  192. # hm2 pins 40-47 are outputs
  193. # hm2 pin 24-39 are inputs
  194.  
  195. # external output signals
  196. # --- DOUT-00 --- Slitter knife down
  197. setp hm2_5i20.0.gpio.040.is_output true
  198. net dout-00 <= motion.digital-out-00
  199. net dout-00 => hm2_5i20.0.gpio.040.out
  200.  
  201. # --- DOUT-01 --- Cutter knife down
  202. setp hm2_5i20.0.gpio.041.is_output true
  203. net dout-01 <= motion.digital-out-01
  204. net dout-01 => hm2_5i20.0.gpio.041.out => classicladder.0.in-03
  205. # net dout-01
  206.  
  207. # --- DOUT-02 --- In cycle light (auto mode?)
  208. setp hm2_5i20.0.gpio.042.is_output true
  209.  
  210. net dout-02 => hm2_5i20.0.gpio.042.out
  211.  
  212. # --- DOUT-03 --- System ready ??
  213. setp hm2_5i20.0.gpio.043.is_output true
  214.  
  215. net dout-03 => hm2_5i20.0.gpio.043.out
  216.  
  217. # --- DOUT-04 ---
  218. setp hm2_5i20.0.gpio.044.is_output true
  219.  
  220. net dout-04 => hm2_5i20.0.gpio.044.out
  221. # --- DOUT-05 ---
  222. setp hm2_5i20.0.gpio.045.is_output true
  223.  
  224. net dout-05 => hm2_5i20.0.gpio.045.out
  225. # --- DOUT-06 ---
  226. setp hm2_5i20.0.gpio.046.is_output true
  227.  
  228. net dout-06 => hm2_5i20.0.gpio.046.out
  229.  
  230. # ----DOUT-07---
  231. setp hm2_5i20.0.gpio.047.is_output true
  232.  
  233. net enable => hm2_5i20.0.gpio.047.out
  234.  
  235. # **** Setup for external estop ladder program -START ****
  236.  
  237. net estop-out <= iocontrol.0.user-enable-out
  238. net estop-out => classicladder.0.in-00
  239. net estop-ext hm2_5i20.0.gpio.024.in => classicladder.0.in-01
  240. # When the operator clicks on the Estop button when the system is in Estop, the user-request-enable bit flashes on
  241. net estop-strobe classicladder.0.in-02 <= iocontrol.0.user-request-enable
  242. net estop-outcl classicladder.0.out-00 => iocontrol.0.emc-enable-in
  243.  
  244. # **** Setup for external estop ladder program -END ****
  245.  
  246. # --- DIN-01 --- Cutter knife down switch
  247. net din-01 <= hm2_5i20.0.gpio.025.in
  248. net din-01 => motion.digital-in-00
  249. # => classicladder.0.in-03
  250.  
  251.  
  252. # --- DIN-02 --- Cutter knife up switch
  253. net din-02 <= hm2_5i20.0.gpio.026.in
  254. #net din-02 => motion.digital-in-01 => classicladder.0.in-04
  255.  
  256. # --- DIN-03 --- Slitter knife down switch
  257. net din-03 <= hm2_5i20.0.gpio.027.in
  258. net din-03 => classicladder.0.in-05
  259.  
  260. # --- DIN-04 --- Sliter knife up switch
  261. net din-04 <= hm2_5i20.0.gpio.028.in
  262. net din-04 => classicladder.0.in-06
  263.  
  264. # --- DIN-05 ---
  265. # --- JOG-X-POS ---
  266. net jog-x-pos <= hm2_5i20.0.gpio.029.in
  267. net jog-x-pos => halui.jog.0.plus
  268.  
  269. # --- DIN-06 ---
  270. # --- JOG-X-NEG ---
  271. net jog-x-neg <= hm2_5i20.0.gpio.030.in
  272. net jog-x-neg halui.jog.0.minus
  273.  
  274. # --- DIN-07 ---
  275. # --- JOG-Y-POS ---
  276. net jog-y-pos <= hm2_5i20.0.gpio.031.in
  277. net jog-y-pos halui.jog.1.plus
  278.  
  279. # --- DIN-08 ---
  280. # --- JOG-Y-NEG ---
  281. net jog-y-neg <= hm2_5i20.0.gpio.032.in
  282. net jog-y-neg halui.jog.1.minus
  283.  
  284. # --- DIN-09 ---
  285. # --- JOG-Z-POS ---
  286. net jog-z-pos <= hm2_5i20.0.gpio.033.in
  287. net jog-z-pos halui.jog.2.plus
  288.  
  289. # --- DIN-10 ---
  290. # --- JOG-Z-NEG ---
  291. net jog-z-neg <= hm2_5i20.0.gpio.034.in
  292. net jog-z-neg halui.jog.2.minus
  293.  
  294. # --- DIN-11 ---
  295.  
  296. # --- DIN-12 ---
  297.  
  298. # --- DIN-13 ---
  299.  
  300. # --- DIN-14 ---
  301. net din-14 <= hm2_5i20.0.gpio.038.in
  302. net din-14 => motion.digital-in-02
  303.  
  304. # --- DIN-15 ---
  305. net din-15 <= hm2_5i20.0.gpio.039.in
  306. net din-15 => motion.digital-in-03
  307.  
  308. # COUNTER RESET BIT FROM GCODE TO LADDER COUNTER
  309. net count_rst motion.digital-out-02 => classicladder.0.in-07
  310.  
  311.  
  312.  
  313.  
  314.  
  315. net enable => motion.motion-enabled
  316.  
  317. # create signals for tool loading loopback
  318. #net tool-prep-loop iocontrol.0.tool-prepare => iocontrol.0.tool-prepared
  319. #net tool-change-loop iocontrol.0.tool-change => iocontrol.0.tool-changed
  320.  
  321. ### Added with Classic ladder interface
  322.  
  323.  
  324. # Load Classicladder without GUI (can reload LADDER GUI in AXIS GUI
  325. # without classic ladder gui
  326. #loadusr classicladder --nogui custom.clp
  327. # with classic ladder gui
  328. loadusr classicladder custom.clp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement