Author Topic: Revisiting a DIY Arduino/Forth Electronic Leadscrew Project  (Read 11160 times)

Offline vtsteam

  • Full Member
  • ****
  • Posts: 1252
Revisiting a DIY Arduino/Forth Electronic Leadscrew Project
« on: February 08, 2026, 05:09:09 PM »
I'm way down a rabbit hole of trying to resurrect an electronic leadscrew project for my lathe that I started maybe ten years ago. I stopped at about 95% completed, having written partially working code to drive an arduino and stepper in FORTH, and a partial schematic -- and naturally did not document much of what I'd done. :Doh:

After more than a day of reading, testing, and reconfiguring, and basic head scratching I've finally got the FORTH code working to move the stepper in response to a 600 line encoder, and a set of 6 thread setting switches and an internal thread lookup table. And I've got the electronic bits and pieces hooked together. But there are still some problems I have to work out, and it's absorbing all my time trying to do that.

Presently, I want to be able to reverse either the direction of the spindle or the direction of the leadscrew independently with two switches and have them still maintain register -- which is tricky. Right now the Arduino does sense the direction of the encoder rotation (using interrupts and quadrature) and branches according to what it finds to setting the stepper direction.

That would work for conventional toward-the-headstock screw cutting, and powered backing to the start point for a deeper cut, while maintaining registration. But I can imagine that it might be convenient to feed in reverse while the spindle is rotating in the forward direction -- not for screw cutting, just auto feeds. I dunno, maybe that's not important. It would simplify things right now if I didn't have to try to make that work. Opinions, please, is there any reason for doing that?

(btw.... I know that now electronic leadscrew modules are more readily available compared to the situation ten years ago when I started all this, and also yes I know alternatively I could just add a conventional CNC computer and software to drive the screw cutting. BUT, I want to finish my project for the pure satisfaction of having done it my way, and having it work. Plus I have no room for a CNC computer in the tiny shop. Besides I like the way I'm going to physically implement it -- so it looks pretty much like a conventional change gear box -- with six lever switches taking the place of the usual gear levers.... just an aesthetic thing. )

Anyway, here's a pic of my test setup as it was before adding a set of dip switches for test setting TPI.

If I get everything running successfully, I'll put up the FORTH code and some notes on how I did the whole thing, as well as (I hope) showing it working on my DIY lathe.
« Last Edit: February 08, 2026, 05:25:53 PM by vtsteam »
Steve

Offline vtsteam

  • Full Member
  • ****
  • Posts: 1252
Re: Revisiting a DIY Arduino/Forth Electronic Leadscrew Project
« Reply #1 on: February 08, 2026, 05:41:54 PM »
Just a few pics of the switch and leadscrew control box I made for my lathe -- made from 4" PVC pipe that I softened in boiling water, bent, and glued together. Last pic is of the switches installed.
Steve

Offline vtsteam

  • Full Member
  • ****
  • Posts: 1252
Re: Revisiting a DIY Arduino/Forth Electronic Leadscrew Project
« Reply #2 on: February 08, 2026, 05:45:05 PM »
btw.... ya know, one doesn't necessarily need a 3D printer to make complex plastic shapes....(though I do own one!  :Jester:  :stickpoke:)
Steve

Offline vtsteam

  • Full Member
  • ****
  • Posts: 1252
Re: Revisiting a DIY Arduino/Forth Electronic Leadscrew Project
« Reply #3 on: February 15, 2026, 04:51:36 PM »
After over a week of work trying to re-engineer what I'd done in software, I've finally managed to get my program and gear working well enough to take iot out to the shop and temporarily connect it to my lathe and stepper motor. It's all still laid out across the bench, not the neat unit I envisioned, but I was able to get the leadscrew turning after making a coupler for the encoder, and a bracket to support it.

I also had to set up a DPDT center-off switch in my spindle motor controller (a treadmill MC-60) to allow me to reverse direction of the spindle. That is how I will back off for each pass during thread cutting. Finally, I was ready to try this rig out. I chucked up a piece of scrap aluminum, and set the switches for 13 TPI. Then took a light pass. Below is the first cut on my homebrew ELS!

Very excited about that -- only one slight flaw in the ointment...... it was a perfect 14 TPI groove. Um guess I need to subtract one from a loop index somewhere in my code! Probably forgot that zero is a number.  :Doh:
Steve

Offline Jasonb

  • Full Member
  • *****
  • Posts: 11263
  • Surrey, UK
Re: Revisiting a DIY Arduino/Forth Electronic Leadscrew Project
« Reply #4 on: February 15, 2026, 05:02:42 PM »
Having tested a lathe last year with a factory fitted ELS it is a nice feature to have.

The cost of the electronics these days from the likes of Aliexpress hardly make it worth doing your own thing and there are a lot of features and any sensible thread pitch or feed rate you want be it left or right hand. You can buy the same system as fitted to that lathe for very little money.

Running in reverse is useful to cut away from a shoulder but if you are able to set a length on your homebrew system then not really needed.

<a href="https://www.youtube.com/watch?v=tB7MaCHxQQ0" target="_blank">http://www.youtube.com/watch?v=tB7MaCHxQQ0</a>

Offline vtsteam

  • Full Member
  • ****
  • Posts: 1252
Re: Revisiting a DIY Arduino/Forth Electronic Leadscrew Project
« Reply #5 on: February 15, 2026, 05:46:03 PM »
One can purchase a pre-built model engine there as well.  :LittleDevil: 

Jason,  :cheers: I found it very much worth doing to build my own lathe, and the ELS for it -- assuming it works in the end. Of course, yet to be proven!  :Lol:
Steve

Offline vtsteam

  • Full Member
  • ****
  • Posts: 1252
Re: Revisiting a DIY Arduino/Forth Electronic Leadscrew Project
« Reply #6 on: February 15, 2026, 09:25:09 PM »
 I did it, WooHoo!!!!!!!!!  :pinkelephant: :pinkelephant: :pinkelephant: :cartwheel: Just cut a 3/8" - 16 on my lathe, without change gears. I just used an ordinary insert, not a screw cutter, but it was a 60 degree type, so I figured it would be good enough for a trial cut. It actually did quite well.

Turned out my earlier problem wasn't in the code after all, it was just personal dumbness. Checking the switches (which were hidden since the gearbox was upside down on the bench) they were actually set to 14 TPI. So the ELS had done what it was supposed to, after all. That kind of mistake will be solved mounting the project all together onto the lathe, now that I know it works.

I'm really happy! I should have called this an electronic change gear project, rather than an ELS because I don't intend to do more than cut threads and set fine feeds with this unit. For ten years, up until today my lathe has been purely manual, with no leadscrew drive at all, and no gears.

When I first built it, I decided I didn't want to make change gears and a banjo, etc. for it. The intention was to use a variable speed DC motor for the spindle, and a stepper driven leadscrew, while retaining manual capability. I do enjoy turning the cranks on a lathe, generally. But for finest finishes, and thread cutting, the electronic changegear will be a very handy addition now!

BTW, I can cut both imperial and metric threads with it. And it works by positional encoder feedback, not single pulse magnetic switch feedback, so it is accurate no matter if there are speed changes. Which is important for a DC motor drive. In fact I can move my spindle by hand forwards and backwards and the leadscrew will track perfectly, just like real gears when engaged. It senses spindle direction and reverses in sync automatically. If I want to cut left hand threads I can reverse the relationship between spindle and leadscrew directions with another switch.

Again extremely happy today -- this has been a VERY long time coming....

Photo, first screw cut, 3/8" - 16:
Steve

Offline Kim

  • Global Moderator
  • Full Member
  • *****
  • Posts: 9560
  • Portland, Oregon, USA
Re: Revisiting a DIY Arduino/Forth Electronic Leadscrew Project
« Reply #7 on: February 15, 2026, 10:27:07 PM »
Congratulations!   :cheers:
That is a real accomplishment!  And so very satisfying that you designed it and wrote all the code yourself.
Nicely done!  You should feel quite proud about this!

Kim



Offline vtsteam

  • Full Member
  • ****
  • Posts: 1252
Re: Revisiting a DIY Arduino/Forth Electronic Leadscrew Project
« Reply #8 on: February 16, 2026, 03:18:01 AM »
Thanks, Kim! I can't tell you how psyched I am about this!  :cheers: :cheers:
Steve

Offline MJM460

  • Full Member
  • ****
  • Posts: 1718
  • Melbourne, Australia
Re: Revisiting a DIY Arduino/Forth Electronic Leadscrew Project
« Reply #9 on: February 16, 2026, 05:04:37 AM »
Well done Steve.  A truly exciting and wonderful achievement.

I really admire you for not only making your own lathe but also following through with this excellent feature.

Now to add the stepper motor and encoder to the cross slide travels.

MJM460

The more I learn, the more I find that I still have to learn!

Offline vtsteam

  • Full Member
  • ****
  • Posts: 1252
Re: Revisiting a DIY Arduino/Forth Electronic Leadscrew Project
« Reply #10 on: February 16, 2026, 04:13:41 PM »
Thanks kindly MJM460!!  :cheers: You know I have thought about that, but every time I think about it I see a big bulk of a stepper motor hanging off of the action end of the cross-slide, and it cuts into the available travel, reduces stiffness, is hard to allow it to freewheel, and just generally gets in the way of hand cranking. And I don't want to loose that capability. I see my lathe as a manual lathe.

I've had a similar but lesser problem considering if I can add a DRO scale to the cross slide. I do have one for the carriage in place already. But adding anything to the cross slide tends to interfere with range of travel by interference at the tailstock, or by extending too far out of the back of the lathe and hitting the back wall of the bench. I may still figure something out there...

If I were to purposefully design a CNC lathe, it would be quite a different design in many respects. If I had the shop room for an additional lathe, that would be an interesting project with some definite appeal for me. But as things stand now I'm working in a 6' x 8' space, so this one lathe was designed to be a very solid compact benchtop 9" x 12" lathe to fit the space. The leadscrew stepper motor is tucked underneath the headstock, so doesn't interfere at all, or reduced benchtop space.

It drives the leadscrew vial a toothed belt, and I can see an immediate need to make that easily detachable for manual cranking. Presently it isn't, and cranking now has the resistance of turning the stepper motor.

I'm thinking of getting a longer belt, and adding a retractable idler pulley to the back of the ways so I can release the stepper belt.

Likewise I'll also want a way to release the encoder, since it runs at motor speed, which is 5 times spindle speed, and there's no need to add wear to its bearings when the lathe is used manually.

But these are both refinements.
« Last Edit: February 16, 2026, 04:25:50 PM by vtsteam »
Steve

Offline Jasonb

  • Full Member
  • *****
  • Posts: 11263
  • Surrey, UK
Re: Revisiting a DIY Arduino/Forth Electronic Leadscrew Project
« Reply #11 on: February 16, 2026, 04:39:41 PM »
I suppose it depends on how your lathe is configured. The one I tried had the stepper driving the lead screw and you had to have the half nuts engaged to make use of the ELS functions, otherwise carriage was moved by the wheel on the front and the rack on the bed.

However if you have a permanently engaged leadscrew like my Unimat3 then I can see the benifit it being able to disengage the motor. The belt idea sounds best as any form of dog clutch could introduce lost movement.

Are you now stuck with the set thread pitches allocated for the switches or is there a possibility of allocating one for non common pitches that a bit of rewriting could set up? Again the one I tried had all the common metric & Imperials but you could also enter a pitch to about 5 decimal places which would work for things like BA or Pipe threads.

One of the reasons I have not put a DRO on my lathe is the problem with it clashing with tehtailstock. If I ever do it then it will be a magnetic tape and small encoder on the underside of the cross slide.

Offline vtsteam

  • Full Member
  • ****
  • Posts: 1252
Re: Revisiting a DIY Arduino/Forth Electronic Leadscrew Project
« Reply #12 on: February 16, 2026, 07:31:09 PM »
Hi Jason, thanks.  :cheers:

The pitch values are set up in a software lookup table which I set up, and can be extended very easily. The limiting factor is the number of pitch value switches -- I presently have 6 of them so there are slots in the software table for 64 possible values.

I've used up 46 of those with the common pitches I chose and three fine feed rates, so I have space for 18 more without adding another switch.

While Using the lathe, choosing a pitch is just like setting a DIP switch, except in this case they are individual toggle switches so easier to see and work with.

Adding more pitches in software is pretty easy, but not instantly doable from a front panel display on the lathe. To add pitch values I would just type those numbers into my program's lookup table via a text editor (the program is just a .txt file) and upload it to the Arduino in the lathe "gearbox". This is done with a simple USB cable from my laptop. It takes seconds to upload a different version of the program.

The "fineness" which I can work with in this setup with a 600 line encoder, and a 5 to 1 motor to spindle ratio is 3000 lines per spindle revolution. Of course my real life mechanics are not going to be producing anything like that precision at the thread. The 5 digits of precision you mention for pitch entry would be unrealistic... for my lathe, at least! Maybe Dan Gelbart....

Personal quirks: I wanted my faux "gearbox" housing to look kind of like a quick change type traditional gearbox where you set levers for the pitch, and you read the settings from a brass plaque table on the box, rather than a digital display and keypad. I imagined going so far in this silliness as to add small brass levers over the toggle switch bats to make them a little more like levers -- but I'm not there yet.

re. leadscrew and half-nut: On my lathe there is no rack or wheel. Just the leadscrew and a ball handle at the tailstock end. The stepper motor shaft extends out at the opposite end of the lathe from under the headstock, and now has a cogged belt to a pulley to a short leadscrew extension parallel to it. So yes, the half-nut must be engaged to move the carriage, and presently the leadscrew is always connected with the stepper -- hence why I want to add a longer belt and idler to make it easy to remove the belt.

Before I finished the ELS I had simply left the belt off all the time. Oh also another change I will need is to get rid of the ball handle in favor of a solid wheel with removable handle -- to avoid catching anything when the leadscrew is turning under power. I was watching that yesterday and thinking, gee I'm glad I didn't have my usual clutter sitting there at that end.

Present pitches I have programmed in:


« Last Edit: February 16, 2026, 09:19:47 PM by vtsteam »
Steve

Offline Jasonb

  • Full Member
  • *****
  • Posts: 11263
  • Surrey, UK
Re: Revisiting a DIY Arduino/Forth Electronic Leadscrew Project
« Reply #13 on: February 16, 2026, 07:37:59 PM »
Ah, I was thinking one toggle = one pitch but sounds like you can use a combination of toggles to get a lot more pitches. Just like two gearbox levers A-B-C and 1-2-3 will give 9 different pitches.

Your setup is like ly little Unimat which also has the handwheel on the left so definately worth being able to disengage the stepper.

Offline vtsteam

  • Full Member
  • ****
  • Posts: 1252
Re: Revisiting a DIY Arduino/Forth Electronic Leadscrew Project
« Reply #14 on: February 16, 2026, 08:41:36 PM »
Yup, that's right Jason. I should include photos just to show what I'm talking about -- here's the headstock end of my lathe with the leadscrew extension and stepper location under the headstock.

And the second photo is my fake "gearbox: housing with the switches, wiring and the tiny computer that does it all -- an arduino nano type. You can see a pencil in the photo for size comparison. The computer is dwarfed by the wiring to it, and the "gearbox is cavernous.

I'll neaten this stuff up and secure it before installing. It's easier to connect a USB cable to it while it's loose -- you can just see the mini USB connector at the bottom of the board for sending it programs. This board cost I think $4 -- I think I got 3 for $12 ? -- can't remember.
Steve

 

SimplePortal 2.3.5 © 2008-2012, SimplePortal