585,967 active members*
4,406 visitors online*
Register for free
Login
Page 1 of 2 12
Results 1 to 20 of 32
  1. #1
    Join Date
    Dec 2006
    Posts
    406

    Optimizing servo tuning.

    Hi Tom,
    These are the screen shots and data files for my current setup. Some things you may want to know are the extent I got with increasing the P setting. X is rack and pinion drive and made it to 8 before going unstable. I reduced it to 7. The Y is acme 1/2-10 leadscrew and made it to 35 before being reduced to 17.5. It got very noisey as i went above 17.5. The Z is a 5 thread 5/8" ballscrew and made it to 10 before being reduced to 9. The motors are all noisey for some reason. I cut a part at 50 and 25ipm they were dead on for measurements after adjusting the steps but were no good on the corner radius. they were rough and odd shaped and did'nt show up at all below 1/8" radius. Any help is much appreciated. Thanks.
    Judleroy
    Attached Thumbnails Attached Thumbnails x.PNG   y.PNG   z.PNG  
    Attached Files Attached Files
    • File Type: txt x.txt (478.1 KB, 25 views)
    • File Type: txt y.txt (479.5 KB, 9 views)
    • File Type: txt z.txt (481.5 KB, 11 views)

  2. #2
    Join Date
    Dec 2006
    Posts
    406
    I did not get the shots off the config and filter screens. I will do that tomorrow. I can say that I set all three as brush servo with encoder input and set the snapamp motor output channels. Also set max error to 10000 counts. Nothing else was changed in the configure screen from factory. Also all filters are turned off for all axis as per the manuals instructions. Thanks.
    Judleroy

  3. #3
    Join Date
    May 2006
    Posts
    4045
    Hi Judleroy,

    Yes there is oscillation.

    Here is first some background:

    I believe you are using our SnapAmp driving Brush Servos. In this case the servo output is commanding torque (or acceleration). Sometimes with CNC machines and Analog Servos the servo output can command velocity rather than acceleration. Simple P (proportional) gain when commanding velocity will make a stable system. But simple P gain when commanding acceleration will not.

    P gain works simply to make the commanded output proportional to the error. This means that as we approach the target the output reduces to zero.

    With a velocity command this works well it causes us to reduce speed as we get closer to the target. This results in a nice exponential curve.

    But with an acceleration command the acceleration reduces as we get closer to the target. This means we actually continue to accelerate right until we reach the target. The acceleration is reducing but still positive so speed is still increasing and more importantly not decreasing. This is like in your car taking your foot off the gas as you arrive at a stop sign. This results in overshooting the target badly. This only works at all if you are going slow and have a lot of friction. Like a car slowly dragging a heavy sled behind. If you remove the gas as you approach the stop sign you may well stop without too much overshoot.

    So the first step in CNC servo tuning is to be aware of what type of servo system amplifier you have: Velocity or Acceleration Command (note acceleration, motor current, and torque are all basically the same thing).

    In your case we have acceleration command. The key to stabilizing this type of system is D (derivative) gain. D gain is like adding artificial friction or damping. It applies a deceleration that is proportional to velocity. The P and the D gains then work together to form a nice approach to the desired stopping position.

    So back to your system: The next step is to add in some D gain. As described above increasing D gain is like adding in friction which slows the system down. This is unlike P (and I) gain where increasing gain makes the system respond harder and faster. However this only works upto a point. Increasing D gain too far will also make the system unstable due to small delays and compliances in the mechanics which make the applied "friction" become out of phase with the velocity.

    So add in increasing D gain until the system goes unstable. Then back off a significant amount (2 or 3X reduction).

    Then see if the P gain can now be increased and better performance is obtained without so much oscillation.

    Regards
    TK
    TK
    http://dynomotion.com

  4. #4
    Join Date
    Dec 2006
    Posts
    406
    Thanks Tom. I will try this and then post back to see where to go from there. The examples you give make some things a little clearer.
    Judleroy

  5. #5
    Join Date
    Dec 2006
    Posts
    406
    I must confess a little confusion. I have tried increasing d until the system goes unstable. I made it to 500000 with channel 0 and still no instability. The other 2 I did not take that far but appear the same. At 10000 or so when I change the move size to 10000 the machine moves very slow and sluggish.
    Also the Output is set at 200 and so is the error. What will increasing the output do?
    Thank you.
    Judleroy

  6. #6
    Join Date
    Dec 2006
    Posts
    406
    One more thing I didn't mention. The motors at idle output a terrible sounding hissing and whining noise. The output voltage is showing nothing on x and y at idle and z is hovering about the bottom of the chart. (I assume because it is holding itself up). If it weren't for the stable voltage the noise would really scare me?
    Judleroy

  7. #7
    Join Date
    May 2006
    Posts
    4045
    Judleroy ok great progress! :}

    Well let's see I was hoping to take this one step at a time but maybe that doesn't work well. I think we need to add a low pass filter.

    A little more background: The derivative is trying to calculate speed by observing the changes in encoder position. But KFLOP samples the encoder pretty fast (90us) and the encoder has limited resolution. So what typically happens is KFLOP sees no change in encoder for many times and then it sees a change of one encoder count. So basically it thinks the velocity is zero most of the time and every once in a while it sees a velocity of 1 encoder count change per servo tick. So with a D gain of 100 the result of the derivative feedback is to output 0x100=0 most of the time and sometimes 1x100=100. This is very spikey and SnapAmp and the motor don't handle that well. Furthermore if you crank the D gain up to 1000000 then it tries to output 0 most of the time and 1000000 sometimes, but we have the output max set at 200 so the 1000000 gets clipped down to 200 so really any gain over 200 will make no difference. BTW you should be able to see all this if you look at the plots and zoom in. Each "step" in the encoder (red) will cause the output (green) to spike up to 200 and be clipped.

    So try adding in a Low pass filter. Use the 3rd filter and specify a 2nd order Low pass filter with a frequency of 500 Hz and a Q of 1.4. Don't forget to push the "Compute" button which will comput the 5 Z domain coeficients which are what the DSP actually uses to implement the Low Pass filter. This will smooth the spikes into a more continuous current so the Amplifier and the Motor can make more use of the command. You should be able to see a difference in the plots. Please post some plots if you have time.

    BTW you asked about the Max limits. Here is a copy of a post from the Yahoo Group:

    Max Output - limits the max output of the servo which in the case of a SnapAmp will limit the max current applied to the motor. This should be set as low as possible to achieve the acceleration that you really need.

    Max Integrator - limits the amount the integrator to "wind up". Without any limit if something abnormal happens like if you force the servo off target with your hand and hold it off for a long time the integrator will continue to ramp up to a Huge value so then if you release it there will be a large overshoot most likely slamming the axis into the limit (this assumes you don't have a Max Following Error set to fault the axis). Max Integrator helps prevents this. Normally it should be set to a fraction of the Max Output.

    Max Error - Normally servo following errors are small. But in abnormal situations they might be big such as when trying to accelerate too fast. Max Error can limit the amount of error that the servo "sees" so as not to react too violently to a huge error. This should normally be set to slightly bigger that the amount of errors that you would expect under normal conditions.
    TK
    http://dynomotion.com

  8. #8
    Join Date
    Dec 2006
    Posts
    406
    I implemented the low pass and that quieted things down a lot but still a bit of noise. The filter made me have to decrease my p gain. I increased d but still cannot get it to go unstable. I stopped at 200 but at that the noise was loud again. I decreased to 100 and at that could almost double p. I will post plots tonite but if there's a next step I can move on to before then that will be great. I will save the plots where they are now but can't post till I get home. I believe this is moving in the right direction and I'm starting to understand what's going on with each setting. Thanks for everything.
    Judleroy

  9. #9
    Join Date
    May 2006
    Posts
    4045
    Hi Judleroy,

    It's hard to tell the next step without seeing the plots.

    We have the Max output set very low (if it is still at 200). Max Current of 8191 corresponds to 35Amps. So 200 is only 0.85A. But I wouldn't normally start increasing the peak current until things are stable. Looking at the plots you can check if the current is being limited.

    Later I gain will improve accuracy. Start with a small number like 0.0001.

    Thanks for your patience.

    Regards
    TK
    http://dynomotion.com

  10. #10
    Join Date
    Dec 2006
    Posts
    406
    These are the new screenshots and data files. I have just waited and worked on other things untill you can look them over. I will wait to see what you think before adjusting anything. I have cut some more. The radius are much better but far from good. When I cut text which has alot of arcs I have a issue with the way code is run. It pauses whenever it comes to alot of arcs all together and runs the code then a little later cuts the path. Like its thinking it through before it can make the cut. Can this be taken care of? Also My x moves .032 inches when it reverses direction before it actually starts moving. (backlash). I am not sure what it is asking for in the backlash comp section? Thanks always.
    judleroy
    Attached Thumbnails Attached Thumbnails x.PNG   y.PNG   z.PNG  
    Attached Files Attached Files
    • File Type: txt x.txt (478.1 KB, 14 views)
    • File Type: txt y.txt (479.5 KB, 13 views)
    • File Type: txt z.txt (481.5 KB, 12 views)

  11. #11
    Join Date
    May 2006
    Posts
    4045
    Hi Judleroy,

    I don't understand, there doesn't seem to be any D gain or Low Pass filter added?

    Regards
    TK
    http://dynomotion.com

  12. #12
    Join Date
    Dec 2006
    Posts
    406
    Sorry I used files from the wrong folder. I will repost in just a few minutes. Sorry. Judleroy

  13. #13
    Join Date
    Dec 2006
    Posts
    406
    These should work better.
    Attached Thumbnails Attached Thumbnails x.jpg   y.jpg   z.jpg  
    Attached Files Attached Files
    • File Type: zip x.zip (139.5 KB, 10 views)
    • File Type: zip y.zip (156.7 KB, 6 views)
    • File Type: zip z.zip (143.2 KB, 5 views)

  14. #14
    Join Date
    Dec 2006
    Posts
    406
    Here are a few videos of the machine cutting. The first shows the machine configuration from a distance. The second is cutting text. You can see the dwell I was talking about when cutting alot of arcs.
    [ame=http://www.youtube.com/watch?v=iBO1SMwH7-g]VIDEO0039 - YouTube[/ame]
    and
    [ame=http://www.youtube.com/watch?v=IdE26_JvRYE]VIDEO0041 - YouTube[/ame]
    The more complicated the letter the longer the pause?
    Judleroy

  15. #15
    Join Date
    May 2006
    Posts
    4045
    Hi Judleroy,

    Those graphs look pretty good. Max following error is less than 20 encoder counts for all 3 axes.

    There is some limit cycle oscillation when sitting still of one encoder count particularly on the Y axis. See the attachment. Notice the encoder (red plot) is dithering by 1 count. If you find this annoying it can usually be eliminated by specifying a "Dead Band". Dead band can be used to tell the servo to reduce (or even consider as zero) any small error. There are two parameters for Dead Band - Range and Gain. The Range specifies how far from zero error the Dead Band should be applied. Specifying a value of 0 will cause Dead Band to be never applied. A typical value of 3 might be used so that when the error is less that 3 encoder counts it is applied. The Gain is the DeadBand factor to be applied to the error. Zero would tell the servo to ignore any error less than 3 counts completely. Or a Gain of 0.1 might be used to tell the servo to attempt to correct the error with an effort of 10% of normal. You will most likely have to play with the values for your system. You should realize that Dead Band will tend to make your system less accurate to a tiny degree so you should use the minimum necessary.

    Your system could also benefit from a small amount of I gain. Notice in the attached plot that the axis is limit cycling 1 count but is also 3 count away from the target position (blue plot). I Gain would force this to zero sooner or later and never allow it to remain 3 counts away indefinitely. I gain will also help during the motion to apply the average output necessary to keep things moving rather than requiring some error to create the drive. I gain is very destabilizing so too much will quickly cause oscillation. Because it accumulates every servo sample (90us) it is usually a small value in the 0.001 to 0.0001 range.

    I did notice a minor issue with your X encoder. It may be close to going bad. It looks like the AB quadrature signals that should be 90 degrees out of phase are more like 20 degrees out of phase. In the attached plot you can see the encoder changes in an irregular manner. Instead of even change is doesn't change for a while and then changes 2 counts rapidly. This also disturbs the servo as it thinks the axis is going slow, then fast, then slow, then fast. You can see this in the output (green). Probably not a big deal. Even a perfect encoder changes not at all and then suddenly one count so this is only twice as bad, but if the 20 degrees of phase goes down to zero it wont work at all so you should be aware of this.

    Regarding the pauses. This is somewhat of a known issue and is caused by us flushing the USB buffer on each Rapid motion (G0). Then to start a new motion enough coordinated path needs to be downloaded to be sure any Windows stalls won't be a problem before motion can begin. How much Windows buffer time do you have specified in the Trajectory Planner Configuration. Reducing it to 1 or 2 seconds may be enough. If you get the dreaded "Unexpected buffer underflow" message then you have reduced it too much.

    Also "Corner Rounding" can generate lots of tiny vectors if the "Facet Angle" parameter is set very small.

    Another workaround is to change your GCode to use all coordinated motion Paths (all G1 G2 G3) without any Rapids (G0). In this case you can eliminate the pauses entirely. You may want to set high feed rates for the "rapids".

    We are looking int a better solution.

    Regards
    TK
    Attached Thumbnails Attached Thumbnails YLimitCycle.png   BadEncoder.png  
    TK
    http://dynomotion.com

  16. #16
    Join Date
    Dec 2006
    Posts
    406
    Thanks a lot Tom. That sounds like things are moving in a good direction. I will set the dead band for 3 counts and adjust the I gain as you suggest. Also I removed that encoder and later put it back on so the problem might be my fault. I don't know if it can be adjusted to fix the problem. My circles and radius look terrible and I'm pretty sure it's because of backlash. When jogging the x axis in k-motion Cnc I set the step size to .001. It takes 32 thou before a change in direction in that axis starts. I'm not really sure what to do to compensate for this. I think I understand that the amount would be the number of encoder counts that equal 32 thou of motion. I do not know how to set the rate because I don't know what it relates to or how it is computed? I also am wondering about feed forward and if it would be helpful in my system? I would like to know what to set the Output to to equal 3 amps? Is this peak or continuous allowed current? I think I can set the error to 200 and that should be more then I really need? Thank you so much.
    Judleroy

  17. #17
    Join Date
    May 2006
    Posts
    4045
    Hi Judleroy,

    That seems like a lot of backlash. I wouldn't expect software backlash compensation to completely solve that. Backlash compensation requires that the backlash is consistent and there is enough friction to stay on the "correct side" of the backlash and the servo doesn't overshoot, etc, etc... But it is worth the try. The Rate value in KFLOP for backlash compensation is simply the linear rate that the backlash compensation is applied. The way backlash compensation works is that when the direction reverses the axis must quickly jump ahead to take out the backlash. If the rate is too slow then the machine path won't be corrected quickly enough and won't be correct. If it is too fast then it may cause a jerk and an overshoot. I don't think there is any method other than trial and error to find what works best. The rate is in encoder counts per second so for example if your backlash value is 100 counts and the rate is 1000 counts/sec the jump will happen over 0.1 seconds.

    Regarding peak current it looks like you are already peaking at about 3.5A. See the attached current plot. You can't really set the current, but rather the servo will command whatever current is required to perform the motion you are commanding. So if you increase the acceleration the required current will increase. There is a Max Output setting to limit the peak current. If the motion requires more current than allowed, the current limit will result in the motion falling behind the trajectory, and a following error will result. I misstated the output range in an earlier email. The Current Command output is 11bits or +/-10bits or +/-1024 counts. So your Max output setting of 200 is 200/1024*35A = 6.8A. SnapAmp can drive up to 15A peak when driving 4 motors. You need to check what your motors will allow safely.

    Regards
    Attached Thumbnails Attached Thumbnails Amps3.5.png  
    TK
    http://dynomotion.com

  18. #18
    Join Date
    Dec 2006
    Posts
    406
    Thanks Tom that clears things up for me.
    Judleroy

  19. #19
    Join Date
    Dec 2006
    Posts
    406
    Alright this is a little off topic from this thread. I am fairly happy with performance and with a little tweaking I think I'll be fine. Now I would like to add home switches. The switches I have are standard lever activated no/nc type. I'm not sure what I need to do to connect them. Do I add +5v and ground then connect to a input or is this a bad way to do things. (basically I'm lost). I see all the inputs and outputs but don't know where power should come from. I will connect them through the 50 pin on the snap amp if I can. Also I need to create a c program for startup. I know I need to paste all the settings from the config screen into a program. Also I need to add the axis enable and coordinated motion setup for the axis I'm using. I would also like to tell it not allow the machine to run until I have homed the axis or if home is somehow lost. Last I would like to know if I can setup software limits so if a program commands a move that is outside of what I set as travel limits the machine will read an error and stop motion. This is to prevent hopefully ever hitting a real limit. Also as an extra protection for me until I add negative limits at a later time. Thanks.
    Judleroy

  20. #20
    Join Date
    May 2006
    Posts
    4045
    Hi Judleroy,

    Regarding Home Switches: SnapAmp has (8) 5-12V opto isolated inputs. So connect an OPTO_PLUS pin to the +12V supply and connect the respective OPTO_NEG pin to one end of your switch. Connect the other end of the switch to GND (the +12V return). Ideally use an separate isolated supply to avoid all the limit switch wiring from picking up noise and injecting it into KFLOP GND but it is not absolutely necessary to use a separate supply. See

    Normally you would need to write a short C program to then Home. User Brad wrote a MasterHome program that might be helpful. By just specifying a few parameters for each axis describing the direction, speed, switch polarity, offset, etc... it should do the rest. I'd like to try it out.

    Regarding Init C Program. Yes paste the axis settings, enable commands, and DefineCoordSystem command into the program. I'm not sure of a way to keep things from moving until you home. Maybe just don't enable the axes in the Init.c program but rather in the Home program, but if you are using Mach3 I don't think it will allow Homing until the axes are enabled.

    We still need some work on soft limits. You can add a "watchdog" loop at the end of your Init program that will continue to run and watch the position. It can then set "virtual" limit bits which the Axis can then be configured to watch. Use the "Disallow Drive Into Limit" Limit switch mode. Something like the code below.

    #define COUNTS_PER_MM 200.0
    for ( ;; )
    {
    WaitNextTimeSlice();

    if (ch0->Position < 10.0 * COUNTS_PER_MM)
    SetBit(48);
    else
    ClearBit(48);

    if (ch0->Position > 300.0 * COUNTS_PER_MM)
    SetBit(49);
    else
    ClearBit(49);
    }

    Regards
    TK
    http://dynomotion.com

Page 1 of 2 12

Similar Threads

  1. Servo tuning
    By ho-229 in forum Laser Engraving / Cutting Machine General Topics
    Replies: 2
    Last Post: 11-11-2011, 04:06 PM
  2. Servo Tuning HELP!!
    By Julian M in forum Servo Motors / Drives
    Replies: 1
    Last Post: 07-18-2010, 01:06 AM
  3. Servo Tuning
    By gbowne1 in forum Fanuc
    Replies: 0
    Last Post: 11-07-2009, 05:31 AM
  4. 6t Servo tuning?
    By Jerry Shorter in forum Fanuc
    Replies: 5
    Last Post: 08-17-2009, 11:28 PM
  5. appropriate servo tuning.... help?
    By howling60 in forum Servo Motors / Drives
    Replies: 6
    Last Post: 02-27-2006, 03:48 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •