Advertisement
AGR12

AGR Hal File

Jul 9th, 2015
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.21 KB | None | 0 0
  1. # kinematics
  2. loadrt trivkins
  3.  
  4. # motion controller, get name and thread periods from ini file
  5. loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[TRAJ]AXES
  6.  
  7. # standard components
  8. loadrt pid num_chan=5
  9. loadrt abs
  10. addf abs.0 servo-thread
  11. loadrt scale
  12. addf scale.0 servo-thread
  13.  
  14. # hostmot2 driver
  15. loadrt hostmot2
  16.  
  17. # load low-level drivers
  18. loadrt hm2_pci config="firmware=hm2/5i20/SVST8_4.BIT num_encoders=4 num_pwmgens=4 num_stepgens=0,firmware=hm2/5i20/SVST8_4.BIT num_encoders=4 num_pwmgens=4 num_stepgens=0"
  19. loadrt classicladder_rt numRungs=200 numBits=200 numWords=20 numTimersIec=40 numMonostables=2 numPhysInputs=30 numPhysOutputs=30 numArithmExpr=100 numCounters=10 numSections=1
  20. loadusr -w classicladder --nogui bostomatic.clp
  21.  
  22. # 7i33 on board0 P2
  23. setp hm2_5i20.0.pwmgen.00.output-type 3
  24. setp hm2_5i20.0.pwmgen.01.output-type 3
  25. setp hm2_5i20.0.pwmgen.02.output-type 3
  26. setp hm2_5i20.0.pwmgen.03.output-type 3
  27. setp hm2_5i20.0.pwmgen.pdm_frequency 6000000
  28.  
  29. # 7i33 on board1 P2
  30. setp hm2_5i20.1.pwmgen.00.output-type 3
  31. setp hm2_5i20.1.pwmgen.01.output-type 3
  32. setp hm2_5i20.1.pwmgen.02.output-type 3
  33. setp hm2_5i20.1.pwmgen.03.output-type 3
  34. setp hm2_5i20.1.pwmgen.pdm_frequency 6000000
  35.  
  36.  
  37. # make outputs for the 7i37 on board0 P3
  38. # INs are 024 through 039
  39. # OUTs are 040 through 047
  40. setp hm2_5i20.0.gpio.040.is_output 1
  41. setp hm2_5i20.0.gpio.041.is_output 1
  42. setp hm2_5i20.0.gpio.042.is_output 1
  43. setp hm2_5i20.0.gpio.043.is_output 1
  44. setp hm2_5i20.0.gpio.044.is_output 1
  45. setp hm2_5i20.0.gpio.045.is_output 1
  46. setp hm2_5i20.0.gpio.046.is_output 1
  47. setp hm2_5i20.0.gpio.047.is_output 1
  48. setp hm2_5i20.0.gpio.040.invert_output 1
  49. setp hm2_5i20.0.gpio.041.invert_output 1
  50. setp hm2_5i20.0.gpio.042.invert_output 1
  51. setp hm2_5i20.0.gpio.043.invert_output 1
  52. setp hm2_5i20.0.gpio.044.invert_output 1
  53. setp hm2_5i20.0.gpio.045.invert_output 1
  54. setp hm2_5i20.0.gpio.046.invert_output 1
  55. setp hm2_5i20.0.gpio.047.invert_output 1
  56.  
  57. # make outputs for the 7i37 on board1 P3
  58. # INs are 024 through 039
  59. # OUTs are 040 through 047
  60. setp hm2_5i20.1.gpio.040.is_output 1
  61. setp hm2_5i20.1.gpio.041.is_output 1
  62. setp hm2_5i20.1.gpio.042.is_output 1
  63. setp hm2_5i20.1.gpio.043.is_output 1
  64. setp hm2_5i20.1.gpio.044.is_output 1
  65. setp hm2_5i20.1.gpio.045.is_output 1
  66. setp hm2_5i20.1.gpio.046.is_output 1
  67. setp hm2_5i20.1.gpio.047.is_output 1
  68. setp hm2_5i20.1.gpio.040.invert_output 1
  69. setp hm2_5i20.1.gpio.041.invert_output 1
  70. setp hm2_5i20.1.gpio.042.invert_output 1
  71. setp hm2_5i20.1.gpio.043.invert_output 1
  72. setp hm2_5i20.1.gpio.044.invert_output 1
  73. setp hm2_5i20.1.gpio.045.invert_output 1
  74. setp hm2_5i20.1.gpio.046.invert_output 1
  75. setp hm2_5i20.1.gpio.047.invert_output 1
  76.  
  77. # make outputs for the 7i37 on board0 P4
  78. # INs are 048 through 063
  79. # OUTs are 064 through 071
  80. setp hm2_5i20.0.gpio.064.is_output 1
  81. setp hm2_5i20.0.gpio.065.is_output 1
  82. setp hm2_5i20.0.gpio.066.is_output 1
  83. setp hm2_5i20.0.gpio.067.is_output 1
  84. setp hm2_5i20.0.gpio.068.is_output 1
  85. setp hm2_5i20.0.gpio.069.is_output 1
  86. setp hm2_5i20.0.gpio.070.is_output 1
  87. setp hm2_5i20.0.gpio.071.is_output 1
  88. setp hm2_5i20.0.gpio.064.invert_output 1
  89. setp hm2_5i20.0.gpio.065.invert_output 1
  90. setp hm2_5i20.0.gpio.066.invert_output 1
  91. setp hm2_5i20.0.gpio.067.invert_output 1
  92. setp hm2_5i20.0.gpio.068.invert_output 1
  93. setp hm2_5i20.0.gpio.069.invert_output 1
  94. setp hm2_5i20.0.gpio.070.invert_output 1
  95. setp hm2_5i20.0.gpio.071.invert_output 1
  96.  
  97. # make outputs for the 7i37 on board1 P4
  98. # INs are 048 through 063
  99. # OUTs are 064 through 071
  100. setp hm2_5i20.1.gpio.064.is_output 1
  101. setp hm2_5i20.1.gpio.065.is_output 1
  102. setp hm2_5i20.1.gpio.066.is_output 1
  103. setp hm2_5i20.1.gpio.067.is_output 1
  104. setp hm2_5i20.1.gpio.068.is_output 1
  105. setp hm2_5i20.1.gpio.069.is_output 1
  106. setp hm2_5i20.1.gpio.070.is_output 1
  107. setp hm2_5i20.1.gpio.071.is_output 1
  108. setp hm2_5i20.1.gpio.064.invert_output 1
  109. setp hm2_5i20.1.gpio.065.invert_output 1
  110. setp hm2_5i20.1.gpio.066.invert_output 1
  111. setp hm2_5i20.1.gpio.067.invert_output 1
  112. setp hm2_5i20.1.gpio.068.invert_output 1
  113. setp hm2_5i20.1.gpio.069.invert_output 1
  114. setp hm2_5i20.1.gpio.070.invert_output 1
  115. setp hm2_5i20.1.gpio.071.invert_output 1
  116.  
  117. # configure both watchdogs for 10 servo cycles
  118. setp hm2_5i20.0.watchdog.timeout_ns 10000000
  119. setp hm2_5i20.1.watchdog.timeout_ns 10000000
  120.  
  121.  
  122. # ################################################
  123. # THREADS
  124. # ################################################
  125.  
  126. addf hm2_5i20.0.read servo-thread
  127. addf hm2_5i20.1.read servo-thread
  128.  
  129. addf motion-command-handler servo-thread
  130. addf motion-controller servo-thread
  131.  
  132. addf pid.0.do-pid-calcs servo-thread
  133. addf pid.1.do-pid-calcs servo-thread
  134. addf pid.2.do-pid-calcs servo-thread
  135. addf pid.3.do-pid-calcs servo-thread
  136. addf pid.4.do-pid-calcs servo-thread
  137.  
  138. addf classicladder.0.refresh servo-thread
  139. addf hm2_5i20.0.write servo-thread
  140. addf hm2_5i20.1.write servo-thread
  141. addf hm2_5i20.0.pet_watchdog servo-thread
  142. addf hm2_5i20.1.pet_watchdog servo-thread
  143.  
  144. # ################
  145. # X [0] Axis
  146. # ################
  147.  
  148. # axis enable chain
  149. newsig emcmot.00.enable bit
  150. sets emcmot.00.enable FALSE
  151. net emcmot.00.enable => pid.0.enable
  152. net emcmot.00.enable => hm2_5i20.0.pwmgen.00.enable
  153. net emcmot.00.enable => hm2_5i20.0.gpio.045.out
  154. net emcmot.00.enable <= axis.0.amp-enable-out
  155.  
  156.  
  157. # encoder feedback
  158. setp hm2_5i20.0.encoder.00.counter-mode 0
  159. setp hm2_5i20.0.encoder.00.filter 1
  160. setp hm2_5i20.0.encoder.00.index-invert 0
  161. setp hm2_5i20.0.encoder.00.index-mask 0
  162. setp hm2_5i20.0.encoder.00.index-mask-invert 0
  163.  
  164. setp hm2_5i20.0.encoder.00.scale [AXIS_0]INPUT_SCALE
  165. net motor.00.pos-fb hm2_5i20.0.encoder.00.position => pid.0.feedback
  166. net motor.00.pos-fb => axis.0.motor-pos-fb #push copy back to Axis GUI
  167.  
  168. # set PID loop gains from inifile
  169. setp pid.0.Pgain [AXIS_0]P
  170. setp pid.0.Igain [AXIS_0]I
  171. setp pid.0.Dgain [AXIS_0]D
  172. setp pid.0.bias [AXIS_0]BIAS
  173. setp pid.0.FF0 [AXIS_0]FF0
  174. setp pid.0.FF1 [AXIS_0]FF1
  175. setp pid.0.FF2 [AXIS_0]FF2
  176. setp pid.0.deadband [AXIS_0]DEADBAND
  177. setp pid.0.maxoutput [AXIS_0]MAX_OUTPUT
  178.  
  179. # position command signals
  180. setp hm2_5i20.0.pwmgen.00.scale [AXIS_0]OUTPUT_SCALE
  181.  
  182. net emcmot.00.pos-cmd axis.0.motor-pos-cmd => pid.0.command
  183. net motor.00.command pid.0.output => hm2_5i20.0.pwmgen.00.value
  184.  
  185.  
  186. # ################
  187. # Y [1] Axis
  188. # ################
  189.  
  190. # axis enable chain
  191. newsig emcmot.01.enable bit
  192. sets emcmot.01.enable FALSE
  193. net emcmot.01.enable => pid.1.enable
  194. net emcmot.01.enable => hm2_5i20.0.pwmgen.01.enable
  195. net emcmot.01.enable <= axis.1.amp-enable-out
  196.  
  197. # encoder feedback
  198. setp hm2_5i20.0.encoder.01.counter-mode 0
  199. setp hm2_5i20.0.encoder.01.filter 1
  200. setp hm2_5i20.0.encoder.01.index-invert 0
  201. setp hm2_5i20.0.encoder.01.index-mask 0
  202. setp hm2_5i20.0.encoder.01.index-mask-invert 0
  203.  
  204. setp hm2_5i20.0.encoder.01.scale [AXIS_1]INPUT_SCALE
  205. net motor.01.pos-fb hm2_5i20.0.encoder.01.position => pid.1.feedback
  206. net motor.01.pos-fb => axis.1.motor-pos-fb #push copy back to Axis GUI
  207.  
  208. # set PID loop gains from inifile
  209. setp pid.1.Pgain [AXIS_1]P
  210. setp pid.1.Igain [AXIS_1]I
  211. setp pid.1.Dgain [AXIS_1]D
  212. setp pid.1.bias [AXIS_1]BIAS
  213. setp pid.1.FF0 [AXIS_1]FF0
  214. setp pid.1.FF1 [AXIS_1]FF1
  215. setp pid.1.FF2 [AXIS_1]FF2
  216. setp pid.1.deadband [AXIS_1]DEADBAND
  217. setp pid.1.maxoutput [AXIS_1]MAX_OUTPUT
  218.  
  219. # position command signals
  220. setp hm2_5i20.0.pwmgen.01.scale [AXIS_1]OUTPUT_SCALE
  221.  
  222. net emcmot.01.pos-cmd axis.1.motor-pos-cmd => pid.1.command
  223. net motor.01.command pid.1.output => hm2_5i20.0.pwmgen.01.value
  224.  
  225.  
  226. # ################
  227. # Z [2] Axis
  228. # ################
  229.  
  230. # axis enable chain
  231. newsig emcmot.02.enable bit
  232. sets emcmot.02.enable FALSE
  233. net emcmot.02.enable => pid.2.enable
  234. net emcmot.02.enable => hm2_5i20.0.pwmgen.02.enable
  235. net emcmot.02.enable <= axis.2.amp-enable-out
  236.  
  237. # encoder feedback
  238. setp hm2_5i20.0.encoder.02.counter-mode 0
  239. setp hm2_5i20.0.encoder.02.filter 1
  240. setp hm2_5i20.0.encoder.02.index-invert 0
  241. setp hm2_5i20.0.encoder.02.index-mask 0
  242. setp hm2_5i20.0.encoder.02.index-mask-invert 0
  243.  
  244. setp hm2_5i20.0.encoder.02.scale [AXIS_2]INPUT_SCALE
  245. net motor.02.pos-fb hm2_5i20.0.encoder.02.position => pid.2.feedback
  246. net motor.02.pos-fb => axis.2.motor-pos-fb #push copy back to Axis GUI
  247.  
  248. # set PID loop gains from inifile
  249. setp pid.2.Pgain [AXIS_2]P
  250. setp pid.2.Igain [AXIS_2]I
  251. setp pid.2.Dgain [AXIS_2]D
  252. setp pid.2.bias [AXIS_2]BIAS
  253. setp pid.2.FF0 [AXIS_2]FF0
  254. setp pid.2.FF1 [AXIS_2]FF1
  255. setp pid.2.FF2 [AXIS_2]FF2
  256. setp pid.2.deadband [AXIS_2]DEADBAND
  257. setp pid.2.maxoutput [AXIS_2]MAX_OUTPUT
  258.  
  259. # position command signals
  260. setp hm2_5i20.0.pwmgen.02.scale [AXIS_2]OUTPUT_SCALE
  261.  
  262. net emcmot.02.pos-cmd axis.2.motor-pos-cmd => pid.2.command
  263. net motor.02.command pid.2.output => hm2_5i20.0.pwmgen.02.value
  264.  
  265. # ################
  266. # A [3] Axis
  267. # ################
  268.  
  269. # axis enable chain
  270. newsig emcmot.03.enable bit
  271. sets emcmot.03.enable FALSE
  272. net emcmot.03.enable => pid.3.enable
  273. net emcmot.03.enable => hm2_5i20.0.pwmgen.03.enable
  274. net emcmot.03.enable <= axis.3.amp-enable-out
  275.  
  276. # encoder feedback
  277. setp hm2_5i20.0.encoder.03.counter-mode 0
  278. setp hm2_5i20.0.encoder.03.filter 1
  279. setp hm2_5i20.0.encoder.03.index-invert 0
  280. setp hm2_5i20.0.encoder.03.index-mask 0
  281. setp hm2_5i20.0.encoder.03.index-mask-invert 0
  282.  
  283. setp hm2_5i20.0.encoder.03.scale [AXIS_3]INPUT_SCALE
  284. net motor.03.pos-fb hm2_5i20.0.encoder.03.position => pid.3.feedback
  285. net motor.03.pos-fb => axis.3.motor-pos-fb #push copy back to Axis GUI
  286.  
  287. # set PID loop gains from inifile
  288. setp pid.3.Pgain [AXIS_3]P
  289. setp pid.3.Igain [AXIS_3]I
  290. setp pid.3.Dgain [AXIS_3]D
  291. setp pid.3.bias [AXIS_3]BIAS
  292. setp pid.3.FF0 [AXIS_3]FF0
  293. setp pid.3.FF1 [AXIS_3]FF1
  294. setp pid.3.FF2 [AXIS_3]FF2
  295. setp pid.3.deadband [AXIS_3]DEADBAND
  296. setp pid.3.maxoutput [AXIS_3]MAX_OUTPUT
  297.  
  298. # position command signals
  299. setp hm2_5i20.0.pwmgen.03.scale [AXIS_3]OUTPUT_SCALE
  300.  
  301. net emcmot.03.pos-cmd axis.3.motor-pos-cmd => pid.3.command
  302. net motor.03.command pid.3.output => hm2_5i20.0.pwmgen.03.value
  303.  
  304. # ################
  305. # B [4] Axis
  306. # ################
  307.  
  308. # axis enable chain
  309. newsig emcmot.04.enable bit
  310. sets emcmot.04.enable FALSE
  311. net emcmot.04.enable => pid.4.enable
  312. net emcmot.04.enable => hm2_5i20.1.pwmgen.00.enable
  313. net emcmot.04.enable <= axis.4.amp-enable-out
  314.  
  315. # encoder feedback
  316. setp hm2_5i20.1.encoder.00.counter-mode 0
  317. setp hm2_5i20.1.encoder.00.filter 1
  318. setp hm2_5i20.1.encoder.00.index-invert 0
  319. setp hm2_5i20.1.encoder.00.index-mask 0
  320. setp hm2_5i20.1.encoder.00.index-mask-invert 0
  321.  
  322. setp hm2_5i20.1.encoder.00.scale [AXIS_4]INPUT_SCALE
  323. net motor.04.pos-fb hm2_5i20.1.encoder.00.position => pid.4.feedback
  324. net motor.04.pos-fb => axis.4.motor-pos-fb #push copy back to Axis GUI
  325.  
  326. # set PID loop gains from inifile
  327. setp pid.4.Pgain [AXIS_4]P
  328. setp pid.4.Igain [AXIS_4]I
  329. setp pid.4.Dgain [AXIS_4]D
  330. setp pid.4.bias [AXIS_4]BIAS
  331. setp pid.4.FF0 [AXIS_4]FF0
  332. setp pid.4.FF1 [AXIS_4]FF1
  333. setp pid.4.FF2 [AXIS_4]FF2
  334. setp pid.4.deadband [AXIS_4]DEADBAND
  335. setp pid.4.maxoutput [AXIS_4]MAX_OUTPUT
  336.  
  337. # position command signals
  338. setp hm2_5i20.1.pwmgen.00.scale [AXIS_4]OUTPUT_SCALE
  339.  
  340. net emcmot.04.pos-cmd axis.4.motor-pos-cmd => pid.4.command
  341. net motor.04.command pid.4.output => hm2_5i20.1.pwmgen.00.value
  342.  
  343. # dummy axis loopback
  344. net Wloop axis.8.motor-pos-cmd axis.8.motor-pos-fb
  345.  
  346. # this kind of machine does not do a prep, since it has to put
  347. # the old tool away before moving the carousel. so just loop it
  348. # back...
  349. net tool-prep-loop iocontrol.0.tool-prepare => iocontrol.0.tool-prepared
  350.  
  351. # only the Y servo has an index, X and Z home without using the index
  352. net Xindex hm2_5i20.0.encoder.00.index-enable <=> axis.0.index-enable
  353. net Yindex hm2_5i20.0.encoder.01.index-enable <=> axis.1.index-enable
  354. net Zindex hm2_5i20.0.encoder.02.index-enable <=> axis.2.index-enable
  355. net Aindex hm2_5i20.0.encoder.03.index-enable <=> axis.3.index-enable
  356. net Bindex hm2_5i20.1.encoder.00.index-enable <=> axis.4.index-enable
  357.  
  358. net Xlimits hm2_5i20.0.gpio.029.in => axis.0.neg-lim-sw-in axis.0.pos-lim-sw-in
  359. net Ylimits hm2_5i20.0.gpio.030.in => axis.1.neg-lim-sw-in axis.1.pos-lim-sw-in
  360. net Zlimits hm2_5i20.0.gpio.031.in => axis.2.neg-lim-sw-in axis.2.pos-lim-sw-in
  361. # no Alimits
  362. net Blimits hm2_5i20.1.gpio.032.in => axis.4.neg-lim-sw-in axis.4.pos-lim-sw-in
  363.  
  364. net Xhome hm2_5i20.0.gpio.024.in => axis.0.home-sw-in
  365. net Yhome hm2_5i20.0.gpio.025.in => axis.1.home-sw-in
  366. net Zhome hm2_5i20.0.gpio.026.in => axis.2.home-sw-in
  367. net Ahome hm2_5i20.0.gpio.027.in_not => axis.3.home-sw-in
  368. net Bhome hm2_5i20.0.gpio.028.in => axis.4.home-sw-in
  369.  
  370. net EstopSense hm2_5i20.0.gpio.039.in_not => iocontrol.0.emc-enable-in
  371. net EstopWrite iocontrol.0.user-enable-out => hm2_5i20.0.gpio.047.out
  372.  
  373. # Spindle Direction
  374. net spindle-fwd motion.spindle-forward => hm2_5i20.0.gpio.041.out
  375. net spindle-rev motion.spindle-reverse => hm2_5i20.0.gpio.040.out
  376.  
  377. # Speed Scale Control (0-10v Spindle Speed)
  378. loadrt scale count=1
  379. addf scale.0 servo-thread
  380.  
  381. # 10volts / 7,000 RPM's at the Spindle = .00142857)
  382. setp scale.0.gain 0.00142857
  383.  
  384. net spindle-rpm-cmd motion.spindle-speed-out => abs.0.in
  385. net spindle-rpm-abs abs.0.out => hm2_5i20.1.pwmgen.01.value
  386.  
  387. # Spindle Enable
  388. net emcmot.01.enable hm2_5i20.1.pwmgen.01.enable
  389. net spindle-enable emcmot.01.enable
  390.  
  391. net FloodOn iocontrol.0.coolant-flood => hm2_5i20.0.gpio.046.out
  392. net LubeOn iocontrol.0.lube => hm2_5i20.1.gpio.046.out
  393. net HydOn => hm2_5i20.0.gpio.043.out
  394.  
  395. net PotCycleA hm2_5i20.1.gpio.031.in_not => classicladder.0.in-00
  396. net PotCycleB hm2_5i20.1.gpio.033.in_not => classicladder.0.in-01
  397. net ToolInSpindle hm2_5i20.1.gpio.027.in => classicladder.0.in-02
  398. net ArmIsIn hm2_5i20.0.gpio.035.in_not => classicladder.0.in-03
  399. net ArmIsOut hm2_5i20.0.gpio.037.in_not => classicladder.0.in-04
  400. # Z axis extra position proxes will not be needed anymore
  401. net ToolIndex hm2_5i20.0.gpio.033.in_not => classicladder.0.in-07
  402.  
  403. net ToolChangeStart iocontrol.0.tool-change => classicladder.0.in-08
  404. # and then when it's done ladder tells iocontrol...
  405. # net ToolChangeDone classicladder.0.out-XXX iocontrol.0.tool-changed
  406. net ToolRequested iocontrol.0.tool-prep-number classicladder.0.s32in-00
  407.  
  408. net IndexFor classicladder.0.out-00 => hm2_5i20.1.gpio.041.out
  409. net IndexRev classicladder.0.out-01 => hm2_5i20.1.gpio.043.out
  410.  
  411. net MoveArmIn classicladder.0.out-06 => hm2_5i20.0.gpio.044.out
  412. net ToolRelease classicladder.0.out-08 => hm2_5i20.0.gpio.042.out # was ManTC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement