584,874 active members*
5,187 visitors online*
Register for free
Login
Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2006
    Posts
    45

    Rigid Tapping in KMotionCNC

    I came across this thread https://groups.yahoo.com/neo/groups/...s/topics/10116 on yahoo groups and noticed you guys were trying to get a working C program for rigid tapping in KMotionCNC. Doesn't seem like there was a solution so I figured I'll share what I came up with and hopefully anyone else interested in rigid tapping will benefit from this as well. I started off studying the Mach3 rigid tap program and went from there. A little modification and it seems to work quite well. First a little description of my system's setup.

    The spindle is controlled via an open loop using a 0-10V signal from one of the DACs. The direction is set by switching relays on the spindle drive. There is a CW relay and a CCW relay. There is also a "Spindle Run" relay which enables rotation of the spindle when switched on and disables the spindle rotation when it is switched off. There is an output relay on the spindle drive called "Spindle Zero Speed" which goes high when the spindle speed falls below a certain threshold ( 50rpm or something like that). This lets you know when it is safe to reverse the spindle direction. This is setup as Axis 3. I followed the directions on this page: KMotionCNC Spindle Control to setup my spindle, with slight modifications to the M3, M4, M5 C programs to switch the relays as needed.

    I also have a closed loop axis setup for the spindle as well, however it is never enabled. This is setup as Axis 7. This axis is used purely to sample the position from the spindle encoder. This lets me have actual spindle speed readings in KMotionCNC as well as reading the angular position of the spindle in my C programs by simply using "chan[SPINDLE_AXIS].Position". Note that SPINDLE_AXIS is different than SPINDLEAXIS as SPINDLE_AXIS is the disabled axis used for position reading and SPINDLEAXIS is the axis used for controlling the spindle speed.

    I currently have this setup as M100 and use 3 parameters, not including S for tapping speed. Speed of the tap is defined the same as in an M3 or M4 code using S. P defines the distance per revolution (thread pitch). Q defines the depth in incremental coordinates from current position. R defines the thread direction (1=RH, -1=LH).

    A typical GCode tapping command would look something like this:

    G0 X1.5 Y1.0 Z0.5
    S1000
    M100 P0.025 Q1.50 R1

    Assuming the top of the material stock is set at Z0, the machine would rapid to position, the speed of the tapping operation would be set to 1000 rpm but the spindle would not turn on unless and M3 or M4 code is present and the tapping operation would begin. The tap would go to an absolute position of Z-1.00 ( Z starting postion - Q) with a right hand rotation with a thread pitch of 0.025 inches per thread (40 TPI). Once the bottom is reached the spindle will be commanded to turn off and then reversed back to the starting position. The program is currently setup for inches only however it can be easily modified to check what units are currently being used in KMotionCNC and then use those units accordingly.

    This was my first version but quickly realized a problem. Tapping a through hole would not be an issue however tapping a blind hole would cause the tap to bottom out and break if the depth of the tapping operation is set close to the bottom of the hole. This is because the spindle is commanded to stop after the Z depth has been reached. The spindle's inertia would continue to rotate the spindle for some time and the Z axis would follow as it is and should still be slaved to the spindle's angular position.

    I came up with second version which incorporates an Over Shoot Compensator. The OSC is determined experimentally and is unique to each machine's physical properties. An explanation of how the OSC is determined will be shown in a later post so stay tuned. The input of the OSC (X value or Domain) is the tapping speed in RPM and the output of the OSC (Y value or Range) is the the number of revolutions the spindle makes after the spindle has been commanded to stop. Knowing the number of revolutions the spindle will overshoot with and the pitch of the thread we can determine how far the Z axis will overshoot. We can then take this value and subtract it from the desired depth that way once the spindle turns off the tap will end up at our desired depth. This is assuming your spindle has repeatable overshoot and will be seen when determining the OSC.

    This version was an improvement on the first however it was far from perfect. The biggest issue now is that the OSC is determine without any tapping load induced on the spindle. a #0 tap will produce a very small opposing torque on the spindle, effecting the overshoot very little. A 1/2" tap will produce a much larger opposing torque and will help slow down the spindle faster, creating a significant effect on the overshoot. This adds an unpredictable variable to the mix and is addressed in a third version.

    The third version has two overshoot compensator variables. One defines a deceleration point and the second defines the stopping point. The tapping is initially performed at the desired speed until the Z axis reaches the OSDecel point. At this point the spindle is commanded to slow down to a predefined, creep speed, in my case 100rpm. The spindle will "creep" at a slow rate until the Z axis reaches the OSStop point. At this point the spindle is commanded to stop. The theory here is that the spindle can be stopped from a slow speed much more consistently than from a high speed and because the spindle is decelerated to a predefined slow speed, the user defined speed is irrelevant. Also, the spindle can stop much faster from a slow speed than a high speed thus a varying load on the spindle will have a much smaller effect on the overshoot.

    Looking at the OSDecel equation in the RigidTap C program you will notice that 0.75 is added to the overshoot value. In a mathematically perfect environment this number essentially defines how many revolutions to creep before the OSStop point is reached. This allows time for the spindle speed to stablize at the creep speed. If you are getting inconsistent results increasing this number may help. Decreasing this number will create a smoother transition from Decel point to the spindle being stopped. Setting this number to zero will essentially nullify the use of this technique and achieve similar results as that found in the second version.

    If you choose not to use an OSC then you can set OSStop and OSDecel to 0.

    If you have any questions or need further explanation please feel free to ask.

    I will try to post the explanation for how to develop the OSC equation for your machine later today.

    - Tom
    Attached Files Attached Files

  2. #2
    Join Date
    Oct 2006
    Posts
    45

    Re: Rigid Tapping in KMotionCNC

    Every machine spindle has its own set of physical characteristics and no simple, universal equation can define its behavior. In my machine the spindle is controlled via an open loop thus having precise control over where the spindle stops is not an option. So developing an equation which accurately describes the spindle's stopping behavior will be very useful in controlling the final depth in a rigid tapping program. Some of the variables involved in defining your system's stopping characteristics are the spindle's moment of inertia, the spindle's frictional load and the spindle motor's stopping power ( and/or brake if you have one equipped).

    For those who have a spindle that can be controlled as a closed loop servo this technique will be somewhat inferior. If your spindle can be controlled as a servo then you can use coordinated motion between the spindle axis and the Z axis giving you extremely precise and accurate depth control. This is no longer known as rigid tapping but is rather known as synchronous tapping and is a technique used in high speed drill/tap machines like the Haas DT-1. If you have this luxury then you should develop code to take advantage of your system's setup.

    For those of us that do not have the luxury of controlling the spindle as a servo the spindle will continue to rotate for some time after it is commanded to stop. The hope here is that it is a consistent and thus predictable amount which will allow us to define an approximate equation which will describe the spindle's stopping behavior. Creating an equation is fairly straight forwarding using a program like MS Excel and plotting a number of experimentally derived data points. To derive the data points the rigid tap program is run with a delay implemented when the Z axis reaches the bottom. The delay allows for the spindle to come to a complete stop and enough time for the operator to read and record the overshot value. If the current Z axis position is at -2.00 and the Q parameter (tap depth) is set to 1.00 in the M100 code then the tap should stop at -3.00. However the Z axis will overshoot some. Lets say that the Z axis final resting position is -3.013. The overshoot is .013 inches. This is the number you must record. I have included an Excel spreadsheet to aid in plotting the data onto charts.

    Attachment 277436
    The top table's data points are in units of "inches of overshoot". You will notice that a number of runs were performed over various RPMs as well as various thread pitches. It is not necessary to run the tap cycle at various pitches as the data is normalized in the second table. I ran various pitches just to make sure I was getting consistent results. An alternative would be to run the same pitch but multiple times to ensure you are getting consistent results. I chose to set the max tapping RPM to 2000RPM so I did not record any overshoot with a RPM higher than 2000. On the second table the values in each RPM column are then averaged.

    I created three charts for a visual picture of how the spindle is behaving. The first chart is the overshoot in Inches vs tapping speed in RPM. The second chart is the normalized overshoot in Revolutions vs tapping speed in RPM. The third chart is the Averaged-Normalized overshoot in Revolutions vs tapping speed in RPM.

    Attachment 277438
    This chart shows how many inches the Z axis has overshot at any given rpm between 100 and 2000 at various thread pitches.

    Attachment 277440
    This chart shows the same data as in the previous chart but normalized so that each thread pitch can be directly compared. You will notice that the lines match up very closely which implies that consistent overshoot is being achieved.

    Attachment 277442
    This chart shows the averaged-normalized overshoot for the system. In Excel, right clicking on the line and clicking "Add Trendline" allows you to add a trendline to the chart. Select the trendline type that best fits your data points. For my particular case "Polynomial" of second order fits closest to my data plot. Also setting the intercept to 0 will make the line more accurate as there will be 0 overshoot at a tapping speed of 0 rpm. Make sure to check the "Display Equation on chart" checkbox so that the equation can be seen. This equation is the equation that will be used in your rigid tap program to derived the Overshoot Compensator. By default MS Excel doesn't show enough significant figures in the equation for it to be accurate enough. Clicking on the equation on the chart and going to "Label Options" you can set the number of decimal places to be displayed. Try to use at least 4 significant figures for the OSC.

    After processing the data I have come to the realization that there is a much simpler way to record the overshoot which was not obvious before I analyzed the data and developed the overshoot compensator technique. One could make a simple C program where the spindle is commanded to spin at a given speed and a delay is programmed so that the spindle speed can reach the commanded speed and stabilize. Once the delay has finished the spindle will be commanded to stop. Immediately after the stop command the spindle's angular position is stored into a variable. Another delay is then programmed to allow the spindle to come to a complete stop. The spindle's angular position that was previously stored is subtracted from the spindle's current angular position and is posted to a MsgBox in KMotionCNC. This will give you the number of encoder counts the spindle took to come to a complete stop. This can easily be converted into the number of revolutions by dividing the number by counts/rev that your spindle is configured with. This skips the step of having to normalize the data and is a direct measure (more accurate) of the spindle's angular overshoot.

    Hope this helps some of you out and if you need any help implementing this or if you have any suggestions or improvements then please jump in.

    Thanks,
    Tom

  3. #3
    Join Date
    Oct 2006
    Posts
    45

    Re: Rigid Tapping in KMotionCNC

    I guess this thread wouldn't be complete without a video demonstration. Below you'll find a quick video of my machine rigid tapping 6 holes in a .250 inch piece of aluminum. The first 3 holes are tapped with a #10-32 tap held in a standard ER20 collet tool holder. The second set of holes are tapped with a #10-32 tap held in a Tapmatic Synchroflex rigid tap tool holder. Because no rigid tap system is ever perfect the Synchroflex compensates for any error in the Z axis and reduces the axial stress on the tap. This is said to improve thread quality as well as greatly extend tap life. I tapped with both tools to make a comparison. Unsurprisingly the holes tapped with the Synchroflex have a higher quality thread however the quality isn't so great because I was using taps that were nearing the end of their lives.

    https://youtu.be/yktBL1mhZFY

    Attachment 277492

    Attachment 277494
    Holes on left are tapped with standard ER20 tool holder. Holes on right are tapped with Tapmatic Synchroflex tool holder.

  4. #4
    Join Date
    Feb 2010
    Posts
    371

    Re: Rigid Tapping in KMotionCNC

    Interesting read Tom. Thanks for taking the time to post this. Rigid tapping is something I'd love to implement at some point. I've been considering retrofitting a small bicycle disk brake to the top of the spindle. Something like that would be easy to control and should be able to stop the spindle quite quickly.
    Eric

  5. #5
    Join Date
    May 2006
    Posts
    4043

    Re: Rigid Tapping in KMotionCNC

    Hi Tom,

    Clever idea. Nice video. Thanks for posting.

    I'm curious. Did you make any attempt at operating your Spindle like a Servo? I realize you would need a C Program to control the reversing relay possibly with some logic to avoid switching the relay too soon or often.

    Regards
    TK
    http://dynomotion.com

  6. #6
    Join Date
    Oct 2006
    Posts
    45

    Re: Rigid Tapping in KMotionCNC

    Thanks Eric. I hope this helps you in implementing rigid tapping on your machine.

  7. #7
    Join Date
    Oct 2006
    Posts
    45

    Re: Rigid Tapping in KMotionCNC

    Quote Originally Posted by TomKerekes View Post
    I'm curious. Did you make any attempt at operating your Spindle like a Servo? I realize you would need a C Program to control the reversing relay possibly with some logic to avoid switching the relay too soon or often.
    Hi Tom,

    I never tried running the spindle as a true servo. I only tried running it in a closed loop setup to get better control of the speed but it was tricky to tune with the kmotion tools. Trying to do a move without any of the reversing logic made the spindle behave odd. As an error built up the spindle would over shoot but it would not be able to reverse to return to the commanded position so it would wait for the command signal to catch up and then it would ramp up again and over shoot. In this scenario a tool that would allow to tune an axis via speed command as opposed to a position move would be useful. That or implementing a C program to switch the relays to allow reversing. I just ended up running it in an open loop configuration and use the encoder for tapping and speed feedback for kmotioncnc.

    I'd also be concerned with switching mechanical(assuming they're mechanical) relays as they have a much more finite life than solid state devices. I intend on this being a production machine so I want her as reliable as possible. I am however kind of curious and will probably experiment with it now that you brought up that suggestion when I get some time.

    - Tom

  8. #8
    Join Date
    May 2006
    Posts
    4043

    Re: Rigid Tapping in KMotionCNC

    Hi Tom,

    I would think you could find a set of parameters to work as closed loop without needing reversing logic (until you actually reverse) so you wouldn't wear out the relays any faster than you would otherwise. It may be that the VFD has very slow response to changes in commanded speed. This would make the control very difficult. I would think that you would need to set a fairly low Acceleration such that the Spindle could follow ramping down the speed without needing to reverse. Velocity and Acceleration Feed Forward may also help. Setting those appropriately should basically provide an open loop command to follow the commanded Trajectory without feedback. The servo feedback would only then need to make minor corrections due to variations in load like friction or cutting forces.

    I think if your goal is raw speed then your open loop approach may be the best. It will be hard to beat just slamming on the brakes at the right time But if a more controlled motion profile, that is less susceptible to external variations is the goal, then closed loop might work better.

    Thanks again for posting.

    Regards
    TK
    http://dynomotion.com

Similar Threads

  1. Replies: 1
    Last Post: 07-06-2014, 04:44 AM
  2. Replies: 24
    Last Post: 05-01-2014, 07:02 AM
  3. Replies: 13
    Last Post: 07-04-2009, 12:43 AM
  4. Tapping head or rigid tapping
    By Gregory_C in forum Syil Products
    Replies: 2
    Last Post: 10-18-2008, 06:49 AM
  5. Rigid tapping or tapping head
    By kentavv in forum Charter Oak Automation Support Forum
    Replies: 7
    Last Post: 09-24-2006, 06:08 PM

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
  •