Just FYI, I use galil electronic gearing for rigid tapping and gear hobbing on my CNC mill. It has run flawlessly for years. This approach did NOT work on my lathe. The difference is speed. need on a lathe is to thread at 1000 or even higher RPM.
Lathe approach was first a high speed index mark. used a slot sensor to a high speed opto 22 input. Got response in the area of a few 10EE-6 seconds. Several revolutions are first sampled to accurately determine RPM. Then the X axis is fired on the index mark to move at the calculated feed rate. With this approach total control of a G76 thread cycle works wonders. I had over a month's work just making this thread cycle run.
I haven't had a need for single point threading on the lathe yet, but I have had some down time so I decided to tackle that project. Sorry this is so technical but it is aimed primarily for the very few users that are using Galil Motion Control products to run their CNC machines.
I got the single point threading working and tested last evening, total time spent was about 16 hours programming and testing. Works great. I was prepared for a battle with the spindle indexing, but it turned out the spindle encoder index pulse worked just fine up to 2000 RPM (that was the max speed I tested it at) after I learned how to use and read it. I do have some advantage here in that I am using a DMC-1846 card with the latest firmware rev. This is faster and has some commands available that were not available in earlier cards and firmware, like latching on the encoder index.
First I tried to use the AI (after input) command with IN86 (AUX Z +). Galil allows the AUX encoder + inputs to be used as general inputs, and being encoder inputs they are high speed inputs. IN86 is valid to use with the AI command, but for some reason the program ignored the state of the input and blasted right through that line of code without regard to the state of the input, which I could see changing.
OK, on to plan B, try the input latch (AL) function that can be programed with an ALTn to latch on the axis encoder pulse, in this case Galil B axis is my spindle encoder, so ALTB sets the arm latch function to the B encoder index pulse. The minimum required on time for the pulse is 40 nSec, I haven't checked the on time with a scope, but I'm guessing it is in the 2 mSec range at 1000 RPM so a lot of margin there.
I'm gearing the axes together on-the-fly, using the GD (gear distance) command to ramp into the gear so there is a smooth transition to get the Z axis up to speed, about 0.200 of travel. For testing, the Z start position is set about 3/4 inch off of the part, so the Z is up to speed long before the tool reaches part 0. In normal operation I would set the Z start position at about 0.250.
G code was generated in Fusion 360 using an unmodified Haas post processor. This code will work for internal threads also, as well as pipe threads. If no fadeout is needed, then XZRATIO=0 and ZPOS2 = ZPOS1 and the second line of G code (N24 in this case) is not generated for the threading cycle in the post.
Here is a snippet of a G32 thread cycle G code
N21 G0 Z0.7776 (rapid Z to the start position)
N22 G0 X1.496 (rapid X to the start position)
N23 G32 Z-3.0004 F0.166 (start the operation and move Z to the end of the thread at a feed speed of 0.166''/spindle rev [6 TPI])
N24 X1.5 Z-3.0024 F0.166 (fadeout)
N25 G0 X2.3 (rapid X to clearance)
N26 Z0.7776 (rapid Z back to the start position)
G84 is normally used for rigid tapping and has a couple more parameters that are not needed for single point threading.
Here is the Galil code, assumes that the spindle is running.
#G32;'SINGLE POINT THREADING CYCLE LATHE
'VARIABLES PASSED BY CNC PROGRAM
'
RATIO;'SPINDLE / Z RATIO TO GENERATE PITCH
'
XZRATIO;'X / Z RATIO FOR FADEOUT AT END
'
ZPOS1;'END OF FULL DEPTH THREAD, START FADEOUT
'
ZPOS2;'END OF THREAD
'THE ACTUAL THREADING CYCLE CODE
GAC=B;'ASSIGN SPINDLE AS Z MASTER
GAA=C;'ASSIGN Z AS X MASTER
GDC=5000;'SET Z ENGAGEMENT RAMP DISTANCE
GDA=200;'SET X ENGAGEMENT RAMP DISTANCE
ALTB;'ARM SPINDLE ENCODER INDEX LATCH
#R;JP#R,(_ALB=1);'WAIT FOR LATCH TO TRIP
GRC=RATIO;'SET GEAR RATIO AND ENGAGE Z
MRC=ZPOS1;'WAIT FOR Z TO REACH ASSIGNED POSITION
GDC=0;'CANCEL Z RAMP INTO GEARING
GRA=XZRATIO;'SET GEAR XZ RATIO AND ENGAGE X FOR FADEOUT
MRC=ZPOS2;'WAIT FOR Z TO REACH ASSIGNED POSITION
GR0,,0;'RELEASE X AND Z AXIS
XQ#UI1,7;'NOTIFY THE CNC PROGRAM THAT THE OPERATION IS COMPLETE
EN;'END G32
I didn't have a threading tool set up in the lathe, so I did these tests with a 55° diamond shape tool with a 0.008 radius nose to get a more or less pointy end.
I had the lathe set up for running 1.5 inch bar stock so I started at 6 TPI on a chunk of 1.5 inch aluminum bar @ 200 RPM I just did a 0.010 deep scratch cut and ran 6 passes to see if the it would pick up the previous pass again, it worked flawlessly.
Then I ran the program several times and the only drift I got was from the part moving in the collet slightly when the collet released at the end of the cycle. Then I bumped it up to 400 and then 800 RPM with the same results on the same bar picking up the previously cut thread. Then I did the same test at 24 TPI with the same result. In both cases the thread pitch was perfect as close as I could measure with my thread pitch gauges at 10x magnification. There is no noticeable latency inconsistency in the operation that would have shown up when picking up the thread again.
Then I did a copy & paste to generate a couple hundred cycles of the same cut (6 TPI, 0.010 deep scratch pass) at 400 RPM just to see if the latency was consistent. I'm happy to report that the last pass hit exactly where the first pass cut.
About 15 minutes of repeating the same cut.
This is after a couple hundred passes.
I'm going to say this was a success
Next is to get the spindle indexing working so I can use the live tooling to its full potential doing mill/turn operations.