586,089 active members*
3,874 visitors online*
Register for free
Login
Results 1 to 8 of 8

Threaded View

  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

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
  •