Servo Calibration Mystery

Hello everyone,

Since my last post I’ve modified Mill #2 to reinstall its old, shorter X axis so I could repair the damaged ballscrew on the new X axis but also, more immediately, so I could proceed with calibrating my AC servo.

Long story short, after a few days of trying, success evades me. The cogging that was due to the damaged ballscrew is gone, and this makes the calibration problems on my servo even clearer. So clear in fact that you can see what’s wrong with the naked eye :

(warning, loud phone beep at the start !)

In this video, you’re looking from below Mill #2’s table at the Oldham coupling for the X axis. I am using my pendant to jog back and forth. I mostly do singe detents on the hand-wheel. What you’d see with a stepper motor, for each detent, is the coupling making a really sharp move from one position to the next, with no overshoot and no undershoot. Instead, with the servo, I have this weird overshoot and hunting that’s really, really not what you want to see on a CNC machine tool.

If you’ve ever seen that kind of behavior from an AC servo, I’d very much like to hear about it.

Keep in mind that this servo, especially the drive, are cheap Chinese products. The only alternative I could find for a 600W, 60mm servo is from Oriental Motor and would have cost me upwards of 1,400 euros. The servo you see here cost me less than 300, and I mostly bought it for testing before committing too much money to servos. I have no doubt that it’s up to snuff, really the difference in price comes mostly from a complete lack of support from the manufacturer, including proper documentation.

Initially I didn’t see that as a problem because I know servos, so I thought I could find my way through the poorly-translated “Engrish” user manual. Turns out this is going to take me a lot more time and effort than I expected… and there you have the difference in price. Good thing I don’t have a customer expecting quick results : for once, time is on my side.

The problem at this point appears to be a rather high ratio between load inertia and motor inertia, however the manual’s Engrish is way too bad for me to even detect if there’s a way to measure it and adjust. There has to be, or this drive would just be useless… I simply haven’t found it yet.

The drive that was sold with this servomotor is from a brand called “KRS”, and they are very popular on eBay and Chinese online stores, so I have to assume it’s actually possible to make them work correctly. If you’ve ever used such a Chinese drive, do get in touch with me. If you’re interested in these drives, stay tuned : whenever I manage to get this one working, I’ll definitely post about it.

This entry was posted in CNC and tagged , , . Bookmark the permalink.

39 Responses to Servo Calibration Mystery

  1. tsiroto says:

    Hello!
    I have the same servo motor and drive.
    Here is the most recent manual v3.1 (older versions missing some settings)
    http://wenku.baidu.com/view/60d4696ce2bd960590c6777c?fr=prin
    Is in chinese but auto translators such as google translate and bing translator do very good
    translation from chinese to english.
    I have not connected my servo yet.
    Can you give me some tips how you setup it and running ?

  2. tsiroto says:

    Also here is older version V3.0

    Click to access Servo-drives.pdf

    https://www.sendspace.com/file/fnykdn
    First of all you must set up parameters Pn000 Pn001 Pn002
    especially Pn001 should be set to value 2 ( 60st_m01930 motor).
    I have powered my servo and run it in jog mode from driver menu (Fn002)
    but i have connected with pc yet.
    Can you give me some help with pc (linuxcnc/mach3) connection ?
    What extra hardware must get ? I have one breakout board for parallel port
    and have the skills to do my own circuits/pcbs .
    Can give me some help ?
    thanks.

    • nefastor says:

      Thank you for the manual, Tsiroto, this looks interesting. I don’t use Mach3 or LinuxCNC but I will use the RS485 port on my servo (connected to a microcontroller). I will be posting about it. If I learn how to make these servos work without “hunting” for their final position I will certainly post how I did it.
      I’m pressed for time this week but expect to hear from me very soon.

  3. tsiroto says:

    RS485 is a very slow bus.
    This connection is ok for settings but not for controlling the servo in real time.
    The DB25 port has step/dir input analogue -+10V and feedback quadrature incremental rotary encoder output for closing the loop to controller.
    I don’t think that a uC can output step/dir pulsetrains at 500khz that servo needs
    and read feedback from encoder.
    For these frequencies/timings asic/fpga chips is best suited.
    The best open/free controller with real time capabilities is linuxcnc with some extra hardware
    for generation of high frequency pulsetrains and reading encoder (parallel limited to 50khz).
    The servo is very good (good value/money) from reviews that i have read in chinese from taobao (chinese ebay) overshoot will be resolved with the right settings.
    And for me this is the first servo.
    Iam waiting more news from you..

    • nefastor says:

      Indeed the RS485 and microcontroller is for setting up and monitoring the servo’s parameters. This is my first KRS drive so I want to be able to “fiddle” with it, and I’m already tired with the four buttons and LED display. I need something more flexible.
      You’re correct about the (in-)ability of an MCU to generate 500 KHz step pulse-trains but that’s not the topic : if you’re interested in FPGA-based motion control we may discuss this outside this post, it’s something I’ve had on a back burner for a while.

  4. tsiroto says:

    I have downloaded the v3.1 pdf from chinese site
    You can download it here : https://www.sendspace.com/file/wub1u5

  5. tsiroto says:

    Hello!
    Can you make a post how you set parameters in drive with rs232 or RS485 ?
    Iam interrested in this because the litle 7 segment screen is boring.
    I have a usb-> rs485 board and simple max232 rs232 board
    but to change parameters i want suitable software what software you use ?

    • nefastor says:

      I’ve determined that this type of AC servo drive is not suitable to my machine tool : assuming it’s even possible, it’s too hard to set it up to have good performance (resolution) at very low and very high speeds at the same time. I’m now considering using closed-loop stepper motors. I didn’t use existing software, I made my own, for an LPC1768 MCU and Android. It’s possible I’ll continue this project as it can be adapted to also setup spindle VFD’s.
      At this point I would NOT recommend using KRS servo drives for anything other than speed and torque control. Position control is just too unreliable and poorly documented.

  6. tsiroto says:

    Why you say that ?
    With a fpga card from mesa like 4i24 / 5i25 / 6i25 and linuxcnc with realtime kernel
    you can control this servo with outer closed loop in linuxcnc.
    The servo can controlled from internal pid or external pid (linuxcnc).
    Reatime external pid with linuxcnc & fpga mesa card is perfect solution.
    Can you post details how you set parameters with LPC1768 MCU and Android ?
    Iam very interested in that.

    • nefastor says:

      I bought this servo because it was cheap. Adding a COTS FPGA board and external encoders defeats the purpose and will also take longer to integrate. It’d be easier at that point to just spend all that money in one spot and buy a true, high-quality AC servo system from a reputable manufacturer like Harmonic Drive or Oriental Motor.
      Remember the KISS rule, my friend.
      My work on Android and LPC1768 is not destined to be open source, I’m sorry 😉 maybe in the future ?

  7. tsiroto says:

    Also i did a manual test in position mode with an mpg 100ppr (quadrature rotary encoder 100ppr)
    Settings in servo: Pn02 -> 2 , Pn096 -> 2 & Fn01 to save changes after that i did power cycle
    to load new settings. I connected A -> pin3, A’ -> pin14, B -> pin4, B’ -> pin5 (A,A’,B,B’ are from mpg and 3,4,5,14 are from servo cn2 connector).
    After that i rotated the mpg and with 25 turns servo rotates 2π (full cycle).
    I have very accurate movement no overshoot no undershot.
    I can make so little movements that very is very difficult to check them with eye…
    I have tested in position mode with quadrature signal not step-dir but you can convert step-dir
    to quadrature easily.
    I did this test at very low speeds so i don’t know if has the same accuracy at high speeds..
    Maybe you have a noise problem.. or you driving signal is problematic(check with quadrature signal). I have read very good reviews for this servo.

    • nefastor says:

      The servo was very precise BEFORE I mounted it on a mill : the problem comes from the fact I can’t tune it for the inertial load the mill presents. The ratio between the mill’s rotational inertial and the motor’s rotational inertia is high enough it really needs tuning, but I simply can’t find the parameters for it and I don’t have time to play with it.
      So for now I’ll be using closed-loop stepper motors.
      When I have time I’ll build a test bench for this AC servo and study it in depth, but right now I can’t justify investing the time. That’s life : performance being the same, you got to use what’s easiest to use.
      And there’s definitely no problem with noise or anything like that : I always test new equipment on a proven machine tool so that the new equipment is the only new variable. I’ve tested many different motors on this machine tool, some didn’t even have differential inputs. Can’t be noise.

  8. tsiroto says:

    You are correct.I have tested before without load.
    I put the servo under load and makes a small oscillation before stabilize.
    I understand that is difficult (if impossible) to tune internal pid parameters with that crappy manual.
    But with linuxcnc and a mesa fpga card can do the pid in linuxcnc not in the drive with feedback to linuxcnc. In linuxcnc the pid tunning is more versatile and easy to do with more tune parameters
    and monitoring.
    When you have time can make a post how you change parameters with Android and LPC1768 ?

    • nefastor says:

      I’m guessing the oscillation you’re seeing is the same as on my video. That’s the evidence that the load / motor inertia ratio hasn’t been tuned for. From what I’ve read in the manuals of more expensive servo drives, there is a procedure to tune that, but on the KRS it’s really not straightforward.
      I don’t like the idea of having to put a PC in the loop to get a servo to work : a servo with a dedicated drive unit like the KRS should be a stand-alone system.
      If I can’t manage to set it up, I’ll just open the KRS drive and hack the firmware. I expect there’s an MCU and an FPGA or CPLD in there, I should be able to find my way around. But that’s a time-consuming project and I have better things to do in the foreseeable future.
      If the KRS drive wasn’t so cheap I’d just abandon the idea, but with better firmware this has a lot of potential. I’d never put a PC in the servo loop, though : PC’s aren’t hard real-time computers and aren’t crash-proof.

  9. tsiroto says:

    You don’t need external encoders if you make closed loop with linuxcnc.
    CN2 connector has output with motor encoder quadrature signals.
    And fpga card is not very expensive costs about ~100eur.
    With that cost (275 each servo + 100 fpga both including shipping) i think is a great deal.

    • nefastor says:

      I see what you mean. I wanted to use the CN2 outputs to measure position in real-time while I was calibrating the servo. It’s not a bad idea but really, a PC is not real-time capable, I wouldn’t use one as part of a servo loop.
      275 + 100 brings this close to the price of a Delta ASD-B2 AC servo system. If I wanted to spend that money, I’d go with the Delta : read its manual, it includes procedures for load inertia tuning and has a lot of additional features you won’t get with a KRS + FPGA combo.

  10. tsiroto says:

    Generally speaking pc is not realtime but linux has a realtime time kernel and linuxcnc is written for that realtime kernel and can do realtime with pci fpga card for stegens and encoder reading.

    • nefastor says:

      real-time happens to be my job, so I could tell you in detail why Linux real-time kernel isn’t what engineers call “hard real-time” but this is far beyond the scope of a blog comment. Just trust me on this : if you’re going to machine for hours and days at a time, you really don’t want a PC to take care of your servo loops. It might work, but you wouldn’t sleep well at night 😉
      Hard real-time starts at the hardware level, and PC mainboards and processors just aren’t designed with the necessary features. To an OS like Linux, “real-time” means video playback. To someone like me, “real-time” means constant response time to interrupts. It also means you can’t use processor caches. Huge difference. Like I said, this could fill several books (and in fact it does).
      I guess in the end it depends what you want to achieve : if you’re making a CNC mill for DIY projects that you’ll only use twice a month to make cheap parts that you can always do again if you fail, then PC-based “real time” is acceptable. If you want to make a professional machine tool that must work 24/7 and never fail, then you can’t use PC hardware.
      Look at the big professional CNC, they use dedicated hardware and EtherCAT, not PC’s and Ethernet.
      Which brings me to ask you : what’s your goal ? Do you want to make a simple machine for non-critical use or a professional machine ?

  11. tsiroto says:

    Check appendix A for parameters in pid tunning also the manual has a lot of parameters if you
    have time to play with.
    I understand that you can not share your work with Android and LPC1768 for setting parameters of servo. Can you give me a tip with commands from serial terminal to change the parameters ?

    • nefastor says:

      Sure. You can’t really use a terminal, the commands are meant to be sent from a PLC or computer program, they aren’t not “human readable” (MODBUS protocol). Simplest solution is to use something like Dev-C++ and your RS485 adapter to write some code to communicate with the servo drive. From there, you’re only limited by how good a programmer you are. Me, I’d be limited to command line style, I’m not the best GUI programmer ever…

  12. tsiroto says:

    I know java programming.
    I will not have problem with c/c++ but i need the communication protocol.
    For rs485 connection i will use a lib.
    Have you used termination resistor 120ohm for the rs485 connection ?
    Servo has configurable the pid by some PnXXX parameters.
    I will ask and some chinese users which tuned these servos to explain me the procedure.

    • nefastor says:

      The protocol is MODBUS, it’s easy to find the specifications online, it even has a Wikipedia page.
      I had considered asking Chinese users for help but I do not speak Chinese.

  13. tsiroto says:

    Also before connection have you set some parameters in servo drive
    to enable rs485 function ? If yes what are these parameters ?

    CNC machines rarely have only 1 servo if the machine has more than 1 servos
    you can’t based at the servo drive controller because it not have look ahead capability.
    The feedback must go to a master controller so the master controller will have all the data to synchronize all axis movements.

    • nefastor says:

      I don’t remember the parameter numbers on hand but if you check the manual you’ll find there are a few that control which port is used (RS232 or RS485) and things like baud rate and bus address. Also remember : on RS485 the 120 ohm terminators are mandatory. Use Google to find the recommended wiring practices, RS485 is so common there’s a lot of info out there.
      Multi-axis motion controllers don’t work the way you think. RS485 is way too slow and laggy to allow for positioning information to be used the way you suggest.

  14. tsiroto says:

    I have connected with rs485 (Pn64 -> 2,Pn65 -> 1,Pn66-> 5,Pn67 -> 7)
    And found how to read and set PnXXX parameters with QModBus software
    funtions:
    Read Holding Registers (0x03)
    Write Single Register (0x06)
    Write Multiple Registers (0x10)

    But what function must use for read/write FnXX and DnXX parameters ?

    For servo pid config i will ask the manufacturer http://www.cnyfdz.com/

    • nefastor says:

      Good find, I didn’t even know what their website was 🙂 Please share if you learn anything from them, given how many shops sell these servos I’m sure a lot of people will be interested !

  15. luc says:

    I am thinking of buying 600w KRS servo sets for indutrial point to point machine. I have good experience with servos. Beside the tuning what do you think of the KRS sets?

  16. giancarlo says:

    hello, my name is Giancarlo, I bought the same driver.
    I have a 3 axis cnc.
    use mach3
    but I can not control them
    can you help?
    this is my email giancarlo.braschi@alice.it

  17. nefastor says:

    Hello Luc, sorry I didn’t see your comment sooner. I believe we discussed this in the comments of my YouTube video. Have you bought this servo, in the end ?

    • luc says:

      Hello Jean
      I bought the servos but did not tried them yet. The the machine is not finish. I will let you know as soon as i try them, in 3 to 4 weeks i think.
      Have a nice day

  18. nefastor says:

    Giancarlo, I’ve just replied to you in the comments of my YouTube video. Let me know how it turns out !

    • giancarlo says:

      Hello. thank you
      I can not run them with Mach3 ….
      to other evidence. then if I fail I also step in a kit stepper.
      and study more deeply calmly.
      thanks again

  19. giancarlo says:

    last question.
    I just connect only pulse- pul + dir + dir -? or I have to connect the rest?

    • nefastor says:

      If you’re using a controller with single-ended outputs, then no, it’s slightly more complicated than that. Do you have the manual ? There are schematics on how to connect these signals in the manual.

      • giancarlo says:

        good morning
        you have the manual, I was able to connect with a “line driver” and now the motor rotates in one direction, but I can not drive it with Mach3.
        I think you have to set the parameters, but I’m not good ….
        if anyone can help, that would be great
        thanks Giancarlo

  20. giancarlo says:

    Hello!
    I managed to set the driver.
    now work well on my cnc milling machine with Mach3
    now to me, gave the problem you have.
    I did research on the internet.
    I found that a problem could be bad data signals from the parallel port.
    to control the signals we want an oscilloscope. I have not.
    But I have a breakout board usb.
    I mounted the usb and when changing direction no longer creates the problem like the one you have.
    then he was not the measure that was writing programs than would then marked Mach3 screen.
    I solved it by setting the parameters and pn16 pn17.
    I tried to give the example parameters of example pn16: 25, pn17: 8
    and so the change direction works perfectly.
    Now that move right now is the time to handle the speed, today I try using the parameters “electronic gear”
    I keep you updated
    ciaoo
    I hope I have been of help

    • nefastor says:

      Very happy to read about your progress, Giancarlo. I’m working on something else at the moment but I am interested in any solution you find. Good luck, my friend !

Leave a comment