How does a CNC program co-ordinate the tool with the spindle

I am more interested in writing programs than in using my lathe.

I have written code to make my small lathe work as a 3-axis milling machine.

I now have an application where it would be useful to cut a thread (actually a worm for a small motor). The required thread pitch is beyond th range of the in-built lead-screw and gears. But it should be possible to cut any pitch using CNC.

I wonder if anyone knows how a CNC program coordinates the position of the cutting tool with the angular position of the spindle so that each pass of the tool always starts cutting the thread at the same location.

I have not managed to find anything with Google because the phrase "cnc program" inevitably produces GCode examples. What I want is some insight into how the motor control works and position detection.

...R

I don't know a lot.
but it is by using an encoder on the spindle.

try googling "cnc threading"
this might be helpful also:
threading formula's

Hutkikz:
but it is by using an encoder on the spindle.

Yes. But what exactly should I do with the encoder data?

Googling "cnc threading" did not get me anything useful.

...R

I am still in the planning(dreaming lol) stage.

of retrofitting cnc to my small chinese lathe and mill.

so just learning myself.

wish i could of been more help.

I would think this question would best be asked at :

CNCzone

Hutkikz:
I am still in the planning(dreaming lol) stage.
of retrofitting cnc to my small chinese lathe and mill.

I have a Sieg C1. I don't have space for anything bigger or heavier.

...R

if you have a simple tachometer for your spindle, one point, then you have to assume that your other axies never miss steps.

if you have a multiple point encoder, you will need to add an index. this is a single spot that will be zero and will allow the program to know it is at zero.

if you have a greyscale encoder, well, I would be very impressed. but it would make it easier for this app.

the Y axis, your spindle,
your X is your cross slide
your Z is your carriage. to drill you use changed in Z while X and Y are stationary.
odd, but the CNC was developed for mills.

this is the way a lathe is, but if you have it set differently, just know that is how I am describing it.

your Y has unlimited distance. it just happens to be rolled up like a blueprint.
assume you have 200 steps per rotation:

if you start at 0,0,0 and rotate once and you are 200 steps along on the Y
if you move your Z by 1mm, you would be able to cut 1 mm thread.
1mm up the Z, for 1 revolution, = 1 mm thread pitch.

at the end of a rotation, you are 200 steps along the Y,

single point spindle encoder.

if you have a single point tachometer, then you have to time your thread cutting based on RPM.
reports from people using single point on a lathe for thread cutting are pretty promising.
you anticipate loss of steps, so you cut the left most side of the thread (closests to the spindle) first.
and missed steps will have the cutter move into the section of the part that will be removed.
finish cuts are lighter so less missed steps and less aggravation.

time of flight is different way to cut. you know the current speed. you know the distance you need to move in that speed.
need to calculate how many steps are needed per revolution, set your time per step and then pulse your stepper based on time per step.

try googling for ELS or electronic lead screw
and then add arduino or g-code

electronic lead screw g-code

has 44,000 hits

I have the same here plus the matching mill.

Lotsa fun and and as a fabricator they have certainly proven handy.

Been collecting parts for the conversion as I can afford them.

But it's been tight lately so likely next year before I can get to it.

Thanks Dave. That is very helpful.

I found a slotted detector in my box of bits and I am currently gluing it to my lathe. That means I will have single point detection. I could easily increase that to 3 points, but, as you say, then there is a need for a Zero detector.

if you start at 0,0,0 and rotate once and you are 200 steps along on the Y
if you move your Z by 1mm, you would be able to cut 1 mm thread.
1mm up the Z, for 1 revolution, = 1 mm thread pitch.

This I understand.

However as the spindle must be rotating before the tool is positioned I'm not clear how I get the tool in place just as the Zero point on the spindle arrives. And it may be desirable to have the tool moving along the Z direction before it encounters the workpiece.

...R

You got me curious so I found this:
threading on the lathe mach 3

It's for Mach 3 but it does give a brief description of how it works.

Hutkikz:
You got me curious so I found this:

Thanks that is useful. But what I really want is something that explains how the Mach3 code works as far as matching the tool to the workpiece is concerned.

I am trying to write a very basic program that does some of what Mach3 does.

...R