Advertisement
Guest User

Hal 12-30

a guest
Dec 30th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.18 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=4
  36.  
  37. # only the 7i43 needs this, but it doesnt hurt the others
  38. # loadrt probe_parport Removed
  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_[HOSTMOT2](BOARD).0.pwmgen.pwm_frequency 24000
  49.  
  50. setp hm2_[HOSTMOT2](BOARD).0.watchdog.timeout_ns 10000000
  51.  
  52. ###### ADDED
  53. # load real time components
  54. ##loadrt pid num_chan=2 #loaded line35
  55. loadrt classicladder_rt
  56.  
  57. # numS32in=5 numS32out=5 numPhysInputs=35 numBits=30 numPhysOutputs=22
  58. loadrt weighted_sum wsum_sizes=4
  59. loadrt and2 count=6
  60. loadrt mux4 names=mpg-scale
  61. loadrt or2 count=6
  62. loadrt not count=2
  63. loadrt mult2 count=3
  64. loadrt mux16
  65. loadrt time
  66. loadrt toggle count=2
  67. loadrt toggle2nist count=2
  68.  
  69.  
  70. # load user space components
  71. loadusr halui
  72. loadusr classicladder --nogui hardinge.clp
  73.  
  74. # Flood Toggle
  75. addf and2.5 servo-thread
  76. addf toggle.1 servo-thread
  77. addf toggle2nist.1 servo-thread
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84. # ################################################
  85. # THREADS
  86. # ################################################
  87.  
  88. addf hm2_[HOSTMOT2](BOARD).0.read servo-thread
  89.  
  90. addf motion-command-handler servo-thread
  91. addf motion-controller servo-thread
  92.  
  93. addf pid.0.do-pid-calcs servo-thread
  94. # addf pid.1.do-pid-calcs servo-thread refers to Y axis
  95. addf pid.2.do-pid-calcs servo-thread
  96. #addf pid.3.do-pid-calcs servo-thread
  97.  
  98.  
  99.  
  100. addf hm2_[HOSTMOT2](BOARD).0.write servo-thread
  101.  
  102.  
  103. # addf hm2_[HOSTMOT2](BOARD).0.pet_watchdog servo-thread Removed
  104.  
  105. addf process_wsums servo-thread
  106.  
  107. addf classicladder.0.refresh servo-thread
  108.  
  109.  
  110.  
  111. # ######################################################
  112. # Axis-of-motion Specific Configs (not the GUI)
  113. # ######################################################
  114.  
  115. #########
  116. #set scales
  117. ########
  118. loadrt scale count=2
  119.  
  120. loadrt near
  121. addf near.0 servo-thread
  122.  
  123. # ################
  124. # X [0] Axis
  125. # ################
  126.  
  127. # axis enable chain
  128. newsig emcmot.00.enable bit
  129. sets emcmot.00.enable FALSE
  130. net emcmot.00.enable => pid.0.enable
  131. net emcmot.00.enable => hm2_[HOSTMOT2](BOARD).0.pwmgen.00.enable
  132. net emcmot.00.enable <= axis.0.amp-enable-out
  133.  
  134. setp hm2_[HOSTMOT2](BOARD).0.resolver.00.scale [AXIS_0]INPUT_SCALE
  135. net motor.00.pos-fb hm2_[HOSTMOT2](BOARD).0.resolver.00.position => pid.0.feedback
  136. net motor.00.pos-fb => axis.0.motor-pos-fb #push copy back to Axis GUI
  137.  
  138. # set PID loop gains from inifile
  139. setp pid.0.Pgain [AXIS_0]P
  140. setp pid.0.Igain [AXIS_0]I
  141. setp pid.0.Dgain [AXIS_0]D
  142. setp pid.0.bias [AXIS_0]BIAS
  143. setp pid.0.FF0 [AXIS_0]FF0
  144. setp pid.0.FF1 [AXIS_0]FF1
  145. setp pid.0.FF2 [AXIS_0]FF2
  146. setp pid.0.deadband [AXIS_0]DEADBAND
  147. setp pid.0.maxoutput [AXIS_0]MAX_OUTPUT
  148.  
  149. # position command signals
  150. setp hm2_5i23.0.pwmgen.00.output-type 2 #up on pin1, down on pin2
  151. setp hm2_5i23.0.pwmgen.00.scale [AXIS_0]OUTPUT_SCALE
  152.  
  153. net emcmot.00.pos-cmd axis.0.motor-pos-cmd => pid.0.command
  154. net motor.00.command pid.0.output => hm2_[HOSTMOT2](BOARD).0.pwmgen.00.value
  155.  
  156.  
  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_[HOSTMOT2](BOARD).0.pwmgen.02.enable
  168. net emcmot.02.enable <= axis.2.amp-enable-out
  169.  
  170. setp hm2_[HOSTMOT2](BOARD).0.resolver.02.scale [AXIS_2]INPUT_SCALE
  171. net motor.02.pos-fb hm2_[HOSTMOT2](BOARD).0.resolver.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. setp hm2_[HOSTMOT2](BOARD).0.pwmgen.02.output-type 2 #up on pin1, down on pin2
  187. setp hm2_[HOSTMOT2](BOARD).0.pwmgen.02.scale [AXIS_2]OUTPUT_SCALE
  188.  
  189. net emcmot.02.pos-cmd axis.2.motor-pos-cmd => pid.2.command
  190. net motor.02.command pid.2.output => hm2_[HOSTMOT2](BOARD).0.pwmgen.02.value
  191.  
  192.  
  193.  
  194. net home-switch-X axis.0.home-sw-in <= hm2_[HOSTMOT2](BOARD).0.gpio.028.in
  195. net home-switch-Z axis.2.home-sw-in <= hm2_[HOSTMOT2](BOARD).0.gpio.029.in
  196.  
  197.  
  198. #
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206. # ##################################################
  207. # Standard I/O Block - EStop, Etc
  208. # ##################################################
  209.  
  210. # create a signal for the estop loopback
  211. net estop-loop iocontrol.0.user-enable-out => iocontrol.0.emc-enable-in
  212.  
  213.  
  214. # set up outputs for 7i37
  215. setp hm2_5i23.0.gpio.040.is_output 1
  216. setp hm2_5i23.0.gpio.040.invert_output 1
  217. setp hm2_5i23.0.gpio.041.is_output 1
  218. setp hm2_5i23.0.gpio.041.invert_output 1
  219. setp hm2_5i23.0.gpio.042.is_output 1
  220. setp hm2_5i23.0.gpio.042.invert_output 1
  221. setp hm2_5i23.0.gpio.043.is_output 1
  222. setp hm2_5i23.0.gpio.043.invert_output 1
  223. setp hm2_5i23.0.gpio.044.is_output 1
  224. setp hm2_5i23.0.gpio.044.invert_output 1
  225. setp hm2_5i23.0.gpio.045.is_output 1
  226. setp hm2_5i23.0.gpio.045.invert_output 1
  227. setp hm2_5i23.0.gpio.046.is_output 1
  228. setp hm2_5i23.0.gpio.046.invert_output 1
  229. setp hm2_5i23.0.gpio.047.is_output 1
  230. setp hm2_5i23.0.gpio.047.invert_output 1
  231. setp hm2_5i23.0.gpio.064.is_output 1
  232. setp hm2_5i23.0.gpio.064.invert_output 1
  233.  
  234.  
  235. # End
  236.  
  237.  
  238. #
  239. # homing
  240. #
  241.  
  242. #
  243. # In this example, each of the three axes have their own home switch. All
  244. # home switches are connected to GPIO 25, though hostmot2 boards generally
  245. # have enough GPIO pins to put each axis' home switch on its own pin.
  246. #
  247. # Each switch is normally open, momentarily closed. When the switch is open,
  248. # GPIO 25 floats high (because that is the hostmot2 way). When the switch is
  249. # closed, it shorts GPIO 25 to ground.
  250. #
  251. # EMC expects the value on the .home-sw-in HAL pin to be active high, ie
  252. # True when the switch is closed and False when the switch is open.
  253. # We get this behavior by linking the GPIO .in_not pin instead of the .in
  254. # pin.
  255. #
  256.  
  257.  
  258. ##ADDED FILES
  259.  
  260. # Turn Control On Added Files
  261.  
  262. # setp hm2_[HOSTMOT2](BOARD).0.gpio.041.is_output 1
  263. # setp hm2_[HOSTMOT2](BOARD).0.gpio.041.invert_output 1
  264.  
  265. # pull the CR-1 relay in when the Power Button is on JT
  266. # net machine-power <= motion.motion-enabled =>
  267.  
  268. # CR-1 Control Power
  269. # net machine-power => hm2_5i20.0.gpio.046.out
  270. # net machine-power => hm2_5i23.0.gpio.041
  271.  
  272.  
  273.  
  274.  
  275.  
  276. net machine-power <= motion.motion-enabled =>
  277. net machine-power => hm2_5i23.0.gpio.040.out
  278.  
  279. net machine-power => hm2_5i23.0.gpio.041.out
  280. # End
  281.  
  282.  
  283.  
  284.  
  285. #net home-switch <= hm2_[HOSTMOT2](BOARD).0.gpio.024.in_not
  286. #net home-switch => axis.0.home-sw-in
  287. #net home-switch => axis.1.home-sw-in
  288. #net home-switch => axis.2.home-sw-in
  289.  
  290. # only the Y servo has an index, X and Z home without using the index
  291.  
  292. net x-index-enable hm2_[HOSTMOT2](BOARD).0.resolver.00.index-enable <=> axis.0.index-enable
  293.  
  294. net z-index-enable hm2_[HOSTMOT2](BOARD).0.resolver.02.index-enable <=> axis.2.index-enable
  295.  
  296.  
  297. #net y-index-enable hm2_[HOSTMOT2](BOARD).0.resolver.01.index-enable <=> axis.1.index-enable
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305. # ---setup home / limit switch signals---
  306.  
  307. net x-pos-ot <= hm2_5i23.0.gpio.024.in
  308. net x-pos-ot axis.0.pos-lim-sw-in
  309.  
  310. net x-neg-ot <= hm2_5i23.0.gpio.025.in
  311. net x-neg-ot axis.0.neg-lim-sw-in
  312.  
  313.  
  314.  
  315. net z-pos-ot <= hm2_5i23.0.gpio.026.in
  316. net z-pos-ot axis.2.pos-lim-sw-in
  317.  
  318. net z-neg-ot <= hm2_5i23.0.gpio.027.in
  319. net z-neg-ot axis.2.neg-lim-sw-in
  320.  
  321.  
  322. # Tool Turret Encoder Setup
  323. #Leave cancelled til rest of info is in
  324. net turret-encoder1 wsum.0.bit.0.in <= hm2_5i23.0.gpio.030.in_not
  325. net turret-encoder2 wsum.0.bit.1.in <= hm2_5i23.0.gpio.031.in_not
  326. net turret-encoder4 wsum.0.bit.2.in <= hm2_5i23.0.gpio.032.in_not
  327. net turret-encoder8 wsum.0.bit.3.in <= hm2_5i23.0.gpio.033.in_not
  328.  
  329. # create signals for tool loading loopback In original Mesa file
  330. #net tool-prep-loop iocontrol.0.tool-prepare => iocontrol.0.tool-prepared
  331. #net tool-change-loop iocontrol.0.tool-change => iocontrol.0.tool-changed
  332.  
  333. # Tool Turret tool change, leave the tool prep loop in as there is no prep needed
  334. net tool-prep-loop iocontrol.0.tool-prepare => iocontrol.0.tool-prepared
  335. #net tool-change-loop iocontrol.0.tool-change => iocontrol.0.tool-changed
  336. net tool-cng-req iocontrol.0.tool-change => classicladder.0.in-01
  337. net tool-cn-done iocontrol.0.tool-changed <= classicladder.0.out-01
  338. net tool-number iocontrol.0.tool-number => classicladder.0.s32in-00
  339. net tool-prep-number iocontrol.0.tool-prep-number => classicladder.0.s32in-01
  340. net tur-stop hm2_5i23.0.gpio.046.out <= classicladder.0.out-02
  341. net tur-lift-spin hm2_5i23.0.gpio.047.out <= classicladder.0.out-03
  342. net tur-locked hm2_5i23.0.gpio.034.in => classicladder.0.in-02
  343. net enc-tool-number wsum.0.sum => classicladder.0.s32in-02
  344. net tool-cng-timeout classicladder.0.out-04 => halui.program.stop
  345.  
  346.  
  347.  
  348.  
  349. #######
  350. #Spindle uses resolver.03 and pwmgen.03
  351. #######
  352.  
  353.  
  354. #spindle scales
  355. addf scale.0 servo-thread
  356. addf scale.1 servo-thread
  357.  
  358. #10v/6000rpm=0.001667
  359. #setp scale.0.gain -0.000201 above #/8
  360. #10v/3000rpm=0.003333 Leave as 1/1
  361. setp scale.0.gain 0.000275
  362.  
  363. # offset for spindle next 2 lines were #
  364. #setp scale.0.offset 0.0001loadrt pwmgen output_type=0 # This creates a 1Hz signal
  365.  
  366. setp scale.1.gain 60
  367.  
  368. #load abs comp make spindle RPM pos
  369. loadrt abs count=3
  370. addf abs.0 servo-thread
  371. addf abs.1 servo-thread
  372. addf abs.2 servo-thread
  373.  
  374. #spindle speed out limits
  375. loadrt limit1 count=1
  376. addf limit1.0 servo-thread
  377. setp limit1.0.min -2500
  378. setp limit1.0.max 2500
  379.  
  380. #set scale and pwm
  381. setp hm2_5i23.0.resolver.03.scale 1
  382. setp hm2_[HOSTMOT2](BOARD).0.pwmgen.03.output-type 2
  383.  
  384. net spindle-speed-limit motion.spindle-speed-out => limit1.0.in
  385. net spindle-speed-limit-out limit1.0.out => scale.0.in
  386. net spindle-speed-DAC scale.0.out => hm2_5i23.0.pwmgen.03.value
  387. net spindle-rpm => abs.1.in
  388. net spindle-speed-abs <= abs.1.out
  389.  
  390.  
  391. #Added from andy
  392. net spindle-tryout motion.spindle-on => hm2_5i23.0.pwmgen.03.enable
  393.  
  394. #net spindle-index-enable <=> hm2_5i23.0.resolver.03.index-enable
  395.  
  396.  
  397. #Added for Meter
  398. #net spindle-rpm-filtered => pyvcp.spindle-speed
  399. #net spindle-rpm => pyvcp.spindle-speed
  400. #net spindle-at-speed => pyvcp.spindle-at-speed
  401.  
  402.  
  403. ## Next secions are brake related - DISABLE
  404. #spindle enable Next line cleared
  405. #net spindle-enable-req motion.spindle-on => and2.1.in0
  406. #net spindle-brake-sensor hm2_5i20.0.gpio.051.in_not => and2.1.in1
  407. #net spindle-enable and2.1.out => hm2_5i23.0.pwmgen.03.enable
  408.  
  409. # enable spindle drive
  410. #net spindle-enable => hm2_5i20.0.gpio.065.out
  411. # force spindle lock pin out
  412. #net spindle-enable => hm2_5i20.0.gpio.042.out
  413.  
  414. # release spindle brake
  415. #net spindle-brake-prg not.0.out => or2.2.in0
  416. #net spindle-brake-logic motion.spindle-brake => not.0.in
  417. #net spindle-brake hm2_5i20.0.gpio.040.out <= or2.2.out
  418. ## End of disabled area
  419.  
  420. #spindle sync
  421. net spindle-index motion.spindle-index-enable <= hm2_5i23.0.resolver.03.index-enable
  422. net spindle-velocity motion.spindle-speed-in <= hm2_5i23.0.resolver.03.velocity
  423. net spindle-revs motion.spindle-revs <= hm2_5i23.0.resolver.03.position
  424.  
  425. net spindle-velocity => abs.0.in
  426. net spindle-v-abs abs.0.out => scale.1.in
  427. net spindle-v-abs-out <= scale.1.out
  428.  
  429. # spindle speed
  430. net spindle-velocity mult2.0.in0
  431. setp mult2.0.in1 60
  432. net spindle-abs abs.2.in mult2.0.out
  433. net spindle-rpm abs.2.out
  434.  
  435. # spindle at speed
  436. setp near.0.difference 0.15
  437. net spindle-velocity near.0.in1
  438. net com-spindle-vel near.0.in2 <= motion.spindle-speed-out-rps
  439. net spindle-at-speed near.0.out <= motion.spindle-at-speed
  440.  
  441. # trick Axis
  442. net trick-axis motion.spindle-reverse
  443.  
  444. #Added Stuff
  445. #net spindle-index-enable <=> motion.spindle-index-enable -error-already linked
  446.  
  447.  
  448. #######
  449. #end of spindle
  450. ######
  451.  
  452. # Coolant Pump
  453. net coolant-pump hm2_5i23.0.gpio.064.out <= iocontrol.0.coolant-flood
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement