Hi,
lathe threading has to be done in real time. Any event information, say an Index pulse, were it to be communicated back to Mach4 would take many milliseconds
depending on the refresh rate of the motion control. As an example the ESS default reporting rate is 25ms. Imagine an Index pulse and it takes up to 25ms just to be reported back to Mach4?

But it gets worse. Mach4 makes a decision and then sends out trajectory information to the motion control.....but it has to pass through the motion buffer. Again as an example the ESS motion buffer
is by default 180ms. Thus an Index signal from the machine could take as long as 25 + 180 = 205ms before the machine can respond. Just not going to happen.
Threading must therefore be autonomous within the motion control.....it does not matter whether its an ESS or a Pokeys or a UC300, they all have the same essential characteristics, namely a reporting cycle
of several to tens of milliseconds and a motion buffer of tens to hundreds of milliseconds. Those delays preclude Mach4 from 'doing' the threading, it must be done by the motion controller.
You might reasonably ask then 'Why are there these long delays?'. The Windows OS is not a real time operating system, and never has been. Windows will do a little of this job, then move on to the next job,
until it eventually gets back to the start, and picks up that first job again. If that job is controlling a machine....the machine need continuous service ALWAYS, otherwise it will stutter and stall,
no good for CNC. As a consequence any Windows CNC software must calculate part of the machine trajectory in advance and store it in a buffer for the motion control to 'digest'. Hopefully Windows
can get around to Mach4 again and fill up the motion buffer before it runs out...otherwise the machine will stop with the dreaded 'Run out of Data' message.
So you can shorten the motion buffer, at least with the ESS that I'm familiar with, but you cannot make it zero as that would require that Windows gives Mach4 continuous service.....and that is not how Windows
behaves. I've been told if you have a reasonably powerful PC and very un-cluttered with other software and services you might be able to reduce the motion buffer to 30ms to 40ms. I've never tried it,
I just leave it at 180ms. You can also increase the plugin frequency. By default it is 40Hz, or it sends back data frames to Mach4 every 25ms, but you could increase that to 100Hz or even 200Hz.
What effect it has on the rest of the ESS I do not know.
Even were you to reduce the motion buffer and reporting frequency it would still be something like a 50ms delay between an Index pulse and the machine responding....and that's way WAY too slow
for threading. Delays for effective real time control, lathe threading for example must be a few microseconds, maybe as long as 20 microseconds. Windows PCs cannot do that WITHOUT
some sort of motion buffering.
Each motion control will handle lathe threading their own way, but broadly similarly. In particular they need to be able to measure between encoder pulses (or index pulses) and thereby determine the exact
rotational speed of the spindle. Then they must calculate the advance rate of the Z axis to produce the right pitch, and lastly must use an index pulse to synchronise the start of the thread.
All-in-all its quite a task. For quite some years the UC300 series of motion controls did not support lathe threading at all. In the end they did bow to customer demand.
The bottom line is that single point lathe treading is done and supported by the motion control board. Those boards are proprietary and the software is not open to view or edit. Aside from anything else
most motion controls use an FPGA which is programmed by Verilog or similar software. Most unlikely therefore that you or I could reasonably interpret much less edit or craft our own code.
To my knowledge you have to use what features the motion control manufacturer has provided and live within its limitations.
If that does not appeal then use LinuxCNC. LinuxCNC runs on a specialist Linux distro which is, or at least is very close to, real time. Then you could write your own threading code in C.
Craig