Advertisement
Guest User

Untitled

a guest
Jul 24th, 2012
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.95 KB | None | 0 0
  1. From 5cbd73249659afd91e8c1609690d181eb0daa0f4 Mon Sep 17 00:00:00 2001
  2. From: John Thornton <[email protected]>
  3. Date: Tue, 24 Jul 2012 13:55:26 -0500
  4. Subject: [PATCH] fix lathe simulated spindle not reaching commanded speed
  5.  
  6. some can run 2500 some only 800 until the speed number goes negative
  7. and simulated rpm stalls.
  8.  
  9. requires cherry picking sim_spindle.comp from master
  10. ---
  11. configs/sim/lathe.hal | 79 ++++++++++++++++---------------------------------
  12. 1 files changed, 26 insertions(+), 53 deletions(-)
  13.  
  14. diff --git a/configs/sim/lathe.hal b/configs/sim/lathe.hal
  15. index 2a2632c..cd5a9f8 100644
  16. --- a/configs/sim/lathe.hal
  17. +++ b/configs/sim/lathe.hal
  18. @@ -1,69 +1,42 @@
  19. -# counting the spindle encoder in software
  20. -loadrt encoder num_chan=1
  21. -# simulate the encoder
  22. -loadrt sim_encoder num_chan=1
  23. -loadrt limit2 count=1
  24. +# simulated spindle encoder (for spindle-synced moves)
  25. +loadrt sim_spindle count=1
  26. +setp sim-spindle.0.scale 0.01666667
  27.  
  28. -addf limit2.0 servo-thread
  29. -
  30. -#######################################################
  31. -# Beginning of threading related stuff
  32. -#######################################################
  33. -
  34. -# spindle speed control
  35. -net spindle-speed-cmd motion.spindle-speed-out => limit2.0.in
  36. -net spindle-speed-limited limit2.0.out => sim-encoder.0.speed
  37. -
  38. -# simulate spindle mass
  39. -setp limit2.0.maxv 500.0 # rpm/second
  40. +loadrt limit2 count=1
  41. +loadrt lowpass count=1
  42. +loadrt near
  43. +loadrt abs names=spindle-abs
  44.  
  45. -# spindle encoder
  46. -# connect encoder signals to encoder counter
  47. -net spindle-phase-A sim-encoder.0.phase-A => encoder.0.phase-A
  48. -net spindle-phase-B sim-encoder.0.phase-B => encoder.0.phase-B
  49. -net spindle-phase-Z sim-encoder.0.phase-Z => encoder.0.phase-Z
  50. +addf limit2.0 servo-thread
  51. +addf lowpass.0 servo-thread
  52. +addf near.0 servo-thread
  53. +addf sim-spindle.0 servo-thread
  54. +addf spindle-abs servo-thread
  55.  
  56. -# assume 120 ppr = 480 counts/rev for the spindle
  57. -setp sim-encoder.0.ppr 120
  58. -# iocontrol output is in rpm, but sim-encoder speed is rps
  59. -setp sim-encoder.0.scale 60
  60. -# scale encoder output to read in revolutions
  61. -# (that way thread pitches can be straightforward,
  62. -# a 20 tpi thread would multiply the encoder output
  63. -# by 1/20, etc)
  64. -setp encoder.0.position-scale 480
  65. +# spindle max velocity rpm/second
  66. +setp limit2.0.maxv 1500.0
  67.  
  68. # encoder reset control
  69. # hook up motion controller's sync output
  70. -net spindle-index-enable motion.spindle-index-enable <=> encoder.0.index-enable
  71. +net spindle-index-enable motion.spindle-index-enable <=> sim-spindle.0.index-enable
  72.  
  73. # report our revolution count to the motion controller
  74. -net spindle-pos encoder.0.position => motion.spindle-revs
  75. +net spindle-pos sim-spindle.0.position-fb => motion.spindle-revs
  76.  
  77. -# for spindle velocity estimate
  78. -loadrt lowpass count=1
  79. -loadrt scale count=1
  80. -net spindle-rps-raw encoder.0.velocity lowpass.0.in
  81. -net spindle-rps-filtered lowpass.0.out scale.0.in motion.spindle-speed-in
  82. -net spindle-rpm-filtered scale.0.out
  83. -setp scale.0.gain 60
  84. +# simulate spindle mass
  85. setp lowpass.0.gain .07
  86. -addf lowpass.0 servo-thread
  87. -addf scale.0 servo-thread
  88.  
  89. -# for at-speed detection
  90. -loadrt near
  91. -addf near.0 servo-thread
  92. +# spindle speed control
  93. +net spindle-speed-cmd motion.spindle-speed-out => limit2.0.in
  94. +net spindle-speed-limited limit2.0.out => sim-spindle.0.velocity-cmd lowpass.0.in
  95. +
  96. +# for spindle velocity estimate
  97. +net spindle-rpm-filtered lowpass.0.out motion.spindle-speed-in near.0.in2 spindle-abs.in
  98. +
  99. +# at-speed detection
  100. setp near.0.scale 1.1
  101. setp near.0.difference 10
  102. +
  103. net spindle-speed-cmd => near.0.in1
  104. -net spindle-rpm-filtered => near.0.in2
  105. net spindle-at-speed near.0.out motion.spindle-at-speed
  106.  
  107. -net spindle-fwd <= motion.spindle-forward
  108. -
  109. -addf encoder.capture-position servo-thread
  110. -addf sim-encoder.update-speed servo-thread
  111. -
  112. -addf sim-encoder.make-pulses base-thread
  113. -addf encoder.update-counters base-thread
  114. --
  115. 1.7.0.4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement