Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From 5cbd73249659afd91e8c1609690d181eb0daa0f4 Mon Sep 17 00:00:00 2001
- From: John Thornton <[email protected]>
- Date: Tue, 24 Jul 2012 13:55:26 -0500
- Subject: [PATCH] fix lathe simulated spindle not reaching commanded speed
- some can run 2500 some only 800 until the speed number goes negative
- and simulated rpm stalls.
- requires cherry picking sim_spindle.comp from master
- ---
- configs/sim/lathe.hal | 79 ++++++++++++++++---------------------------------
- 1 files changed, 26 insertions(+), 53 deletions(-)
- diff --git a/configs/sim/lathe.hal b/configs/sim/lathe.hal
- index 2a2632c..cd5a9f8 100644
- --- a/configs/sim/lathe.hal
- +++ b/configs/sim/lathe.hal
- @@ -1,69 +1,42 @@
- -# counting the spindle encoder in software
- -loadrt encoder num_chan=1
- -# simulate the encoder
- -loadrt sim_encoder num_chan=1
- -loadrt limit2 count=1
- +# simulated spindle encoder (for spindle-synced moves)
- +loadrt sim_spindle count=1
- +setp sim-spindle.0.scale 0.01666667
- -addf limit2.0 servo-thread
- -
- -#######################################################
- -# Beginning of threading related stuff
- -#######################################################
- -
- -# spindle speed control
- -net spindle-speed-cmd motion.spindle-speed-out => limit2.0.in
- -net spindle-speed-limited limit2.0.out => sim-encoder.0.speed
- -
- -# simulate spindle mass
- -setp limit2.0.maxv 500.0 # rpm/second
- +loadrt limit2 count=1
- +loadrt lowpass count=1
- +loadrt near
- +loadrt abs names=spindle-abs
- -# spindle encoder
- -# connect encoder signals to encoder counter
- -net spindle-phase-A sim-encoder.0.phase-A => encoder.0.phase-A
- -net spindle-phase-B sim-encoder.0.phase-B => encoder.0.phase-B
- -net spindle-phase-Z sim-encoder.0.phase-Z => encoder.0.phase-Z
- +addf limit2.0 servo-thread
- +addf lowpass.0 servo-thread
- +addf near.0 servo-thread
- +addf sim-spindle.0 servo-thread
- +addf spindle-abs servo-thread
- -# assume 120 ppr = 480 counts/rev for the spindle
- -setp sim-encoder.0.ppr 120
- -# iocontrol output is in rpm, but sim-encoder speed is rps
- -setp sim-encoder.0.scale 60
- -# scale encoder output to read in revolutions
- -# (that way thread pitches can be straightforward,
- -# a 20 tpi thread would multiply the encoder output
- -# by 1/20, etc)
- -setp encoder.0.position-scale 480
- +# spindle max velocity rpm/second
- +setp limit2.0.maxv 1500.0
- # encoder reset control
- # hook up motion controller's sync output
- -net spindle-index-enable motion.spindle-index-enable <=> encoder.0.index-enable
- +net spindle-index-enable motion.spindle-index-enable <=> sim-spindle.0.index-enable
- # report our revolution count to the motion controller
- -net spindle-pos encoder.0.position => motion.spindle-revs
- +net spindle-pos sim-spindle.0.position-fb => motion.spindle-revs
- -# for spindle velocity estimate
- -loadrt lowpass count=1
- -loadrt scale count=1
- -net spindle-rps-raw encoder.0.velocity lowpass.0.in
- -net spindle-rps-filtered lowpass.0.out scale.0.in motion.spindle-speed-in
- -net spindle-rpm-filtered scale.0.out
- -setp scale.0.gain 60
- +# simulate spindle mass
- setp lowpass.0.gain .07
- -addf lowpass.0 servo-thread
- -addf scale.0 servo-thread
- -# for at-speed detection
- -loadrt near
- -addf near.0 servo-thread
- +# spindle speed control
- +net spindle-speed-cmd motion.spindle-speed-out => limit2.0.in
- +net spindle-speed-limited limit2.0.out => sim-spindle.0.velocity-cmd lowpass.0.in
- +
- +# for spindle velocity estimate
- +net spindle-rpm-filtered lowpass.0.out motion.spindle-speed-in near.0.in2 spindle-abs.in
- +
- +# at-speed detection
- setp near.0.scale 1.1
- setp near.0.difference 10
- +
- net spindle-speed-cmd => near.0.in1
- -net spindle-rpm-filtered => near.0.in2
- net spindle-at-speed near.0.out motion.spindle-at-speed
- -net spindle-fwd <= motion.spindle-forward
- -
- -addf encoder.capture-position servo-thread
- -addf sim-encoder.update-speed servo-thread
- -
- -addf sim-encoder.make-pulses base-thread
- -addf encoder.update-counters base-thread
- --
- 1.7.0.4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement