AASD Spindle Servo Motor
- tightmopedman9
- Offline
- Senior Member
- Posts: 69
- Thank you received: 7
I can adjust the PI factors of the loop within the drive itself, but considering how cryptic the manual is and how hard it was to get just this far, I'd rather do as little tuning in the drive as possible. So far, I have left these parameters at their factory programmed values.
I have a feeling that I don't have all the necessary HAL connections in LinuxCNC to properly control the PID loop. If I increase the P factor within LinuxCNC, motor speed goes up seemingly arbitrarily, and there seems to be no feedback to bring the motor to the targeted speed.
Before I go ahead and try to tune the drive with the servo drive operating in speed command mode, I'm wondering if it would be better to switch to torque control mode, so that LinuxCNC could have more control over the spindle. I tried to find some information about which mode would be better for a spindle, but couldn't find any relevant information.
Also, I'm confused about the encoder scale. The motor has a 2500 line encoder and is connected to the spindle via a 64 -> 22 toothed pulley. I would expect an encoder scale of 859.375 (22/64 * 2500), but when I rotate the spindle 360º LinuxCNC reports ~3400 raw counts. I ended up using an encoder scale of 3437.5 (859.375 * 4), but came about this number pretty arbitrarily.
I do not understand MAX_OUTPUT or OUTPUT_SCALE, is there any suggested reading on this topic?
Below are the relevant lines from my HAL and INI files:
#*******************
# SPINDLE
#*******************
setp pid.s.Pgain [SPINDLE_0]P
setp pid.s.Igain [SPINDLE_0]I
setp pid.s.Dgain [SPINDLE_0]D
setp pid.s.bias [SPINDLE_0]BIAS
setp pid.s.FF0 [SPINDLE_0]FF0
setp pid.s.FF1 [SPINDLE_0]FF1
setp pid.s.FF2 [SPINDLE_0]FF2
setp pid.s.deadband [SPINDLE_0]DEADBAND
setp pid.s.maxoutput [SPINDLE_0]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 => pid.s.command
net spindle-vel-fb-rpm => pid.s.feedback
net spindle-output <= pid.s.output
# ---PWM Generator signals/setup---
setp hm2_5i25.0.7i77.0.1.analogout3-scalemax [SPINDLE_0]OUTPUT_SCALE
setp hm2_5i25.0.7i77.0.1.analogout3-minlim [SPINDLE_0]OUTPUT_MIN_LIMIT
setp hm2_5i25.0.7i77.0.1.analogout3-maxlim [SPINDLE_0]OUTPUT_MAX_LIMIT
net spindle-output => hm2_5i25.0.7i77.0.1.analogout3
# ---setup spindle control signals---
net spindle-vel-cmd-rps <= spindle.0.speed-out-rps
net spindle-vel-cmd-rps-abs <= spindle.0.speed-out-rps-abs
net spindle-vel-cmd-rpm <= spindle.0.speed-out
net spindle-vel-cmd-rpm-abs <= spindle.0.speed-out-abs
net spindle-enable <= spindle.0.on
net spindle-cw <= spindle.0.forward
net spindle-ccw <= spindle.0.reverse
net spindle-brake <= spindle.0.brake
net spindle-revs => spindle.0.revs
net spindle-at-speed => spindle.0.at-speed
net spindle-vel-fb-rps => spindle.0.speed-in
net spindle-index-enable <=> spindle.0.index-enable
#---Enable Spindle---
#net spindle-enable => hm2_5i25.0.7i77.0.1.spinena
net spindle-enable => hm2_5i25.0.7i77.0.0.output-03
# ---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 spindle.0.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 .005
setp lowpass.0.load false
net spindle-vel-fb-rps hm2_5i25.0.encoder.03.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
# ---Encoder feedback signals/setup---
setp hm2_5i25.0.encoder.03.counter-mode 0
setp hm2_5i25.0.encoder.03.filter 1
setp hm2_5i25.0.encoder.03.index-invert 0
setp hm2_5i25.0.encoder.03.index-mask 0
setp hm2_5i25.0.encoder.03.index-mask-invert 0
setp hm2_5i25.0.encoder.03.scale [SPINDLE_0]ENCODER_SCALE
[SPINDLE_0]
P = 0.01255
I = 0
D = 0
FF0 = 0
FF1 = -0
FF2 = 0
BIAS = 0
DEADBAND = 0
MAX_OUTPUT = 1000
ENCODER_SCALE = 3437.5
OUTPUT_SCALE = 108
OUTPUT_MIN_LIMIT = -10
OUTPUT_MAX_LIMIT = 100
Please Log in or Create an account to join the conversation.
- Todd Zuercher
- Away
- Platinum Member
- Posts: 4957
- Thank you received: 1441
You may need to improve the tuning in the drive.
Please Log in or Create an account to join the conversation.
- PCW
- Online
- Moderator
- Posts: 17966
- Thank you received: 4824
A 2500 line (PPR) quadrature encoder has 10000 counts per turn (4x2500)Also, I'm confused about the encoder scale. The motor has a 2500 line encoder and is connected to the spindle via a 64 -> 22 toothed pulley. I would expect an encoder scale of 859.375 (22/64 * 2500), but when I rotate the spindle 360º LinuxCNC reports ~3400 raw counts. I ended up using an encoder scale of 3437.5 (859.375 * 4), but came about this number pretty arbitrarily.
OUTPUT_SCALE = RPM at 10V (full scale) to scale in RPMOUTPUT_SCALE = 108
OUTPUT_MIN_LIMIT = -10
OUTPUT_MAX_LIMIT = 100
OUTPUT_MIN_LIMIT = Minimum output bound (in RPM)
OUTPUT_MAX_LIMIT = Maximum output bound (in RPM)
Please Log in or Create an account to join the conversation.
- tightmopedman9
- Offline
- Senior Member
- Posts: 69
- Thank you received: 7
Of course, I didn't think about A + B and rising + falling. The 3437.5 seemed arbitrary, but looks like it was right...A 2500 line (PPR) quadrature encoder has 10000 counts per turn (4x2500)
10v = 2500RPM @ the servo, so 7272.7 at the motor. So then, does this look right?OUTPUT_SCALE = RPM at 10V (full scale) to scale in RPM
OUTPUT_MIN_LIMIT = Minimum output bound (in RPM)
OUTPUT_MAX_LIMIT = Maximum output bound (in RPM)
OUTPUT_SCALE = 7272
OUTPUT_MIN_LIMIT = -7272
OUTPUT_MAX_LIMIT = 7272
What should MAX_OUTPUT be set to? For all of my axes I have it set to 0 (but I made no attempt at scaling before tuning them).
I tried this and the resultant spindle speed was ~15% slower than actual speed (spindle-fb-rpm-abs-filtered) at spindle speeds ranging from 30-5000. I noticed that Dn17 on the drive (analog voltage input) maxes out at 9.85 when LinuxCNC reports an output of 10V, although I haven't measured input at the drive with a multimeter yet to confirm LinuxCNC is correct. Should I rescale the output scale to match this lower effective RPM?To start with try setting P=0 (and all other PID terms) and FF0=1.0 and see what happens. This should start you out with essentially an open loop command where the PID loop is simply sending the spindle speed command straight through. (This is assuming every thing is scaled correctly.)
You may need to improve the tuning in the drive.
I found the problem with my PID loop by referencing this spindle control HAL flow chart. This is the first HAL flowchart/diagram I had seen, and this visual really helped my understanding. Within my HAL file, I had pid.s.feedback connected to net spindle vel-fb-rpm, but didn't have spindle vel-fb-rpm connected to anything, so PID feedback had no input. With this connected, pid.s.output is now dynamically changing to keep the spindle at the target RPM, but when the P factor is changed to give any sort of reasonable motor stiffness, the servo emits a horrible noise and pid.s.output oscillates wildly.
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
- Posts: 23170
- Thank you received: 4860
dynamically changing to keep the spindle at the target RPM, but when the P factor is changed to give any sort of reasonable motor stiffness, the servo emits a horrible noise and pid.s.output oscillates wildly.
I would expect a spindle PID to be more biased to I than P. Try more I-gain.
(Note that when you are at the programmed speed the P-term is zero. so with _only_ P you would be asking for zero speed every time you get to setpoint. This is exactly right for _position_ control but not for velocity.
So try FF0 of 1.0, a small P and a fair bit of I.
Please Log in or Create an account to join the conversation.