Advertisement
cncbasher

mpg-xyz

Oct 30th, 2012
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.10 KB | None | 0 0
  1.  
  2. # mpg x with ilowpass filtering
  3. # mpg-xyz.hal
  4. # add this line to postgui_call_list.hal
  5. # ' source mpg-xyz.hal '
  6.  
  7. # modify ini file to add .0 show the following lines in hostmot2
  8. # DRIVER0 = hm2_xxxx.0
  9. # BOARD0 = xxxx.0
  10.  
  11.  
  12. loadrt encoder num_chan=3
  13. loadrt mux4 count=3
  14. addf encoder.capture-position servo-thread
  15. addf encoder.update-counters base-thread
  16.  
  17. addf mux4.0 servo-thread
  18. addf mux4.1 servo-thread
  19. addf mux4.2 servo-thread
  20.  
  21. loadrt ilowpass
  22. #x-axis
  23. addf ilowpass.0 servo-thread
  24. setp ilowpass.0.scale 1000
  25. setp ilowpass.0.gain 0.01
  26.  
  27. #y-axis
  28. addf ilowpass.1 servo-thread
  29. setp ilowpass.1.scale 1000
  30. setp ilowpass.1.gain 0.01
  31.  
  32. #z-axis
  33. addf ilowpass.2 servo-thread
  34. setp ilowpass.2.scale 1000
  35. setp ilowpass.2.gain 0.01
  36.  
  37.  
  38. # If your MPG outputs a quadrature signal per click set x4 to 1
  39. # If your MPG puts out 1 pulse per click set x4 to 0
  40. setp encoder.0.x4-mode 0
  41. setp encoder.1.x4-mode 0
  42. setp encoder.2.x4-mode 0
  43.  
  44. # For velocity mode, set to 1
  45. # In velocity mode the axis stops when the dial is stopped
  46. # even if that means the commanded motion is not completed,
  47. # For position mode (the default), set to 0
  48. # In position mode the axis will move exactly jog-scale
  49. # units for each count, regardless of how long that might take,
  50. setp axis.0.jog-vel-mode 0
  51. setp axis.1.jog-vel-mode 0
  52. setp axis.2.jog-vel-mode 0
  53.  
  54. # the inputs to the mux4 component
  55. net scale1 mux4.0.sel0 <= hm2_7i43.0.gpio.014.in_not # change to select scale0 input select pin 0
  56. net scale2 mux4.0.sel1 <= hm2_7i43.0.gpio.014.in_not # change to select scale0 input select pin 1
  57.  
  58. net scale3 mux4.1.sel0 <= hm2_7i43.0.gpio.014.in_not # change to select scale1 input select pin 0
  59. net scale4 mux4.1.sel1 <= hm2_7i43.0.gpio.014.in_not # change to select scale1 input select pin 1
  60.  
  61. net scale5 mux4.2.sel0 <= hm2_7i43.0.gpio.014.in_not # change to select scale2 input select pin 0
  62. net scale6 mux4.2.sel1 <= hm2_7i43.0.gpio.014.in_not # change to select scale2 input select pin 1
  63.  
  64. # this sets the scale that will be used based on the input to the mux4
  65. # the scale used here has to be multiplied by the ilowpass scale
  66. setp mux4.0.in0 0.0001
  67. setp mux4.0.in1 0.00001
  68. setp mux4.0.in2 0.000001
  69.  
  70. setp mux4.1.in0 0.0001
  71. setp mux4.1.in1 0.00001
  72. setp mux4.1.in2 0.000001
  73.  
  74. setp mux4.2.in0 0.0001
  75. setp mux4.2.in1 0.00001
  76. setp mux4.2.in2 0.000001
  77.  
  78. # send encoder counts to ilowpass
  79. net mpg-out-x ilowpass.0.in <= encoder.0.counts
  80. net mpg-out-y ilowpass.1.in <= encoder.1.counts
  81. net mpg-out-z ilowpass.2.in <= encoder.2.counts
  82.  
  83. # the output from the ilowpass is sent to each axis jog scale
  84. net mpg-scale-x <= ilowpass0.out
  85. net mpg-scale-y <= ilowpass1.out
  86. net mpg-scale-z <= ilowpass2.out
  87.  
  88. net mpg-scale => axis.0.jog-scale
  89. net mpg-scale => axis.1.jog-scale
  90. net mpg-scale => axis.2.jog-scale
  91.  
  92. # the encoder output counts to the axis. Only the selected axis will move.
  93. net encoder-counts-x <= encoder.0.counts
  94. net encoder-counts-y <= encoder.1.counts
  95. net encoder-counts-z <= encoder.2.counts
  96.  
  97. net encoder-counts-x => axis.0.jog-counts
  98. net encoder-counts-y => axis.1.jog-counts
  99. net encoder-counts-z => axis.2.jog-counts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement