Advertisement
Guest User

Untitled

a guest
Feb 19th, 2013
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.15 KB | None | 0 0
  1. # configuration for 3-axis gantry router with tandem motors on the y-axis
  2. # also has Logitech F310 Gamepad as a jog pendant
  3.  
  4.  
  5. loadrt trivkins
  6. loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EMCMOT]SERVO_PERIOD traj_period_nsec=[EMCMOT]SERVO_PERIOD key=[EMCMOT]SHMEM_KEY num_joints=[TRAJ]AXES
  7. loadrt probe_parport
  8. loadrt hal_parport cfg=0x378
  9. setp parport.0.reset-time 5000
  10. loadrt stepgen step_type=0,0,0
  11. # loadrt threads fp1=0 name1=fast period1=50000 name2=slow period2=1000000
  12.  
  13. # load the Gamepad Pro module
  14. loadusr -W hal_input -KRAL X-Box
  15.  
  16. # load the module for the tandem motor logic
  17. loadrt and2 count=5
  18. loadrt or2 count=5
  19. loadrt not count=6
  20. loadrt mux4 count=1
  21. loadrt debounce cfg=2,3
  22.  
  23. # add the module to the necessary threads
  24. addf and2.0 base-thread
  25. addf and2.1 base-thread
  26. addf and2.2 base-thread
  27. addf and2.3 base-thread
  28. addf and2.4 base-thread
  29. addf or2.0 base-thread
  30. addf or2.1 base-thread
  31. addf or2.2 base-thread
  32. addf not.0 base-thread
  33. addf not.1 base-thread
  34. addf not.2 base-thread
  35. addf not.3 base-thread
  36. addf not.4 base-thread
  37. addf debounce.0 base-thread
  38. addf debounce.1 base-thread
  39.  
  40. addf parport.0.read base-thread
  41. addf stepgen.make-pulses base-thread
  42. addf parport.0.write base-thread
  43. addf parport.0.reset base-thread
  44.  
  45. addf stepgen.capture-position servo-thread
  46. addf motion-command-handler servo-thread
  47. addf motion-controller servo-thread
  48. addf stepgen.update-freq servo-thread
  49.  
  50.  
  51. # set up the axis parameters and create the axis signals
  52.  
  53. # x-axis
  54. setp stepgen.0.position-scale [AXIS_0]SCALE
  55. setp stepgen.0.steplen 1
  56. setp stepgen.0.stepspace 1
  57. setp stepgen.0.dirhold 35000
  58. setp stepgen.0.dirsetup 35000
  59. setp stepgen.0.maxaccel [AXIS_0]STEPGEN_MAXACCEL
  60. net xpos-cmd axis.0.motor-pos-cmd => stepgen.0.position-cmd
  61. net xpos-fb stepgen.0.position-fb => axis.0.motor-pos-fb
  62. net xstep <= stepgen.0.step
  63. net xdir <= stepgen.0.dir
  64. net xenable axis.0.amp-enable-out => stepgen.0.enable
  65.  
  66. # y-axis
  67. setp stepgen.1.position-scale [AXIS_1]SCALE
  68. setp stepgen.1.steplen 1
  69. setp stepgen.1.stepspace 1
  70. setp stepgen.1.dirhold 35000
  71. setp stepgen.1.dirsetup 35000
  72. setp stepgen.1.maxaccel [AXIS_1]STEPGEN_MAXACCEL
  73. net ypos-cmd axis.1.motor-pos-cmd => stepgen.1.position-cmd
  74. net ypos-fb stepgen.1.position-fb => axis.1.motor-pos-fb
  75. net ystep <= stepgen.1.step
  76. net ydir <= stepgen.1.dir
  77. net yenable axis.1.amp-enable-out => stepgen.1.enable
  78.  
  79. # z-axis
  80. setp stepgen.2.position-scale [AXIS_2]SCALE
  81. setp stepgen.2.steplen 1
  82. setp stepgen.2.stepspace 0
  83. setp stepgen.2.dirhold 35000
  84. setp stepgen.2.dirsetup 35000
  85. setp stepgen.2.maxaccel [AXIS_2]STEPGEN_MAXACCEL
  86. net zpos-cmd axis.2.motor-pos-cmd => stepgen.2.position-cmd
  87. net zpos-fb stepgen.2.position-fb => axis.2.motor-pos-fb
  88. net zstep <= stepgen.2.step
  89. net zdir <= stepgen.2.dir
  90. net zenable axis.2.amp-enable-out => stepgen.2.enable
  91.  
  92.  
  93. # set all of the step signals to reset
  94. #setp parport.0.pin-02-out-reset 1
  95. #setp parport.0.pin-04-out-reset 1
  96. #setp parport.0.pin-06-out-reset 1
  97. #setp parport.0.pin-08-out-reset 1
  98.  
  99. # invert a couple of direction signals
  100. setp parport.0.pin-03-out-invert 1
  101. setp parport.0.pin-05-out-invert 1
  102. setp parport.0.pin-07-out-invert 1
  103. setp parport.0.pin-09-out-invert 1
  104.  
  105. # debounce the y-axis switches and connect them to signals
  106. net switches-y1-raw <= parport.0.pin-11-in
  107. net switches-y1-raw => debounce.0.0.in
  108. net switches-y1 <= debounce.0.0.out
  109. net switches-y2-raw <= parport.0.pin-12-in
  110. net switches-y2-raw => debounce.0.1.in
  111. net switches-y2 <= debounce.0.1.out
  112. setp debounce.0.delay 10
  113.  
  114. # join the home switch signals so that both switches have to be closed to trigger a home position
  115. net switches-y1 => and2.0.in0
  116. net switches-y2 => and2.0.in1
  117. net home-y <= and2.0.out
  118. net home-y => axis.1.home-sw-in
  119.  
  120. # we will need the inverse of the home switch signals for our logic, so run them through not gates
  121. net switches-y1 => not.0.in
  122. net switches-y1-inv <= not.0.out
  123. net switches-y2 => not.1.in
  124. net switches-y2-inv <= not.1.out
  125.  
  126. # we will need the inverse of the direction signals for our logic, so run it through a not gate
  127. net ydir => not.2.in
  128. net ydir-inv => not.2.out
  129.  
  130. # we need to determine if the home switch for each motor is tripped while the direction line is
  131. # moving the motor towards the switch
  132.  
  133. # for both y-axis motors, we will prevent the step signal from passing to the motor
  134. # if the motor is moving towards the switch and the switch is tripped
  135. # so "or" the inverted direction signals and the inverted home switches
  136. net ydir => and2.3.in0
  137. net switches-y1 => and2.3.in1
  138. net doh1 <= and2.3.out
  139. net doh1 => not.3.in
  140. net doh1-inv => not.3.out
  141.  
  142. net ydir => and2.4.in0
  143. net switches-y2 => and2.4.in1
  144. net doh2 <= and2.4.out
  145. net doh2 => not.4.in
  146. net doh2-inv => not.4.out
  147.  
  148. # if the step generator is trying to send a step (ystep signal) and either the motor is moving
  149. # away from the switch or the switch is not tripped, then pass the step signal to the motor
  150. net ystep and2.1.in0
  151. net doh1-inv and2.1.in1
  152. net ystep1 and2.1.out
  153.  
  154. net ystep and2.2.in0
  155. net doh2-inv and2.2.in1
  156. net ystep2 and2.2.out
  157.  
  158. # connect our step and direction signals to the output pins
  159. net xstep => parport.0.pin-02-out
  160. net xdir => parport.0.pin-03-out
  161. net ystep1 => parport.0.pin-04-out
  162. net ystep2 => parport.0.pin-08-out
  163. net ydir => parport.0.pin-05-out
  164. net ydir => parport.0.pin-09-out
  165. net zstep => parport.0.pin-06-out
  166. net zdir => parport.0.pin-07-out
  167.  
  168. # we are using combined home and limit switches
  169. # if either switch trips while the homing sequence is not running, then triggered a negative
  170. # limit switch fault
  171. net switches-y1 => or2.2.in0
  172. net switches-y2 => or2.2.in1
  173. net limit-y <= or2.2.out
  174. net limit-y => axis.1.neg-lim-sw-in
  175. net limit-y => axis.1.pos-lim-sw-in
  176.  
  177.  
  178. # set up the other home and limit switches
  179. net switches-x-raw <= parport.0.pin-10-in
  180. net switches-x-raw => debounce.1.0.in
  181. net switches-x <= debounce.1.0.out
  182. net switches-x => axis.0.home-sw-in
  183. net switches-x => axis.0.neg-lim-sw-in
  184. net switches-x => axis.0.pos-lim-sw-in
  185.  
  186. net switches-z-raw <= parport.0.pin-13-in
  187. net switches-z-raw => debounce.1.1.in
  188. net switches-z <= debounce.1.1.out
  189. net switches-z => axis.2.home-sw-in
  190. net switches-z => axis.2.pos-lim-sw-in
  191.  
  192. setp debounce.1.delay 10
  193.  
  194. # connect the spindle control to the relay pin
  195. net spindle-cw => parport.0.pin-14-out
  196. net spindle-cw <= motion.spindle-forward
  197.  
  198. # connect the shop vac to the flood coolant signal
  199. net flood => iocontrol.0.coolant-flood
  200. net flood => parport.0.pin-16-out
  201.  
  202. # set up the e-stop switch
  203. net estop-raw <= parport.0.pin-15-in-not
  204. net estop-raw => debounce.1.2.in
  205. net estop-ext <= debounce.1.2.out
  206. net estop-ext => iocontrol.0.emc-enable-in
  207.  
  208.  
  209.  
  210. #net estop-out <= iocontrol.0.user-enable-out
  211. #net estop-out => iocontrol.0.emc-enable-in
  212.  
  213. net estop-out <= iocontrol.0.user-enable-out
  214.  
  215.  
  216. loadusr -W hal_manualtoolchange
  217. net tool-change iocontrol.0.tool-change => hal_manualtoolchange.change
  218. net tool-changed iocontrol.0.tool-changed <= hal_manualtoolchange.changed
  219. net tool-number iocontrol.0.tool-prep-number => hal_manualtoolchange.number
  220. net tool-prepare-loopback iocontrol.0.tool-prepare => iocontrol.0.tool-prepared
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement