Setting up Closed Loop Stepper Mode


Results 1 to 18 of 18

Thread: Setting up Closed Loop Stepper Mode

  1. #1
    Member
    Join Date
    Jun 2005
    Location
    USA
    Posts
    1723
    Downloads
    0
    Uploads
    0

    Cool Setting up Closed Loop Stepper Mode

    Tom,
    I have a question, I have watch several videos and read numerous posts on setting up closed loop stepper mode with the KFLOP. I can see you select CLSTEP, and encoder for Input.

    My question is where do you put in the number of steps per unit with the encoder?

    I have the Renishaw LM10 which is 1um, so 25,400 pulses per inch. When I look under KmotionCNC all I see is the actual steps per unit but nothing on the encoder side. I looked in the init.c files and do see it there either.

    Thanks

    Russ

    Similar Threads:


  2. #2
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4043
    Downloads
    0
    Uploads
    0

    Default Re: Setting up Closed Loop Stepper Mode

    Hi Russ,

    Use KFLOP's InputGain0 parameter to match the encoder resolution to the motor resolution.

    Similar to this example with a rotary encoder.
    Closed Loop Stepper

    Regards

    Regards
    TK http://dynomotion.com


  3. #3
    Member
    Join Date
    Jun 2005
    Location
    USA
    Posts
    1723
    Downloads
    0
    Uploads
    0

    Default Re: Setting up Closed Loop Stepper Mode

    Tom,

    Thanks. Now I see where that aspect goes. I could not find anyone who used linear magnetic scales like the Renishaw. Right now I have my servo motors closed loop with their amps and have been driving the amps with Step and Direction. This work perfect on my small machine and I could hold tolerance with .001 with no issue. On my larger 5x5 machine I had to add some harmonic drives which introduced some backlash, probably .010", which is driving me crazy. I decided to get some high quality magnetic scales to see if I can address the issue. The resolution is 1um which is 3.937 X 10-5 inches. This comes down to 24,500 pulses per inch if my math is right. The scales output quadrature differential signals, so do I take 24,500 * 4 = 101,600 for my InputGain0. I see on the example they are diving the actual pulses/rev of the stepper motor, but don't think I would do that in my case. Again, I have not found any example, but know of several people using these magnetic scales with commercial type machines running other controllers. I have seen several people mention they are closing the loop of their servo and linear scale, but again not real example. I have read your comments on the potential problems when you introduce part of the mechanical machine in the loop. My machine is really tight except for the backlash, and I can move the gantry without the gearing reduction smooth enough not even with a 750W servo due to the mass, so that left me with a gearing reduction which on the surface is smooth as glass, but lots of gears have issues as well.

    Thanks for you help.

    Russ



  4. #4
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4043
    Downloads
    0
    Uploads
    0

    Default Re: Setting up Closed Loop Stepper Mode

    Hi Russ,

    Many users have run Closed Loop Glass scales with Step/Dir Drives. It normally works well.

    The closed loop will correct for the backlash, however only after some time. Imagine you are holding a 1ft chain connected to a cart that you are trying to position to within 1inch. Looking at the cart's position you can decide to move your end of the chain right or left to move the cart into position. Note that you must move the cart slowly into position because you have no way of stopping the cart until you fully remove the slack in the other direction. Friction may work well in your favor. You might find it works well until something is pushing and pulling on the cart (ie cutting forces). The result is likely to be much better than if you couldn't see what the cart was doing at all, but not likely to be perfect in all cases.

    Your math looks right except maybe the factor of 4. When they say the resolution is 1um that might refer to the quadrature counts. Its simple to figure it out. Move the axis an inch and see if the encoder changes by 24,500 or 101,600 counts.

    No you would not put 101,600 as the InputGain0. The idea is to put whatever factor necessary to match the encoder to your steps/inch. I don't think you have told us your resolution in motor steps/inch. For example assume your motor steps/inch is 10000steps/inch and your linear encoder is 24500steps/inch. Then use:

    InputGain0 = 10000/24500 = 0.408163

    If you then make a large move on the Step Response Screen you should see that the red and blue plots match closely within any mechanical errors and servo errors..

    HTH
    Regards

    Regards
    TK http://dynomotion.com


  5. #5
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4043
    Downloads
    0
    Uploads
    0

    Default Re: Setting up Closed Loop Stepper Mode

    Opps I think it should actually be 1000 counts/mm x 25.4mm/inch = 25400 counts/inch not 24500

    Regards
    TK http://dynomotion.com


  6. #6
    Member
    Join Date
    Jun 2005
    Location
    USA
    Posts
    1723
    Downloads
    0
    Uploads
    0

    Default Re: Setting up Closed Loop Stepper Mode

    Tom,
    you are correct, my typo'd the count is 25,400

    My servo motors have encoders with 2000 P/R, which attach to a Harmonic Reducer which is 11:1, that attaches directly to a 40mm pitch ballscrew.

    2000 * 11 = 22,000 P/R Now add in the ballscrew: 40mm / 22000 = 25.4mm / X so X = 13,970 Pulses/Inch

    So if I following your guidance I take: 13,970 / 25,400 = .55 so my inputgain0 would be set to .55 correct?

    I am currently figuring out how to attach the read heads to the machine as well as the tape but can lay the tape on the table and connect a temp cable to the read head to see if Kflop is seeing them move. Thanks again for all your help

    Russ



  7. #7
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4043
    Downloads
    0
    Uploads
    0

    Default Re: Setting up Closed Loop Stepper Mode

    Hi Russ,

    That looks correct except for any possible factors of 4 due to pulses vs counts. So verify your numbers by moving 1 inch.

    Regards

    Regards
    TK http://dynomotion.com


  8. #8
    Member
    Join Date
    Jun 2005
    Location
    USA
    Posts
    1723
    Downloads
    0
    Uploads
    0

    Default Re: Setting up Closed Loop Stepper Mode

    Tom,
    I have not physically attached the Linear Scale read head to an axis but laid the scale tape on my table, and connected the encoder head as follows:

    KANALOG Connections
    JP1-Pin 5 Phase A
    JP1-Pin 6 Phase A/
    JP1-Pin 7 Phase B
    JP1-Pin 8 Phase B/
    5V to encoder +5V
    Gnd to encoder 0V

    I tested the power and got my 5V as expected. I can run the encoder head along the tape and the LED turns Green which indicates it is reading the tape. If I check the KFLOP screen for digital IO I can see the second encoder flash on an off when I move the head.

    Right now I have my MPG connected to Encoder 0 position, probably will need to move that when I hook up this stuff for real, so I can keep Encoder 0 for the X axis and Encoder 1 for the Y axis, and Encoder 3 for the Z axis, so I guess I can modify the code and make my MPG encoder 4.

    I wanted to see if the encoder was actually counting up and down when I moved it manually with my hand but can't see any place you can see this on any screen in Kmotion.

    I then when to the configuration page and configured just the Y axis with Encoder Input and CL Step. I also showed the inputgain0 as .55 and saved it and downloaded it into KFLOP. I then went to the step response screen and figured maybe I would see the counts, but nothing. Perhaps this will not work unless it is physically connected to the axis. It will take me a few days to figure out how to make some brackets to mount the heads and tape, but wanted to see if things appear to be working before I went to all that effort.

    Appreciate any guidance, I read the manual over and over and must be missing something again. LOL

    Russ



  9. #9
    Member
    Join Date
    Jun 2005
    Location
    USA
    Posts
    1723
    Downloads
    0
    Uploads
    0

    Default Re: Setting up Closed Loop Stepper Mode

    Tom,

    I went out this morning and setup the encoder head and tape in a temp fashion so I could do some more testing with the linear scale.

    Setting up Closed Loop Stepper Mode-kflop-encoder-step-jpg

    I have PID with I set to .01, I set the 0gain to .55 as calculated then I told it to do a step of 25,400, which should have been the number of counts on the encoder for one inch.

    I don't really understand the plot.

    The red position plot I can see the steps 25,400 at the top, the command plot I don't understand, the numbering on the left looks wrong. This almost seems like I have the A and B phase of the encoder reversed. A little guidance please.

    Russ



  10. #10
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4043
    Downloads
    0
    Uploads
    0

    Default Re: Setting up Closed Loop Stepper Mode

    Hi Russ,

    That looks good to me. The only issue is about a 1 inch difference between the commanded destinations(blue) and the measured positions(red). If you push the "Zero" button they should both start at zero.

    We normally initialize the Axis Destination to the current encoder position with:

    EnableAxisDest(0,ch0->Position);

    The Axis Screen can be used to display the Destinations and Positions for all the Axes.

    You aren't showing the configuration but I'm guessing you are testing open loop as there is no output (green - uses right side scale).

    Regards

    Regards
    TK http://dynomotion.com


  11. #11
    Member
    Join Date
    Jun 2005
    Location
    USA
    Posts
    1723
    Downloads
    0
    Uploads
    0

    Default Re: Setting up Closed Loop Stepper Mode

    Tom,

    I restarted and did everything in Kmotion and did not touch KmotionCNC this time. I enabled the Y axis and then corrected the configuration and then did the following step response.

    Setting up Closed Loop Stepper Mode-encoder-correction-applied-jpg

    This time the plot looks more like what I expected. Both curves are almost directly on top of each other which seems correct. It also has the Green plot showing correction but I am not exactly sure how to read that aspect. I did notice you can watch the axis page and see the encoder count. I forgot to run the test of moving the axis one inch and see if I got 25,400 counts. I think I am starting to get closer. I have not done the rest of the filter aspect, that will come next as soon as I mount the encoders and scales permanently on the machine.

    Russ



  12. #12
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4043
    Downloads
    0
    Uploads
    0

    Default Re: Setting up Closed Loop Stepper Mode

    Hi Russ,

    Looks like you have a few issues. You should make open loop moves first as it is simpler to analyze.

    Feedback appears unstable. Maybe reduce I Gain to 0.001

    Feedback is requiring more than the allowed 200 counts so the Output is saturating and limited

    Position doesn't return to zero after the move. That seems strange. It is even correcting 200 steps but is still off 150 which means a total error of 350 steps. Either you have significant mechanical errors or steps or counts are being lost.

    Regards

    Regards
    TK http://dynomotion.com


  13. #13
    Member
    Join Date
    Jun 2005
    Location
    USA
    Posts
    1723
    Downloads
    0
    Uploads
    0

    Default Re: Setting up Closed Loop Stepper Mode

    Tom,

    Well after your note last night I was almost ready to throw in the towel. Seems I take two steps forward and four steps backwards. LOL

    I setup a dial indicator to see if when I issued a move it was getting back to where it started and indeed it was getting back to zero. I also adjusted the gain to .001 as you recommended and here is the latest plot.

    Not sure why the destination shows -1, but it was set to that when I started up and enabled the axis.

    Setting up Closed Loop Stepper Mode-test2-jpg

    The commanded position and the actual position are virtually right now top of each other. The green adjustment line also looks much simpler, not sure I understand exactly how to read the green line.

    Russ



  14. #14
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4043
    Downloads
    0
    Uploads
    0

    Default Re: Setting up Closed Loop Stepper Mode

    Hi Russ,

    Heh heh. Don't give up you are making progress.

    The Plot now looks more stable. But it is still saturating as the output (green) is still going to 200 (right side scale) and remaining clamped there. The Output is how much correction in Motor Steps the servo is applying to try to correct the error (difference in commanded Step Position and measured Encoder Position). Do you understand this part? In other words there is an error of ~300 Steps (300 / 13970 steps/in = 0.02 inches). But with your Max Output setting of 200 you are only allowing the servo to correct 200 steps so it stops correcting the error. Maybe increase that to 500.

    I see that after the move is complete the output is at about -150. This means the servo is make a correction of 150 steps to the motor position to get the encoder to read 0 (or -1 since that is where you started). That's about 0.01 inches. Do you think your system could have that much mechanical slop?

    I'm assuming when you used the dial gauge you were running the closed loop move in the plot? That shows the closed loop correction is working as it returns to the same place even with so much mechanical slop.

    Like I asked you to do several times now I always prefer to start with open loop moves (Step Dir mode or PID gains zero) to first understand the issues with your hardware and mechanics. In open loop mode the encoder is only used as an observer so you can get insight into issues with your system. You are sort of jumping to the final result which makes it more difficult to understand as the feedback tends to hide the real mechanical issues.

    Its hard to see errors on that scale. You can zoom in or plot errors to see small errors better. Please save and attach the raw data file. That allows us to display the move data however we want.

    Hang in there you'll get it
    Regards

    Regards
    TK http://dynomotion.com


  15. #15
    Member
    Join Date
    Jun 2005
    Location
    USA
    Posts
    1723
    Downloads
    0
    Uploads
    0

    Default Re: Setting up Closed Loop Stepper Mode

    Tom,
    Thanks for your feedback. Yeah, apparently these HD Harmonic drive units are generating about 10 thousands of backlash when connected to my 40mm ground ballscrews. Yes, I understand the correction was limited to 200, that must have been the default since I did not type that into the configuration tool. I have been trying to figure out a different approach as I don't like that much backlash, just very disappointing to buy those expensive HD units with 11:1 reduction and get that kind of result. I was looking to see if I had some high quality belt and gears to setup one axis using the reduction using a belt reduction. My guess is the root of all my issues started with using such rapid ballscrews 40mm pitch, these were used in expensive placement machines, but trying to use them on a CNC machine was probably not my smartest move, but ground screws in perfect condition at a reasonable price. Yes, I used the dial indicator with the correction turned on, understand your recommendation to do several open loop plots to get to the source of backlash, which I am pretty sure is the HD reduction gears.

    Russ



  16. #16
    Member
    Join Date
    Jun 2005
    Location
    USA
    Posts
    1723
    Downloads
    0
    Uploads
    0

    Default Re: Setting up Closed Loop Stepper Mode

    Tom,

    After two days of frustration all ready to pack it in, I came to the conclusion the Harmonic Drives must just be bad, even though they are new. This afternoon I decided to take of the Y axis drive and just spin it with no load to see if it was behaving correctly. Right as I was pulling it off I noticed the end with the coupling started to spin, which is really strange since there is a 11:1 gear reduction. Upon close inspection when they assembled this unit they forgot to install (8) 4mm x .7 screws that attach the face with the shaft coupling to the front of the harmonic drive itself. It was just a friction fit so when the motor would turn it would move the ballscrew sometimes and then it would start to slip. This explain why it was taking so much correction that never really worked. This evening I will remount the unit with the (8) new screws installed and see if it moves things better now. I have three of these units and have never got one with the screws missing, unreal. Well like you said something is WRONG. LOL

    Russ


    Setting up Closed Loop Stepper Mode-hd-img_1506-jpg



  17. #17
    Member
    Join Date
    Jun 2005
    Location
    USA
    Posts
    1723
    Downloads
    0
    Uploads
    0

    Default Re: Setting up Closed Loop Stepper Mode

    Tom,
    After I installed the missing 8 screws on the HD unit, I reinstalled and ran a quick test. Here is the plot.

    Setting up Closed Loop Stepper Mode-hd-fix-jpg

    If I am reading the green line correctly at the end it had to correct 52 steps is that correct?

    Russ



  18. #18
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4043
    Downloads
    0
    Uploads
    0

    Default Re: Setting up Closed Loop Stepper Mode

    Hi Russ,

    Good catch. That's 3~6X better! Yes the final Output correction is ~52 steps or ~ 0.0035 inches.

    Regards

    Regards
    TK http://dynomotion.com


Tags for this Thread

Posting Permissions

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


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

Setting up Closed Loop Stepper Mode

Setting up Closed Loop Stepper Mode