Tuning PID values for servo

More
14 Mar 2016 22:59 - 14 Mar 2016 23:01 #71657 by dinodf
Dear, I'm tuning the PID's values to control a servo (DC motor driven by www.isel.com/hu/downloads/dl/file/id/4287/dc_setup_eng.pdf), I have read the good tutorial written by John Thornton (gnipsel.com/linuxcnc/tuning/servo.html), I have an acceptable result, but the axis is very "nervous" and at start and stop it have a BIG error :(
This is in .ini file:
#********************
# Axis X
#********************
[AXIS_0]
TYPE = LINEAR
HOME = 0.0
FERROR = 10.005
MIN_FERROR = 10.0005
MAX_VELOCITY = 250.0
MAX_ACCELERATION = 5000.0
P = 5
I = 0.02
D = 0.08
FF0 = 0
FF1 = 0.06
FF2 = 0.075
BIAS = 0
DEADBAND = 0.0001
MAX_OUTPUT = 8
ENCODER_SCALE = 800
OUTPUT_SCALE = 16
OUTPUT_MIN_LIMIT = -10
OUTPUT_MAX_LIMIT = 10
MIN_LIMIT = -0.01
MAX_LIMIT = 100.0
HOME_OFFSET = 0.000000
HOME_SEARCH_VEL = -0.050000
HOME_LATCH_VEL = -0.016667
HOME_FINAL_VEL = 0.000000
HOME_USE_INDEX = YES
HOME_SEQUENCE = 1
and this in .hal:
#*******************
#  AXIS X
#*******************

setp   pid.x.Pgain     [AXIS_0]P
setp   pid.x.Igain     [AXIS_0]I
setp   pid.x.Dgain     [AXIS_0]D
setp   pid.x.bias      [AXIS_0]BIAS
setp   pid.x.FF0       [AXIS_0]FF0
setp   pid.x.FF1       [AXIS_0]FF1
setp   pid.x.FF2       [AXIS_0]FF2
setp   pid.x.deadband  [AXIS_0]DEADBAND
setp   pid.x.maxoutput [AXIS_0]MAX_OUTPUT

net x-index-enable  <=>  pid.x.index-enable
net x-enable       => pid.x.enable
net x-output       => pid.x.output
net x-pos-cmd      => pid.x.command
net x-vel-fb       => pid.x.feedback-deriv
net x-pos-fb       => pid.x.feedback

# ---PWM Generator signals/setup---

setp   hm2_5i25.0.7i77.0.1.analogout0-scalemax  [AXIS_0]OUTPUT_SCALE
setp   hm2_5i25.0.7i77.0.1.analogout0-minlim    [AXIS_0]OUTPUT_MIN_LIMIT
setp   hm2_5i25.0.7i77.0.1.analogout0-maxlim    [AXIS_0]OUTPUT_MAX_LIMIT

net x-output                             => hm2_5i25.0.7i77.0.1.analogout0
net x-pos-cmd    axis.0.motor-pos-cmd
net x-enable     axis.0.amp-enable-out
# enable _all_ sserial pwmgens
net x-enable   hm2_5i25.0.7i77.0.1.analogena

# ---Encoder feedback signals/setup---

setp    hm2_5i25.0.encoder.00.counter-mode 0
setp    hm2_5i25.0.encoder.00.filter 1
setp    hm2_5i25.0.encoder.00.index-invert 0
setp    hm2_5i25.0.encoder.00.index-mask 0
setp    hm2_5i25.0.encoder.00.index-mask-invert 0
setp    hm2_5i25.0.encoder.00.scale  [AXIS_0]ENCODER_SCALE

net x-pos-fb               <=  hm2_5i25.0.encoder.00.position
net x-vel-fb               <=  hm2_5i25.0.encoder.00.velocity
net x-pos-fb               =>  axis.0.motor-pos-fb
net x-index-enable    axis.0.index-enable  <=>  hm2_5i25.0.encoder.00.index-enable
net x-pos-rawcounts        <=  hm2_5i25.0.encoder.00.rawcounts

# ---setup home / limit switch signals---

net home-x     =>  axis.0.home-sw-in
net min-x     =>  axis.0.neg-lim-sw-in
net max-x     =>  axis.0.pos-lim-sw-in

Please indicate me what I have to tune for eliminate this error!

Two more questions:
what does it mean MAX_OUTPUT = 8 OUTPUT_SCALE = 16 OUTPUT_MIN_LIMIT = -10 OUTPUT_MAX_LIMIT = 10?
pid.x.maxoutput (MAX_OUTPUT) is the maximum value allowed from pid but not the value (in volts) of the analog?
From manual
(float rw) .7i77.0.0.analogoutN-maxlim: (N = 0 to 5) The maximum speed request allowable
(float rw) .7i77.0.0.analogoutN-minlim: (N = 0 to 5) The minimum speed request.
//// ***** CHECK ME ***** I’m not sure about the description on analogoutN-scalemax ////
(float rw) .7i77.0.0.analogoutN-scalemax: (N = 0 to 5) The analog speed scaling. This is the speed request which would correspond to full-scale output from the spindle control pin. For example with a 10V drive voltage and a 10000rpm scalemax a value of 10,000 rpm on the spinout pin would produce 10V output. However, if spinout-maxlim were set to 5,000 rpm then no voltage above 5V would be output.

Please can explain a bit?
it is correct set OUTPUT_SCALE = 16? (if I set it to 10 the following-error is big)
OUTPUT_MIN_LIMIT = -10 and OUTPUT_MAX_LIMIT = 10 what does it mean? 10 rpm? 10V? what?

Thanks a lot!
Dino
Attachments:
Last edit: 14 Mar 2016 23:01 by dinodf.

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

More
15 Mar 2016 00:36 - 15 Mar 2016 00:37 #71661 by PCW
Replied by PCW on topic Tuning PID values for servo
Is the drive programmed for velocity mode operation? its not clear that this is the case

The plot is not of much use unless you plot what motion is happening (at minimum plot following error plus commanded velocity )

I would set the minlimit and maxlimit and output scale all to 10 (this is in volts unless you scale the output into machine units per second)
edit: (minlimit would be -10)

With initial tuning set D and I and FF2 to 0. Only when tuning is very close should you even think about touching these.
If you cannot get _very_ close to correct with just P and FF1 something is wrong elsewhere that needs to be fixed.

Note that pncconf has a bug and sets MAX_ERROR to .0005, this needs to be set to 0 for all axis (no limit)
Last edit: 15 Mar 2016 00:37 by PCW.
The following user(s) said Thank You: dinodf

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

More
15 Mar 2016 07:39 #71668 by emcPT
Replied by emcPT on topic Tuning PID values for servo
See this information. It have step by step instructions

www.wiki.eusurplus.com/index.php?title=Category:Tuning
The following user(s) said Thank You: dinodf

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

More
15 Mar 2016 15:40 #71685 by dinodf
Replied by dinodf on topic Tuning PID values for servo
Thanks for the answers!
The drive is programmed for velocity mode, I try to tune it with the instructions linked, But I have a doubt, MAX OUTPUT, OUTPUT SCALE, OUTPUT_MIN_LIMIT and OUTPUT_MAX_LIMIT must have the same values except for the sign? and what value, 10? (V)

Thanks

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

More
15 Mar 2016 17:02 #71687 by PCW
Replied by PCW on topic Tuning PID values for servo
Unless you have a very good reason, i would leave
OUTPUT_SCALE, OUTPUT_MAX_LIMIT = 10
and
OUTPUT_MIN_LIMIT = -10

The only common exception would be if you want to normalize these values
so the PID output is scaled in machine units/per second (Making FF1==1)
The following user(s) said Thank You: dinodf

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

More
20 Mar 2016 22:18 #71953 by dinodf
Replied by dinodf on topic Tuning PID values for servo
These are the steps that I have to do for have a good result?
1. Check that the configuration it's correct (verse Encoder Input and Output drive)
2. Adjust the maximum speed that the servo drive can take (MAX_VELOCITY)
3. Adjust the PID output scale for have +-10v measurable on Mesa output pin (OUTPUT_SCALE, OUTPUT_MAX_LIMIT and OUTPUT_MIN_LIMIT)
4. Adjust the values P and FF1 of the PID to minimize the following-error

I forgot something?

Some more questions:
When I have to increase P value for search the maximum stiffness without oscillation I have to move the axis but at what velocity? from 5-10% till to maximum allowed I think, it's right? and when I found the lower P value that have oscillations which value I will set? half of it? or 75%

Thank you

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

More
21 Mar 2016 15:06 - 21 Mar 2016 15:08 #71987 by PCW
Replied by PCW on topic Tuning PID values for servo
That's about correct for velocity mode servos, you also need to a set safe following error limits
and make sure LinuxCNC has control of the drive enables before powering the drives

For 2, you typically set MAX_VELOCITY to about 80% of the servos speed at 10V (so you have 20 % headroom)

You do not need to do 3 (pncconf and example files all set these to +-10V) The only reason I can think of
to change these numbers is if you want to modify the scale so the PID output is in machine units (velocity)
this has the advantage that tuning for mm and inch machines is now the same (and FF1 is known = 1.0)

JT has a nice tuning tutorial here

gnipsel.com/linuxcnc/tuning/servo.html
Last edit: 21 Mar 2016 15:08 by PCW.
The following user(s) said Thank You: dinodf

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

More
06 Apr 2016 18:19 #72861 by dinodf
Replied by dinodf on topic Tuning PID values for servo
Now I have SERVO_PERIOD = 1000000, my PC have maximum jitter near 15000, it will better response if I decrease SERVO_PERIOD value? at half? at a third?

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

More
06 Apr 2016 18:33 - 06 Apr 2016 18:34 #72865 by Todd Zuercher
There typically is little advantage to shortening the servo period to less than that for a velocity controlled servo. (unless speeds and accelerations are extremely high.)
Last edit: 06 Apr 2016 18:34 by Todd Zuercher.
The following user(s) said Thank You: dinodf

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

Time to create page: 0.094 seconds
Powered by Kunena Forum