Need help setting up synchronized spindle

More
8 years 2 months ago #116758 by JohnnyCNC
I connected the encoder and index
I got the spindle going and moving in the proper direction but only at full speed. I think the issue not getting the proper feedback to the PID.

I have my DYN4 Servo working as a spindle motor under PID control. Now I want to connect the encoder so I can do rigid taping. I have been searching and looking through the documentation. I found section "6.1. Spindle Synchronized Motion" section and followed it making the changes I thought made sense given that I am using a 7i76. I am using the encoder outputs on the DYN4 drive for the A&B phases and the optical detector on my spindle as the index.

I got the spindle going and moving in the proper direction but only at full speed. I believe that my issue is getting the correct feedback value to the PID.

Below are the spindle/encoder related HAL & INI file entries.

Thanks
John

# set the HAL encoder to 4551.111111 pulses per revolution.
setp encoder.0.position-scale [SPINDLE_9]ENCODER_SCALE
setp hm2_5i25.0.encoder.00.scale [SPINDLE_9]ENCODER_SCALE

# set the HAL encoder to quadrature simple counting using A & B.
setp encoder.0.counter-mode false

# connect the HAL encoder outputs to LinuxCNC.
net spindle-position encoder.0.position => motion.spindle-revs
#net spindle-velocity encoder.0.velocity => motion.spindle-speed-in
net spindle-index-enable encoder.0.index-enable <=> motion.spindle-index-enable

# connect the HAL encoder inputs to the real encoder.
net spindle-phase-a encoder.0.phase-A <= hm2_5i25.0.encoder.00.input-a
net spindle-phase-b encoder.0.phase-B <= hm2_5i25.0.encoder.00.input-b
net spindle-index encoder.0.phase-Z <= hm2_5i25.0.encoder.00.input-index

#// hm2_5i25.0.encoder.00
#// Parameters

#setp hm2_5i25.0.encoder.00.counter-mode true
#setp hm2_5i25.0.encoder.00.filter true
setp hm2_5i25.0.encoder.00.index-invert true
#setp hm2_5i25.0.encoder.00.index-mask false
#setp hm2_5i25.0.encoder.00.index-mask-invert false
#setp hm2_5i25.0.encoder.00.scale [SPINDLE_9]ENCODER_SCALE
#setp hm2_5i25.0.encoder.00.vel-timeout (Defalut 0.5)

setp hm2_5i25.0.encoder.sample-frequency 25000


#*******************
# 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-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-output => 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 => hm2_5i25.0.encoder.00.position motion.spindle-revs
#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 .8
setp lowpass.0.load false

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


INI File entries
[SPINDLE_9]
P = 2
I = 4
D = 0
FF0 = 1.03
FF1 = 0.00
FF2 = 0.00
BIAS = 0.0
DEADBAND = 0.0

MAX_OUTPUT = 5400.0
OUTPUT_MIN_LIMIT = -5400
OUTPUT_MAX_LIMIT = 5400
OUTPUT_SCALE = -10800
ENCODER_SCALE = 4551.111111
#((2048 * 4) / 1.8) = 4551.111111

Please Log in to join the conversation.

More
8 years 2 months ago #116762 by PCW
"setp hm2_5i25.0.encoder.sample-frequency 25000"

Is fine for a one pulse per turn encoder = 600 usec filter but will fail at
more than about 10 RPM with ~4500 counts per turn

Please Log in to join the conversation.

More
8 years 2 months ago #116770 by JohnnyCNC
Thanks PCW.

I was eyeballing that one just before I shutdown for the night. That was to fix the display which is also not working right now but I wasn't going to address the display until I had it running correctly again.

John

Please Log in to join the conversation.

More
8 years 2 months ago #116787 by andypugh
It is possible that the encoder is counting reversed.

Take a look at the pid.s command and feedback signals with halscope.
If they have different signs, this is the problem.
There is also a possibility that one is in rpm and one is in rps...

Please Log in to join the conversation.

More
8 years 2 months ago #116816 by JohnnyCNC
I'm going to check everything over again when I get home but the RPM vs RPS comment brings up a question. Would it be better to use RPS or RPM in the PID? Or, does it not matter?

Please Log in to join the conversation.

More
8 years 2 months ago #116821 by andypugh
It's simpler to use RPS everywhere except if you want an rpm readout.

Please Log in to join the conversation.

More
8 years 2 months ago #116825 by JohnnyCNC
That was it. Commented that line out and the spindle and RPM display both work.

Thank You
John

Please Log in to join the conversation.

More
8 years 2 months ago #116834 by JohnnyCNC
Thanks for the help guys. I just rigid tapped my first hole. 6-32 in aluminum.

John

Please Log in to join the conversation.

Time to create page: 0.092 seconds
Powered by Kunena Forum