Bouncing spindle RPM display

More
26 Aug 2018 02:53 #116589 by JohnnyCNC
Help Please! I have spent hours trying to get the RPM display to settle down. I had this working with a reflective sensor and my old spindle motor. I changed my spindle motor to a DYN4 1.8kw servo and changed the index sensor to a slot type sensor. If I connect the sensor to my old DRO tach input it works perfectly. RPM varies by 2 or 3 RPM. I also checked the RPM with a Biddle mechanical tach and it matches the DRO readout.

Below are my hal file entries that relate to the spindle and a screen shot of the pulses from the sensor connected to the 7i76 encoder phase A. After I get this working I am going to work on getting the PID to bring RPM closer to the commanded RPM. Then connect the encoder output from the DYN drive to be able to do rigid taping.

Thanks
John

#DYN4 1.8K Servo Spindle
loadrt estop_latch count=2
addf estop-latch.0 servo-thread
addf estop-latch.1 servo-thread

loadrt pid names=pid.x,pid.y,pid.z,pid.s
loadrt encoder

#add scale and lowpass, these will be used in custom_postgui.hal
loadrt scale count=1
loadrt lowpass count=1
loadrt abs count=1
loadrt near count=1
loadrt not names=not.halui.spindle-stop

addf scale.0 servo-thread
addf lowpass.0 servo-thread
addf abs.0 servo-thread
addf near.0 servo-thread
addf not.halui.spindle-stop servo-thread

setp hm2_5i25.0.encoder.00.index-enable true
setp hm2_5i25.0.encoder.00.counter-mode true
#setp hm2_5i25.0.encoder.00.position-interpolated

#*******************
# SPINDLE S
#*******************
setp pid.s.Pgain [SPINDLE_9]P
setp pid.s.Igain [SPINDLE_9]I
setp pid.s.Dgain [SPINDLE_9]D
setp pid.s.bias [SPINDLE_9]BIAS
setp pid.s.FF0 [SPINDLE_9]FF0
setp pid.s.FF1 [SPINDLE_9]FF1
setp pid.s.FF2 [SPINDLE_9]FF2
setp pid.s.deadband [SPINDLE_9]DEADBAND
setp pid.s.maxoutput [SPINDLE_9]MAX_OUTPUT
setp pid.s.error-previous-target true

net spindle-index-enable <=> pid.s.index-enable
net spindle-enable => pid.s.enable
net spindle-vel-cmd-rpm-abs => pid.s.command
net spindle-fb-rpm-abs => pid.s.feedback
net spindle-output <= pid.s.output

# ---Analog output signals/setup---
setp hm2_5i25.0.7i83.0.1.analogout5-scalemax [SPINDLE_9]OUTPUT_SCALE
setp hm2_5i25.0.7i83.0.1.analogout5-minlim [SPINDLE_9]OUTPUT_MIN_LIMIT
setp hm2_5i25.0.7i83.0.1.analogout5-maxlim [SPINDLE_9]OUTPUT_MAX_LIMIT

net spindle-vel-cmd-rpm => hm2_5i25.0.7i83.0.1.analogout5

# ---setup spindle control signals---

net spindle-vel-cmd-rps <= motion.spindle-speed-out-rps
net spindle-vel-cmd-rps-abs <= motion.spindle-speed-out-rps-abs
net spindle-vel-cmd-rpm <= motion.spindle-speed-out
net spindle-vel-cmd-rpm-abs <= motion.spindle-speed-out-abs
net spindle-enable <= motion.spindle-on => and2.ena.in0 estop-latch.1.reset
net spindle-cw <= motion.spindle-forward
net spindle-ccw <= motion.spindle-reverse
net spindle-brake <= motion.spindle-brake
net spindle-revs => motion.spindle-revs
net spindle-at-speed => motion.spindle-at-speed
net spindle-vel-fb-rps => motion.spindle-speed-in
net spindle-index-enable <=> motion.spindle-index-enable

net spindle-lockout-db estop-latch.1.ok-out => and2.ena.in1
net spindle-OK and2.ena.out => timedelay.0.in
net DYN-enable timedelay.0.out => hm2_5i25.0.7i76.0.0.output-03 hm2_5i25.0.7i83.0.1.analogena5
net spindle-Lockout hm2_5i25.0.7i76.0.0.input-07-not => estop-latch.1.fault-in

# ---Setup spindle at speed signals---
net spindle-vel-cmd-rpm-abs => near.0.in1
net spindle-fb-rpm-abs => near.0.in2
net spindle-at-speed motion.spindle-at-speed <= near.0.out
setp near.0.scale 1.02

# Use ACTUAL spindle velocity from spindle encoder
# spindle-velocity bounces around so we filter it with lowpass
# spindle-velocity is signed so we use absolute component to remove sign
# ACTUAL velocity is in RPS not RPM so we scale it.

setp scale.0.gain 60
setp lowpass.0.gain 1.2
net spindle-vel-fb-rps hm2_5i25.0.encoder.00.velocity => scale.0.in
net spindle-fb-rpm scale.0.out => abs.0.in
net spindle-fb-rpm-abs abs.0.out => lowpass.0.in
net spindle-fb-rpm-abs-filtered lowpass.0.out

Attachments:

Please Log in or Create an account to join the conversation.

More
26 Aug 2018 03:02 - 26 Aug 2018 04:27 #116590 by PCW
Replied by PCW on topic Bouncing spindle RPM display
Try setting the lowpass gain to between .005 an 0.1

Also since you have such a slow encoder signal you probably want to maximise the electrical noise filtering
by enabling the encoder filter and setting the sample rate lower:

setp hm2_5i25.0.encoder.00.filter true
setp hm2_5i25.0.encoder.sample-frequency 500000

This will set the encoder inputs digital filter time constant to 30 usec
(default time constant on a 5I25 with the filter off would be 100 ns = 300 times shorter)
Last edit: 26 Aug 2018 04:27 by PCW. Reason: copy-paste error

Please Log in or Create an account to join the conversation.

More
26 Aug 2018 03:29 #116591 by JohnnyCNC
I tried .01, .001, .002, .003, .004, .005, and previously 1.4,1.2,1,.9,.6,.5,.1, .01, .04,.05,.06. None of these setting make me think I am getting close.

Please Log in or Create an account to join the conversation.

More
26 Aug 2018 04:27 #116592 by PCW
Replied by PCW on topic Bouncing spindle RPM display
lowpass gain numbers 1 or over make no sense

Is the RPM readout approximately right?

How are you looking at the spindle speed? the lowpass gain should make a dramatic difference in the displayed number jitter.

The smaller the lowpass gain number, the longer the filter time constant. Long time constants should smooth the displayed speed but too long will cause the filtered number to lag excessively.

Did you change the encoder filter settings I mentioned? It would be good to do this to rule out electrical noise

Please Log in or Create an account to join the conversation.

More
26 Aug 2018 14:25 #116605 by JohnnyCNC
Apparently I follow instructions much better after some sleep. I changed hm2_5i25.0.encoder.sample-frequency to 500000 and it worked. I then backed the number down by halving it. 20000 is where I ended up and it is working great.

Thanks PCW.

Please Log in or Create an account to join the conversation.

Time to create page: 0.171 seconds
Powered by Kunena Forum