Well, I'm back at this again, now that my "new" lathe work has resumed and headed toward the finish line.... and I've finally got a big stepper mounted on it.
I've had to reverse engineer what I had done before (5 years ago!) -- I have no notes, other than the FORTH program listing, and the surviving breadboard with some connections missing.
Nevertheless, it's beginning to come back.
I already have a working routine and circuit to do the carriage movement while cutting threads. But what I hadn't yet sussed was how to do multiple passes when cutting a thread. Since this lathe gear is strictly intended as an electronic leadscrew, or more accurately, digital change gear, there are some differences to what is possible with a full two axis CNC lathe.
In the case of CNC where a single pulse on the spindle gear gives spindle positional and timing information, and the program sets the leadscrew rotational speed based on the rotational speed of the spindle, the program can automatically retract the carriage, move it to a starting position, and advance the tool and begin carriage movement at the right time to begin a repeat cut. The single pulse gives a reference point. This method of essentially proportioning rotational speeds is especially accurate where the spindle RPM is controlled by servo, VFD, etc. A DC motor like mine would be less accurate for thread cutting if the load changed with a setup like this, though probably accurate enough for home workshop use.
I chose a different route in this project, which is running an encoder on the spindle yielding, after gearing, 3000 pulses per revolution. This is matched by the stepper gearing (plus the leadscrew pitch) to yield 3000 steps per inch. Any non-fractional TPI can therefore be generated by the simplest integer math:
40 encoder pulses per step pulse yields 40 TPI.
27 encoder pulses per step pulse yields 27 TPI, etc.
This is the most basic programming I can imagine for generating the motion needed. But without positional cue, a single pass is all this routine will do. There is no physical connection between the spindle and the carriage. As I imagine it, the only way to do multiple passes in this system is to use the early lathe spindle reversing method. In this case:
1.) manually stop the spindle motor (which will also stop the leadscrew stepper tracking it)
2.) manually retract the tool from the work
3.) reverse the spindle direction
4.) reverse the stepper direction
5.) power the spindle back to the start position manually (jog)
6.) stop the spindle motor
7.) set new tool depth
8.) change spindle direction to forward
9.) change stepper direction to forward
10.) start spindle to cut next pass
Now there are some sophistications possible. Encoder quadrature could be sensed by the Arduino to do its own switching from forward to reverse stepper rotation. Is this worth the trouble ......eh, maybe not. The little board is doing a lot already, at fairly high computational speed, and I've also heard (Pekka?) somewhere that fast quadrature sensing on the fly can be problematic especially if there's electrical interference.
Seems to me that I can reverse stepper direction and spindle direction simultaneously more simply than by asking a computer to figure out when to do that. A DPDT, center OFF switch on the DC motor could stop and reverse its direction. and if I add a diode and link it to the stepper driver's direction input, that would reverse the stepper rotation when needed.
I guess I'd need another switch for doing reverse threads. So that's two switches and a diode.
Other possible sophistications could be to employ the Hall sensor also present on my lathe (for the tach) to give actual spindle position, but I'm not sure just what this would enhance. I'd still have to jog the carriage with the stepper -- I couldn't release the halfnut to move it, or I'd lose carriage position. This is assuming I was somehow trying to sync up the Hall sensor and the carriage. I actually don't see any advantage in complicating things this way.
The other need is for user input of thread sizes. Six bits of information would give me 64 choices. Something like an 8 pin DIP switch would be overkill. I want to keep things as simple as possible -- no display for the board to have to refresh, no keypad to poll, minimal footprint -- just the Arduino and some switches. Besides, a DIP switch looks almost like an miniature automatic change gear lever set on a traditional mechanical lathe. The only problem for me is I wish they were bigger. Of course you couldn't call it a DIP switch properly then!
I guess I could make a bank out of larger single switches. Better still if the looked like levers instead of plain toggle switches!