Advertisement
Guest User

Untitled

a guest
Mar 13th, 2015
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.46 KB | None | 0 0
  1. ----
  2. # add the encoder to HAL and attach it to threads.
  3. loadrt encoder num_chan=1
  4. addf encoder.update-counters base-thread
  5. addf encoder.capture-position servo-thread
  6.  
  7. # set the HAL encoder to 100 pulses per revolution.
  8. setp encoder.3.position-scale 100
  9.  
  10. # set the HAL encoder to non-quadrature simple counting using A only.
  11. setp encoder.3.counter-mode true
  12.  
  13. # connect the HAL encoder outputs to LinuxCNC.
  14. net spindle-position encoder.3.position => motion.spindle-revs
  15. net spindle-velocity encoder.3.velocity => motion.spindle-speed-in
  16. net spindle-index-enable encoder.3.index-enable <=> motion.spindle-index-enable
  17.  
  18. # connect the HAL encoder inputs to the real encoder.
  19. net spindle-phase-a encoder.3.phase-A <= parport.0.pin-10-in
  20. net spindle-phase-b encoder.3.phase-B
  21. net spindle-index encoder.3.phase-Z <= parport.0.pin-11-in
  22. ----
  23.  
  24. === Spindle At Speed[[sec:Spindle-At-Speed]]
  25.  
  26. (((Spindle At Speed)))
  27.  
  28. To enable LinuxCNC to wait for the spindle to be at speed before executing
  29. a series of moves you need to set motion.spindle-at-speed to true when
  30. the spindle is at the commanded speed. To do this you need spindle
  31. feedback from an encoder. Since the feedback and the commanded speed
  32. are not usually 'exactly' the same you need to use the 'near'
  33. component to say that the two numbers are close enough.
  34.  
  35. The connections needed are from the spindle
  36. velocity command signal to near.n.in1 and from the spindle velocity
  37. from the encoder to near.n.in2. Then the near.n.out is connected to
  38. motion.spindle-at-speed. The near.n.scale needs to be set to say how
  39. close the two numbers must be before turning on the output. Depending
  40. on your setup you may need to adjust the scale to work with your
  41. hardware.
  42.  
  43. The following is typical of the additions needed to your HAL
  44. file to enable Spindle At Speed. If you already have near in your HAL
  45. file then increase the count and adjust code to suit. Check to make
  46. sure the signal names are the same in your HAL file.
  47.  
  48. ----
  49. # load a near component and attach it to a thread
  50. loadrt near
  51. addf near.0 servo-thread
  52.  
  53. # connect one input to the commanded spindle speed
  54. net spindle-cmd => near.0.in1
  55.  
  56. # connect one input to the encoder-measured spindle speed
  57. net spindle-velocity => near.0.in2
  58.  
  59. # connect the output to the spindle-at-speed input
  60. net spindle-at-speed motion.spindle-at-speed <= near.0.out
  61.  
  62. # set the spindle speed inputs to agree if within 1%
  63. setp near.0.scale 1.01
  64. ----
  65.  
  66. === Spindle Orient[[sec:Spindle-Orient]]
  67.  
  68. (((Spindle Orient)))
  69.  
  70. LinuxCNC G-code offers the M19 command to perform spindle orientation moves.
  71. For this to work there needs to be a PID-controller to operate the spindle in
  72. a fashion much like a servo. This means that the spindle must be able to
  73. rotate in both directions under software control and there needs to be spindle
  74. feedback from an encoder (or similar).
  75. As the spindle encoder counter will typically have counted many thousands of
  76. rotations at the point when a spindle orient command is required it is not
  77. possible to simply request a 0 to 360 degree angle. Instead one should use the
  78. "orient" HAL component which creates a new position setpoint based on the
  79. current spindle completed revs + the required angle.
  80. The HAL configuration diagrammed below shows two PID controllers, one active
  81. when the spindle is on to close the velocity loop, and the other active when
  82. the spindle is in orient mode to close the position loop.
  83.  
  84. image::images/orient.svg[align="center"]
  85.  
  86. ----
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement