Lathe - Electronic Lead Screw

A servo-driven lead screw using Arduino to calculate proper spindle and lead screw speeds for cutting English and metric threads with VFD.

Apr 23, 2019

64064 views

70 respects

Components and supplies

1

Arduino UNO

Tools and machines

1

Crimp Tool, Heavy-Duty

1

Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires

Project description

Code

leadScrewV1

arduino

LeadScrewV2

arduino

With rapid mode

LeadScrewV2

arduino

With rapid mode

leadScrewV1

arduino

Downloadable files

Spindle VFD Schematic

Spindle VFD Schematic

Spindle VFD Schematic

Spindle VFD Schematic

Servo Controller Schematic

Servo Controller Schematic

Comments

Only logged in users can leave comments

Anonymous user

2 years ago

i wont 3 pace motor invetr plis help me

Anonymous user

2 years ago

I'm concerned that 1 Pulse/rev may not provide the spindle positional resolution needed. It assumes there will be sufficient inertia in the spindle and drive assembly to hold revs sufficiently constant.

Anonymous user

2 years ago

Hiya Nick, i am a newbie to this forum. Having a bit of trouble navigating thru this ELS project cos I cant find a manual or guide for using it, nor a list of features etc. How fast can the leadscrew be run (rpm)? Is it a pain to get spindle vs leadscrew ratio correct so that, say, 8 tpi = 8 tpi.? Re the extra bits of improved code, is that all incorporated into Ver. 2 with rapid mode? Any chance of an improvement using an encoder? Or, is there an off-the-shelf ELS turn-key solution?

Anonymous user

2 years ago

Has anyone come across these Arduino replacements https://www.aliexpress.com/item/32989749596.html?spm=a2g0s.9042311.0.0.1ebc4c4dkd32hF when configured they run twice the clock speed of the normal Arduino Nano, there is a youtube video that tests them and they do run at 32MHz when configure properly, these may be what you need to get more features in the code.

Anonymous user

2 years ago

Do I change to[ point 05] or [ 0 point 5 ] or [ 5] from 1.00 I previously commented out 2 - Delay(5) in loop code, but since I don't have a stepper attached , I don't know if that will cause a problem. This did make a big difference... spindle @ approx 400 Ratio=1 LStpi=16 405 408 410 Stepper 405.41 408.16 410.96 408.16 most stable Spindle @ 194 195 196 197 198 Stepper 195.44 196.08 or .72 197.37 198.02 changes approx 2 seconds I was seeing +/- 10 in these ranges I'm thinking the speed control on my HF 7-10 may be contributing, I would like to feed the 45 gear pulses into the speed control, but that will probably require a different control board. Let me know on the longdelay value and I will uncoment the Delay(5) and try it. Is there any reason for the Delay(5)?

Anonymous user

2 years ago

I want to detect the 45 pulses from the gear and 1 index pulse, then when count of pulses =45, a index should be present, after electronic sync of course. That way I will know if the spindle lost a count slipped etc, probably over kill, however this still does not mean that the lead screw has not missed a step etc.....Getting 1 pulse is becoming an issue for me, no reliable sensor or pick off point.. Still waiting for the china pickups.......

Anonymous user

2 years ago

what lines of code do I comment out to remove the debounce, I'm using forked IR sensor and see no dropout and little jitter... [ 1 pulse / rev]

Anonymous user

2 years ago

I have connected a Ir sensor to sense a flag for the RPM. Checking with scope at max RPM flag is 1.5 us... The Arduino RPM display jumps all over the place, I'm asuming I'm over running the Arduino. The max stable seems to be around 1500 RPM, Has anybody else checked their max RPM?? ALSO the RPM has a tendancy to jmp +/- 10 rpm any body else see this? It may be the HF lathe variable speed jittering. My homemade reluctance pickup works like a champ. It is connected to INA128 {instrumation amp} and max3095 rs485 Quad rec. I see no dropout on scope, but don't think ARDUINO will handle it.

nsr5058

2 years ago

The debounceDelay variable may need to be reduced to read higher RPM's. (See the discussion above.) Try Changing line 13 of the code from long debounceDelay = 1.00; to long debounceDelay = 05; What speed was the RPM jumping was it +/- 10 at 100rpm or +/- 10 at 1000rpm? Let me know and I will double check mine. Nice that you made a reluctance pickup but I agree, you would need a better micro controller than arduino to handle that.

nsr5058

2 years ago

Change the debounce time to 0.5. you have to eliminate the if statement in the speed sensor loop. So you could change the speed sensor loop to something like this. I did not run this code but it should look something like this. void speedSensor() { time = millis(); int currentSensorState = digitalRead(SensorPin); if (currentSensorState != lastSensorState) { sensorState = currentSensorState; if (sensorState == LOW) { calculateRPM(); // Real RPM from sensor if (currentX == 0) { englishCalc(); } else if (currentX == 1) { metricCalc(); } } } lastSensorState = currentSensorState; lcdRPM = RPM; } I'm not sure why your RPM readings vary so much does the lead screw respond to the change in RPM's on the spindle?

Anonymous user

2 years ago

Nick; Debouncing is only necessary for mechanical switches. Optical and magnetic switches don't bounce when changing state. The debouncing code on your rpm sensor signal processing, although not necessary, won't hurt, but you are wasting cpu time, ram and flash space. The debouncing code will also limit the maximum rpm you could successfully read in your case (since you are only reading one pulse per revolution it won't hurt either, but it will if somebody tries to port your code while using a high ppr rotary encoder). The fact that there might be others doing it this way does not legitimize the use of debouncing in this case. Good job on your electronic gearbox!! Thanks for sharing!

nsr5058

2 years ago

I changed the speed sensor loop to run without debouncing. It does work when the lathe motor is off but when the lathe is running I get EMI. So actually in this case debouncing the speed sensor signal is necessary.

nsr5058

2 years ago

Thanks for the info. I will try changing the code and if it works well I will revise!

Anonymous user

2 years ago

Why do you need a debounce on an electronic speed sensor..??

Anonymous user

2 years ago

The reason the original author of the code used debounce was because in the code you linked to in one of your replies, the author was using a reed switch as a pickup sensor. Nothing to do with anything else you mentioned. This is what happens when you copy paste code and and have either not checked it or don't know any different.

nsr5058

2 years ago

I changed the speed sensor loop to run without debouncing. It does work when the lathe motor is off but when the lathe is running I get EMI. So actually in this case debouncing the speed sensor signal is necessary because we need to double check that the speed sensor signal was generated as I stated before.

nsr5058

2 years ago

The electronic speed sensor sends a pulse like a momentary push button. Since we are measuring the time between pulses we need to double check that the signal was generated. See the debounce example for more info https://www.arduino.cc/en/tutorial/debounce I actually grabbed that part of the code from tony here is his writeup. He explains it very well and it worked seamlessly. https://www.hackster.io/TonyScarp/arduino-ir-lathe-tachometer-500733

Anonymous user

2 years ago

i got an error message i.e #include <LiquidCrystal_I2C.h> so pleasde help me

yuke123

2 years ago

Same for me

yuke123

2 years ago

if anything to solve this problem please tell me ......

Anonymous user

2 years ago

Nick, well done! i have built a russian sourced ELS but untested as yet.. It controls the crossfeed as well, so U can prog the no. of cuts & depth of cut per pass. It is synched with an encoder. Uses a Mega. Physical positioning of its bulky control panel is a bit of an issue! But the only proper way to do it is with a heavier duty processor that is fast enough to do the calcs on the fly. See Clough 42, Utube, seems the way to go, as the stepper is stepped very evenly for each rotation, (not in bursts). - Clough's coding is way beyond me, as is yours! Not as sophisticated as the Russian unit. There is also another with a touch screen, using a mega also. Almost every known thread type is included.

Anonymous user

2 years ago

I was quite pleased to see and read this project, I have entered this world, precisely to finally learn CNC, having been a machinist for fifty years, introduced to it, on paper tape, in high school, but working manual machines all my life. I've got my own machine shop, I'm retired from the Marines, and do research and development, and I was very pleased to see the comment, "if I'd known, I'd have gone to Nema 24". These are issues one only finds when doing a job, a bit too much for "what I thought would do". I've got three lathes of similar size, and one, while being a 1946, is in practically unused condition, and set aside for exactly the project I just read. Thanks for giving me the foundation, and some important information. I'm glad to finally be on a site I can learn what I want to know. Semper Fidelis, John McClain

Anonymous user

2 years ago

I would like a video on how to handle this project. Regards Janek

Anonymous user

2 years ago

Great project! I’ve got the same lathe, and the gear change is a pain. I’m not sure I understood your comment about not stopping the stepper motor to maintain registration with the spindle. Are you inferring that it is possible to machine the thread in multiple passes without resorting to the stepper motor position encoder? Thinking about this a bit more, I believe you can cut a thread with multiple passes like this, assuming the thread pitch is advanced for every revolution. 1) Set the cross slide cut depth 2) start the stepper motor feed 3) At the end of the thread, stop or slow feed if you are creating a shoulder 4) here’s the important part, use the stepper motor to move the carriage to the start location Repeat. The important part was to always use the stepper motor to move the carriage. Is that correct?

nsr5058

2 years ago

For the most part yes, you are correct. When I am threading I leave the spindle on and I do not change direction. I leave it run and disengage/re-engage the carriage like you would normally do with the lever and the dial. The problem is, if you stop the lathe to check the threads you get everything out of sync. So if you go to cut threads you need to make sure you know the exact depth and do it right the first time. If I am cutting critical threads I will go back to the gear system since all you have to do is take off the pulleys and put the gears back on. I am thinking of adding a timing light indicator to use instead of the dial so you know when to engage the carriage based on the timing of the spindle .

yuke123

2 years ago

I am getting a code Problem ... Arduino: 1.8.13 (Windows 7), Board: "Arduino Uno" sketch_oct24b:6:10: fatal error: LiquidCrystal_I2C.h: No such file or directory #include <LiquidCrystal_I2C.h> LiquidCrystal_I2C.h: No such file or directory

yuke123

2 years ago

Sir, I have a doubt that you have to add only one motor in the code, but we have add two motors for the machine, which means that we have to add 2 axes to the machine. Can you explain this?

Anonymous user

2 years ago

Great Job. I startet with the same idea and then i have build a complete CNC Lathe Calculating the steps using a encoder with 1024/rev http://www.hsm-ebs.de/Drehbank_CNC_Umbau/Story_Drehbank_CNC_Umbau.htm Reguards, JS

Anonymous user

2 years ago

Amazing!!! Just what I was looking for. I have aBOxford lathe that has lost the gears. BUt, one question. Once I start the lathe and it works out leadscrew speed, when I stop the lathe I cant change the direction of the leadscrew, it just says OFF. I am using my normal spindle motor with an LM393 speed sensore on pin 2.

Anonymous user

2 years ago

Excellent code for button flag setting!!

Anonymous user

2 years ago

Isn't there a possible problem with sampling the spindle speed only once per revolution?

Anonymous user

2 years ago

Hi, am a newbie to this forum. Having a bit of trouble navigating thru this ELS project cos I cant find a manual or guide for using it, nor a list of features etc. How fast can the leadscrew be run (rpm)? Is it a pain to get spindle vs leadscrew ratio correct so that, say, 8 tpi = 8 tpi.? What type of encoder is use? - Cant find how to contact Nick directly either.

Anonymous user

2 years ago

What we found with my ELS ( mailto:E-LeadScrew@yahoogroups.com ) was that 1 PPR is more than adequate for high quality threading as long as several issues are addressed. 1. The pulse has to be long enough for your software to capture the edge and then verify that it's a real pulse and not noise. We usually suggest about 5 to 10 degrees for the slot used with say an opto-coupler. Magnets and Hall Sensors seem to work well just because the magnet itself is about 5 degrees wide. Depending on where it's placed (distance from center). 2. That the lathe spindle speed is steady. A standard lathe with AC motor or even three phase and VFD is remarkably stable and threading rarely puts a heavy load that could slow the spindle down. So one is better off spending the money on a good motor to keep the cutting speed stable. Having said that about speed, my ELS code does two things. With the assumption that the spindle speed is steady it averages it out over several turns. That prevents the display of RPM or SFM from bopping around. Second if there is a general slowing down of the spindle (or speeding up) I added code that tweaked the speed of the carriage. That was to deal with Sherline Lathes that aren't that stable for speed. Where the 1 PPR system does suffer is that once you start cutting a thread at say 300 RPM you cannot change your mind and pause threading, change speed to 600 RPM and expect the tool to enter the previous thread. The reason is simple. With 1 PPR and a carriage that is stopped, the index pulse tells the system where the spindle is. The acceleration up to speed for a stepper motor is generally fixed to be as quick as the stepper can handle without dropping steps. From a stopped Z axis stepper to the point it's up to speed is a fixed time interval and is repeatable. So if the index pulse triggers the Zmotor start, then the spindle will have turned Y amount. once the stepper is up to speed and is turning at the desired ratiometric speed to the spindle. Since this is repeatable, if the spindle is turning 300 RPM, the tool bit will always be at the same spot once it's accelerated up to speed. But change the RPM and the acceleration of the carriage remains the same but the spindle will have turned twice as far. Now the Z axis also needs to be turning twice as fast but unless you are cutting a lead screw pitch thread where spindle and Z axis turn the same speed they normally won't be at the same spot as 300 RPM. BTW, knowing that stuff about fxed acceleration, makes it also possible to cut multi-start threads with my ELS. John

Anonymous user

2 years ago

It's an old video done with a video tape camera. I really should make a new one. https://youtu.be/qu0GToSvnxk Turning to the correct diameter usually let's you know what the correct RPM is. If you are running MACH3 CNC you have the same issues since it also used 1 PPR. The goal of the ELS over

Anonymous user

2 years ago

10 years ago was to provide threading on old lathes with minimal costs. That meant 1 PPR and a single motor on the carriage. The ELS included the micro-stepping driver which at the time and a price of $200 for the kit was a bargain. Now with far east stepper drivers and multi-line encoders along with belts and pulleys the cost of adding threading to an old lathe has dropped. For my South Bend Heavy 10L though, the cost of belts, pulleys and an encoder still reach well over $100. Just not worth it compared to 1 PPR.

nsr5058

2 years ago

Qtron, You can contact me directly at nsr5058@gmail.com I would be happy to help. Nick

Anonymous user

2 years ago

Hi, I’m putting together some junction boxes for domestic lighting using RS own brand DIN terminals in a suitable enclosure (home automation later would favour grouping the wiring into a limited number of JBs with space to accept relays later). One thing that came to mind was to do with these: https://ca.famaga.com/catalog/rs-pro/korpusy-stojki-shkafy They are the special DIN terminals that have a screw operated clamp to the DIN rail which claims to provide electrical continuity. How might I decide if these would provide suitable and reliable continuity for the circuit CPC on say a circuit protected by a C10 RCBO? Or do you reckon they are just fine? Points I’ve considered: Reliability – these clamp to a plated steel rail – so providing the plating holds and the rail does not corrode, then OK Clamping action seems positive. Contact resistance: haven’t attempted to measure yet, but I suspect it would be off the bottom of the range of my Megger. Fault current – worst case scenario: hundreds of amps but no more than 1kA for a very short time. There is a little leeway in that the circuit is RCD protected, but I feel it would be bad practice to factor that in as a key design consideration. What do you folk think of such devices? Many thanks,

Anonymous user

2 years ago

Thanks for the reply. Whilst 1PPR is simpler it means you've got to get the spindle RPM correct before you start threading. That's not always easy with some "difficult" materials.

dougal

2 years ago

Really Brilliant - well done, made for a small fraction of the cost of a commercial unit. I suppose the next step is multi-start threads but I think you will need encoders as you have already said. The commercial item you where initially looking for is called an "electronic gearbox" or "electronic gearing". PARKER HANNIFIN electronic servo drives include systems for them.

Anonymous user

2 years ago

Hi ,hoping there is a more accurate , correct wiring diagram I could follow ? Cheers Nick

Anonymous user

2 years ago

Very well done! A word of warning however, if you're using a single magnet for rotational speed detection, you will see odd things happen. When you start to cut the rpm will drop but you won't "see" that for 1 rpm. Typically, people use 60 slot wheels with optical sensors OR you could use a hall effect sensor that would "see" the teeth of that gear wheel next to the magnet.

Anonymous user

2 years ago

I agree with Dougal, I think you've created an electronic gearing system rather than an electronic lead screw. When I google "Electronic Lead Screw" the first hit is my web page http://www.autoartisans.com/ELS/ and if you join the Yahoo E-Leadscrew group formed about 12 years ago there is a huge amount of information so you don't have to re-invent the wheel. Learn from our mistakes. https://www.youtube.com/watch?v=qu0GToSvnxk&t=21s If you wanted to take it one step further the BeagleBone Black runs MachineKit ( a port of LinuxCNC) and with a multi-line encoder creates a full featured CNC lathe for the price of a BBB and some sort of breakout board cape. All the other costs for motors, pulleys etc. remain the same no matter what approach you use. Still congratulations on getting your motor to move. Quite the thrill isn't it.

nsr5058

2 years ago

Thank you. Yes you’re right this is more of an electronic gearbox. There are no canned threading cycle features like the one you referenced. I purposely decided to stray away from any CNC functions and keep it simple for this application. Many bench top lathes like mine do not have the rigidity and require ball screws for full blown CNC. Now if I had a more stout larger lathe I would be more inclined to take it a step further.

Anonymous user

2 years ago

Hi I need some help totally confused about how to wire in the serial LCD screen cannot see any 5 volt power feed on the servo control schematic struggling to understand why screen is wire as shown (HELP)

Anonymous user

2 years ago

Code says : The stepper speed calculations are based on the lead screw threads per inch ( in this case 8TPI), the synchronous belt gear ration ( in this case 1.529), the micro steps (in this case 400), and the RPM. Where does 1.529 come from??? 22T / 14T = 1.571 ????

Anonymous user

2 years ago

Hi xtal1011 lets try and keep things simple, the formula for your example becomes 400/60 as everything else cancels out or is irrelevant. The result of 400/60 is 6.66666 these are pulses to the stepper per second which equates to 1 Rev Per Minute, multiply the steps by 60 (60 seconds in one minute) and you get your 400 steps (400 steps in one minute = 1 RPM if you double step a 200 step motor) the command stepper.setSpeed(-stepperRPM); requires a value of steps per second. 400 steps per second will rotate the stepper shaft at 60RPM. so your calculations are correct, you are not doing anything wrong - I made the same mistake as you, it was only when I looked at the stepper.setspeed() command more closely that the penny dropped.

stro38

2 years ago

Hi thank you once again sorry to trouble you, altered line 142 to: stepper.setSpeed(-1*stepperRPM); but still having problems noticed red led on stepper driver when I tried CCW with non rotation.. Anyway great sketch and thank you for the effort you put into it

stro38

2 years ago

Hi I have sorted out the problem. I was using a 2 metre long cable with 7 wires from my control box with the power 24 v and the dc dc converter 24 v to 5 v and the stepper driver wires all to my arduino small control case with lcd which must have disrupted the pulses to pul and dir so I put a shielded twisted pair and everything is ok now...really pleased

stro38

2 years ago

Hi thank you, managed to complete the setup everything works great cutting right hand threads. Small problem cannot get ccw or if I reverse the motor connections cannot get CW despite the correct reading on the LCD change. So at the moment I can cut right hand threads but not left hand and if I wanted to cut left hand or feed left I have to change the stepper motor winding's over. Any idea what the problem is I have checked my circuits out and all seem Ok

Anonymous user

2 years ago

Thanks Howard... Next Q ? Is the sensor pulse positive pulse or negative pulse ?? I'm assuming positive....

Anonymous user

2 years ago

I'm totally confused about the StepperRPM: For test sake: using EnglishCalc Spindle RPM=1 Lead Screw = 16 TPI .0625 pitch USE Thread TPI = 16 .0625 pitch I think the pully ratio would be 1 ???? Now this seems to me that the spindle speed will match the stepper/Leadscrew speed I can't make it work. StepRPM = [Ratio * LS-tpi * Steps/rev] / Thread-tpi * 60s StepRPM = 1 * 16 threads * 400 steps 16 threads * 60s ---------- ------ / --------------- inch rev inch StepRPM = 6400 threads steps 960 threads s ------------------ / ------------- inch rev inch StepRPM = 6400 threads steps inch 6.666 steps ------------------ * -------------- ===>>> -------------- inch rev 960 threads s rev s This does not compute for me, What am I doing wrong?????????

Anonymous user

2 years ago

I'm totally confused about the StepperRPM: For test sake: using EnglishCalc Spindle RPM=1 Lead Screw = 16 TPI .0625 pitch USE Thread TPI = 16 .0625 pitch I think the pully ratio would be 1 ???? Now this seems to me that the spindle speed will match the stepper/Leadscrew speed I can't make it work. StepRPM = [Ratio * LS-tpi * Steps/rev] / Thread-tpi * 60s __________1 * 16 threads * 400 steps__16 threads * 60s StepRPM = ----------------------------- / --------------- ___________inch_________rev_________inch _______6400 threads steps___960 threads s StepRPM = ------------------ / ------------- ________inch_____rev_____________inch ________6400 threads steps__inch______________6.666 steps StepRPM = ------------------ * -------------- ===>>> -------------- ________inch_____rev___ 960 threads__s_______rev___s This does not compute for me, I would expect 400 steps, What am I doing wrong?????????

Anonymous user

2 years ago

This did not post properly but I get 6.6666 steps/rev s 6.6666 is a log way from 400

nsr5058

2 years ago

If you are talking about the stepper drive, it is wired positive.

nsr5058

2 years ago

For the gear ratio I can see your confusion. I did not use the # of teeth to calculate the gear ratio. I used the actual pitch diameters of the sprockets. The gear ratio of 1.529 is calculated based on the pitch diameter for the 22t and 14t sprockets which are 2.6in and 1.7in respectively. 2.6/1.7 = 1.529.

nsr5058

2 years ago

Try changing line 142 From this, stepper.setSpeed(-stepperRPM); To this, stepper.setSpeed(-1*stepperRPM); I will check my working code tonight....

Anonymous user

2 years ago

I may have taken a wrong look, but nowhere did I find the function of each push button and toggle switch. Find out by pressing the buttons anyhow, is not a good way. On the other hand, something important bothers me and prevents me from carrying out this assembly : Memorizable right and left stops are missing, which allow precise and secure stopping without breaking everything ! (ex internal threading)

Anonymous user

2 years ago

This is much of what I was looking for. I've a Craftsman Altas 109 with a partially stripped, weak half-nut, and missing a few change gears., I also have a $50 2000ppm encoder, an arduino, a stepper, and a driver. It might be nice to extend your code with an encoder and add both a virtual thread indicator and virtual half-nut. If you keep track of the spindle position with a quadrature encoder, you could track the relation between the leadscrew and spindle as a virtual thread indicator, leave the physical half-nut engaged and have a virtual half-nut that engages on '0' and switches to some jog mode otherwise. The Craftsman 109 doesn't have a feed control separate from the leadscrew, just disengage and push. Thanks.

Anonymous user

2 years ago

Hello. I am Polish and do not speak English - I use Google translator. A great project. My lathe is a small machine from 1960. But wanting to do it needs more data such as which button in the diagram what is it What is the switch for. The program is written for turning inch and metric threads. I only make metric threads. I also have a problem with the code - how is the translation of spindle revolutions calculated into the revolutions of the lead screw? Thank you very much for your help.

stro38

2 years ago

I liked your simple ELS just for screw cutting and feeds and this what appeals to me. I would like to put a rotary encoder instead of the hall effect sensor and create a closed system. The mechanical fitment of the hardware is not a problem but the arduino code is my nemesis, therefore if I fit the rotary encoder what code do I have to write in the script. I have a super mini Warco 180. I would be very much obliged if this can be done

Anonymous user

2 years ago

I have a concern that 1 pulse/rev isn't going to be enough when cutting the coarser threads.

stro38

2 years ago

Hi really liked your project I would like to fit a rotary encoder instead of the hall effect speed probe and have an enclosed system could I respectively ask if you could help with the alterations to the sketch...many thanks, excellent project

Anonymous user

2 years ago

Hi xtal1011 I am assuming you are talking about the pulse from the hall effect switch for RPM, this is a positive pulse. Next challenge is to try and use a rotary encoder off the lathe main shaft, my feeble attempts are proving fruitless at the moment, but, who knows?

Anonymous user

2 years ago

My Lathe is cheapo HF 7-10

Anonymous user

2 years ago

I too having feeble attempts.. Tried LJ8A3-2-Z/BY and BX inductive proximity sensors, I though I would pickup the 45 teeth on my spindle , These sensors are to sensitive to gap , they are either on or off....I was planning to plug 1 tooth gap , to have a index ref... I was trying to find a reasonable cost variable reluctance sensos,, They want a arm and leg for them, years ago they were dirt cheap, some Univac printers & key punches used them.. Ive ordered some tooth sensors [Hall] from china [2 wk wait] , may or may not work. So now will try to make a reluctance sensor, waist of time I'm sure , but I have lots of idle time.....

Anonymous user

2 years ago

10P Nail with magnet on nail head and coil next to nail head. Sine wave type signal from 45 tooth spindle gear. the faser the speed the greater the amplitude, I saw little noise, signal will have to be conditioned for aduino. I think I can temporary block 1 gear slot, then detect the enlarged timeframe as Index and use the other pulses for speed control, probably over kill , A lot of ELS seem to be using 1 index pulse. .......|coil| <<<Nail<{}Magnet] .......|coil|

Anonymous user

2 years ago

Found a coil 3/4 in long 3/8 dia with center hole the size of a 10P nail. The coil measures 50 ohms, fine coated green wire, looks like what I used to hand wire ic's with, small pencil type tool and wrap wire around IC pins then solder thru insolution. Anyway coil measures 50 ohms. I hand held very close to gear and it appears to work very well. I just have to now figure how to mount, which may be a biggee... Noedymium magnet 1/4 dia approx 1/4 long. I have some wire wrap bobbins I may also try. looks very promising..... Of course mounting is still a problem.....The faster RPM the higher the output... .......|coil| <<<Nail<<<<<<<<<<][Magnet] .......|coil|

Anonymous user

3 years ago

Nick, well done! i have built a russian sourced ELS but untested as yet.. It controls the crossfeed as well, so U can prog the no. of cuts & depth of cut per pass. It is synched with an encoder. Uses a Mega. Physical positioning of its bulky control panel is a bit of an issue! But the only proper way to do it is with a heavier duty processor that is fast enough to do the calcs on the fly. See Clough 42, Utube, seems the way to go, as the stepper is stepped very evenly for each rotation, (not in bursts). - Clough's coding is way beyond me, as is yours! Not as sophisticated as the Russian unit. There is also another with a touch screen, using a mega also. Almost every known thread type is included.

Anonymous user

4 years ago

Very well done! A word of warning however, if you're using a single magnet for rotational speed detection, you will see odd things happen. When you start to cut the rpm will drop but you won't "see" that for 1 rpm. Typically, people use 60 slot wheels with optical sensors OR you could use a hall effect sensor that would "see" the teeth of that gear wheel next to the magnet.

Anonymous user

4 years ago

I may have taken a wrong look, but nowhere did I find the function of each push button and toggle switch. Find out by pressing the buttons anyhow, is not a good way. On the other hand, something important bothers me and prevents me from carrying out this assembly : Memorizable right and left stops are missing, which allow precise and secure stopping without breaking everything ! (ex internal threading)

DaveX

4 years ago

This is much of what I was looking for. I've a Craftsman Altas 109 with a partially stripped, weak half-nut, and missing a few change gears., I also have a $50 2000ppm encoder, an arduino, a stepper, and a driver. It might be nice to extend your code with an encoder and add both a virtual thread indicator and virtual half-nut. If you keep track of the spindle position with a quadrature encoder, you could track the relation between the leadscrew and spindle as a virtual thread indicator, leave the physical half-nut engaged and have a virtual half-nut that engages on '0' and switches to some jog mode otherwise. The Craftsman 109 doesn't have a feed control separate from the leadscrew, just disengage and push. Thanks.

yuke123

4 years ago

Sir, I have a doubt that you have to add only one motor in the code, but we have add two motors for the machine, which means that we have to add 2 axes to the machine. Can you explain this?

russkinch

4 years ago

Amazing!!! Just what I was looking for. I have aBOxford lathe that has lost the gears. BUt, one question. Once I start the lathe and it works out leadscrew speed, when I stop the lathe I cant change the direction of the leadscrew, it just says OFF. I am using my normal spindle motor with an LM393 speed sensore on pin 2.

yuke123

4 years ago

I am getting a code Problem ... Arduino: 1.8.13 (Windows 7), Board: "Arduino Uno" sketch_oct24b:6:10: fatal error: LiquidCrystal_I2C.h: No such file or directory #include <LiquidCrystal_I2C.h> LiquidCrystal_I2C.h: No such file or directory

Anonymous user

4 years ago

Great Job. I startet with the same idea and then i have build a complete CNC Lathe Calculating the steps using a encoder with 1024/rev http://www.hsm-ebs.de/Drehbank_CNC_Umbau/Story_Drehbank_CNC_Umbau.htm Reguards, JS

Anonymous user

4 years ago

i got an error message i.e #include <LiquidCrystal_I2C.h> so pleasde help me

yuke123

2 years ago

if anything to solve this problem please tell me ......

yuke123

2 years ago

Same for me

Anonymous user

5 years ago

Hi ,hoping there is a more accurate , correct wiring diagram I could follow ? Cheers Nick

Anonymous user

5 years ago

I would like a video on how to handle this project. Regards Janek

jmarl2

5 years ago

Hi I need some help totally confused about how to wire in the serial LCD screen cannot see any 5 volt power feed on the servo control schematic struggling to understand why screen is wire as shown (HELP)

Anonymous user

5 years ago

i wont 3 pace motor invetr plis help me

weecabin

5 years ago

Great project! I’ve got the same lathe, and the gear change is a pain. I’m not sure I understood your comment about not stopping the stepper motor to maintain registration with the spindle. Are you inferring that it is possible to machine the thread in multiple passes without resorting to the stepper motor position encoder? Thinking about this a bit more, I believe you can cut a thread with multiple passes like this, assuming the thread pitch is advanced for every revolution. 1) Set the cross slide cut depth 2) start the stepper motor feed 3) At the end of the thread, stop or slow feed if you are creating a shoulder 4) here’s the important part, use the stepper motor to move the carriage to the start location Repeat. The important part was to always use the stepper motor to move the carriage. Is that correct?

nsr5058

2 years ago

For the most part yes, you are correct. When I am threading I leave the spindle on and I do not change direction. I leave it run and disengage/re-engage the carriage like you would normally do with the lever and the dial. The problem is, if you stop the lathe to check the threads you get everything out of sync. So if you go to cut threads you need to make sure you know the exact depth and do it right the first time. If I am cutting critical threads I will go back to the gear system since all you have to do is take off the pulleys and put the gears back on. I am thinking of adding a timing light indicator to use instead of the dial so you know when to engage the carriage based on the timing of the spindle .

migrys

5 years ago

Hello. I am Polish and do not speak English - I use Google translator. A great project. My lathe is a small machine from 1960. But wanting to do it needs more data such as which button in the diagram what is it What is the switch for. The program is written for turning inch and metric threads. I only make metric threads. I also have a problem with the code - how is the translation of spindle revolutions calculated into the revolutions of the lead screw? Thank you very much for your help.

Anonymous user

5 years ago

Isn't there a possible problem with sampling the spindle speed only once per revolution?

Anonymous user

2 years ago

It's an old video done with a video tape camera. I really should make a new one. https://youtu.be/qu0GToSvnxk Turning to the correct diameter usually let's you know what the correct RPM is. If you are running MACH3 CNC you have the same issues since it also used 1 PPR. The goal of the ELS over

Anonymous user

2 years ago

What we found with my ELS ( mailto:E-LeadScrew@yahoogroups.com ) was that 1 PPR is more than adequate for high quality threading as long as several issues are addressed. 1. The pulse has to be long enough for your software to capture the edge and then verify that it's a real pulse and not noise. We usually suggest about 5 to 10 degrees for the slot used with say an opto-coupler. Magnets and Hall Sensors seem to work well just because the magnet itself is about 5 degrees wide. Depending on where it's placed (distance from center). 2. That the lathe spindle speed is steady. A standard lathe with AC motor or even three phase and VFD is remarkably stable and threading rarely puts a heavy load that could slow the spindle down. So one is better off spending the money on a good motor to keep the cutting speed stable. Having said that about speed, my ELS code does two things. With the assumption that the spindle speed is steady it averages it out over several turns. That prevents the display of RPM or SFM from bopping around. Second if there is a general slowing down of the spindle (or speeding up) I added code that tweaked the speed of the carriage. That was to deal with Sherline Lathes that aren't that stable for speed. Where the 1 PPR system does suffer is that once you start cutting a thread at say 300 RPM you cannot change your mind and pause threading, change speed to 600 RPM and expect the tool to enter the previous thread. The reason is simple. With 1 PPR and a carriage that is stopped, the index pulse tells the system where the spindle is. The acceleration up to speed for a stepper motor is generally fixed to be as quick as the stepper can handle without dropping steps. From a stopped Z axis stepper to the point it's up to speed is a fixed time interval and is repeatable. So if the index pulse triggers the Zmotor start, then the spindle will have turned Y amount. once the stepper is up to speed and is turning at the desired ratiometric speed to the spindle. Since this is repeatable, if the spindle is turning 300 RPM, the tool bit will always be at the same spot once it's accelerated up to speed. But change the RPM and the acceleration of the carriage remains the same but the spindle will have turned twice as far. Now the Z axis also needs to be turning twice as fast but unless you are cutting a lead screw pitch thread where spindle and Z axis turn the same speed they normally won't be at the same spot as 300 RPM. BTW, knowing that stuff about fxed acceleration, makes it also possible to cut multi-start threads with my ELS. John

Anonymous user

2 years ago

10 years ago was to provide threading on old lathes with minimal costs. That meant 1 PPR and a single motor on the carriage. The ELS included the micro-stepping driver which at the time and a price of $200 for the kit was a bargain. Now with far east stepper drivers and multi-line encoders along with belts and pulleys the cost of adding threading to an old lathe has dropped. For my South Bend Heavy 10L though, the cost of belts, pulleys and an encoder still reach well over $100. Just not worth it compared to 1 PPR.

Anonymous user

2 years ago

Hi, am a newbie to this forum. Having a bit of trouble navigating thru this ELS project cos I cant find a manual or guide for using it, nor a list of features etc. How fast can the leadscrew be run (rpm)? Is it a pain to get spindle vs leadscrew ratio correct so that, say, 8 tpi = 8 tpi.? What type of encoder is use? - Cant find how to contact Nick directly either.

Anonymous user

2 years ago

Hi, I’m putting together some junction boxes for domestic lighting using RS own brand DIN terminals in a suitable enclosure (home automation later would favour grouping the wiring into a limited number of JBs with space to accept relays later). One thing that came to mind was to do with these: https://ca.famaga.com/catalog/rs-pro/korpusy-stojki-shkafy They are the special DIN terminals that have a screw operated clamp to the DIN rail which claims to provide electrical continuity. How might I decide if these would provide suitable and reliable continuity for the circuit CPC on say a circuit protected by a C10 RCBO? Or do you reckon they are just fine? Points I’ve considered: Reliability – these clamp to a plated steel rail – so providing the plating holds and the rail does not corrode, then OK Clamping action seems positive. Contact resistance: haven’t attempted to measure yet, but I suspect it would be off the bottom of the range of my Megger. Fault current – worst case scenario: hundreds of amps but no more than 1kA for a very short time. There is a little leeway in that the circuit is RCD protected, but I feel it would be bad practice to factor that in as a key design consideration. What do you folk think of such devices? Many thanks,

Anonymous user

2 years ago

Thanks for the reply. Whilst 1PPR is simpler it means you've got to get the spindle RPM correct before you start threading. That's not always easy with some "difficult" materials.

nsr5058

2 years ago

Qtron, You can contact me directly at nsr5058@gmail.com I would be happy to help. Nick

Anonymous user

5 years ago

I'm concerned that 1 Pulse/rev may not provide the spindle positional resolution needed. It assumes there will be sufficient inertia in the spindle and drive assembly to hold revs sufficiently constant.

Anonymous user

2 years ago

Hiya Nick, i am a newbie to this forum. Having a bit of trouble navigating thru this ELS project cos I cant find a manual or guide for using it, nor a list of features etc. How fast can the leadscrew be run (rpm)? Is it a pain to get spindle vs leadscrew ratio correct so that, say, 8 tpi = 8 tpi.? Re the extra bits of improved code, is that all incorporated into Ver. 2 with rapid mode? Any chance of an improvement using an encoder? Or, is there an off-the-shelf ELS turn-key solution?

Anonymous user

2 years ago

I want to detect the 45 pulses from the gear and 1 index pulse, then when count of pulses =45, a index should be present, after electronic sync of course. That way I will know if the spindle lost a count slipped etc, probably over kill, however this still does not mean that the lead screw has not missed a step etc.....Getting 1 pulse is becoming an issue for me, no reliable sensor or pick off point.. Still waiting for the china pickups.......

Anonymous user

2 years ago

I have connected a Ir sensor to sense a flag for the RPM. Checking with scope at max RPM flag is 1.5 us... The Arduino RPM display jumps all over the place, I'm asuming I'm over running the Arduino. The max stable seems to be around 1500 RPM, Has anybody else checked their max RPM?? ALSO the RPM has a tendancy to jmp +/- 10 rpm any body else see this? It may be the HF lathe variable speed jittering. My homemade reluctance pickup works like a champ. It is connected to INA128 {instrumation amp} and max3095 rs485 Quad rec. I see no dropout on scope, but don't think ARDUINO will handle it.

Anonymous user

2 years ago

Do I change to[ point 05] or [ 0 point 5 ] or [ 5] from 1.00 I previously commented out 2 - Delay(5) in loop code, but since I don't have a stepper attached , I don't know if that will cause a problem. This did make a big difference... spindle @ approx 400 Ratio=1 LStpi=16 405 408 410 Stepper 405.41 408.16 410.96 408.16 most stable Spindle @ 194 195 196 197 198 Stepper 195.44 196.08 or .72 197.37 198.02 changes approx 2 seconds I was seeing +/- 10 in these ranges I'm thinking the speed control on my HF 7-10 may be contributing, I would like to feed the 45 gear pulses into the speed control, but that will probably require a different control board. Let me know on the longdelay value and I will uncoment the Delay(5) and try it. Is there any reason for the Delay(5)?

Anonymous user

2 years ago

what lines of code do I comment out to remove the debounce, I'm using forked IR sensor and see no dropout and little jitter... [ 1 pulse / rev]

nsr5058

2 years ago

Change the debounce time to 0.5. you have to eliminate the if statement in the speed sensor loop. So you could change the speed sensor loop to something like this. I did not run this code but it should look something like this. void speedSensor() { time = millis(); int currentSensorState = digitalRead(SensorPin); if (currentSensorState != lastSensorState) { sensorState = currentSensorState; if (sensorState == LOW) { calculateRPM(); // Real RPM from sensor if (currentX == 0) { englishCalc(); } else if (currentX == 1) { metricCalc(); } } } lastSensorState = currentSensorState; lcdRPM = RPM; } I'm not sure why your RPM readings vary so much does the lead screw respond to the change in RPM's on the spindle?

nsr5058

2 years ago

The debounceDelay variable may need to be reduced to read higher RPM's. (See the discussion above.) Try Changing line 13 of the code from long debounceDelay = 1.00; to long debounceDelay = 05; What speed was the RPM jumping was it +/- 10 at 100rpm or +/- 10 at 1000rpm? Let me know and I will double check mine. Nice that you made a reluctance pickup but I agree, you would need a better micro controller than arduino to handle that.

Anonymous user

2 years ago

Has anyone come across these Arduino replacements https://www.aliexpress.com/item/32989749596.html?spm=a2g0s.9042311.0.0.1ebc4c4dkd32hF when configured they run twice the clock speed of the normal Arduino Nano, there is a youtube video that tests them and they do run at 32MHz when configure properly, these may be what you need to get more features in the code.

Anonymous user

5 years ago

Hi xtal1011 I am assuming you are talking about the pulse from the hall effect switch for RPM, this is a positive pulse. Next challenge is to try and use a rotary encoder off the lathe main shaft, my feeble attempts are proving fruitless at the moment, but, who knows?

Anonymous user

2 years ago

10P Nail with magnet on nail head and coil next to nail head. Sine wave type signal from 45 tooth spindle gear. the faser the speed the greater the amplitude, I saw little noise, signal will have to be conditioned for aduino. I think I can temporary block 1 gear slot, then detect the enlarged timeframe as Index and use the other pulses for speed control, probably over kill , A lot of ELS seem to be using 1 index pulse. .......|coil| <<<Nail<{}Magnet] .......|coil|

Anonymous user

2 years ago

I too having feeble attempts.. Tried LJ8A3-2-Z/BY and BX inductive proximity sensors, I though I would pickup the 45 teeth on my spindle , These sensors are to sensitive to gap , they are either on or off....I was planning to plug 1 tooth gap , to have a index ref... I was trying to find a reasonable cost variable reluctance sensos,, They want a arm and leg for them, years ago they were dirt cheap, some Univac printers & key punches used them.. Ive ordered some tooth sensors [Hall] from china [2 wk wait] , may or may not work. So now will try to make a reluctance sensor, waist of time I'm sure , but I have lots of idle time.....

Anonymous user

2 years ago

Found a coil 3/4 in long 3/8 dia with center hole the size of a 10P nail. The coil measures 50 ohms, fine coated green wire, looks like what I used to hand wire ic's with, small pencil type tool and wrap wire around IC pins then solder thru insolution. Anyway coil measures 50 ohms. I hand held very close to gear and it appears to work very well. I just have to now figure how to mount, which may be a biggee... Noedymium magnet 1/4 dia approx 1/4 long. I have some wire wrap bobbins I may also try. looks very promising..... Of course mounting is still a problem.....The faster RPM the higher the output... .......|coil| <<<Nail<<<<<<<<<<][Magnet] .......|coil|

Anonymous user

2 years ago

My Lathe is cheapo HF 7-10

Anonymous user

5 years ago

Code says : The stepper speed calculations are based on the lead screw threads per inch ( in this case 8TPI), the synchronous belt gear ration ( in this case 1.529), the micro steps (in this case 400), and the RPM. Where does 1.529 come from??? 22T / 14T = 1.571 ????

stro38

2 years ago

Hi thank you once again sorry to trouble you, altered line 142 to: stepper.setSpeed(-1*stepperRPM); but still having problems noticed red led on stepper driver when I tried CCW with non rotation.. Anyway great sketch and thank you for the effort you put into it

stro38

2 years ago

Hi thank you, managed to complete the setup everything works great cutting right hand threads. Small problem cannot get ccw or if I reverse the motor connections cannot get CW despite the correct reading on the LCD change. So at the moment I can cut right hand threads but not left hand and if I wanted to cut left hand or feed left I have to change the stepper motor winding's over. Any idea what the problem is I have checked my circuits out and all seem Ok

stro38

2 years ago

Hi I have sorted out the problem. I was using a 2 metre long cable with 7 wires from my control box with the power 24 v and the dc dc converter 24 v to 5 v and the stepper driver wires all to my arduino small control case with lcd which must have disrupted the pulses to pul and dir so I put a shielded twisted pair and everything is ok now...really pleased

Anonymous user

2 years ago

Hi xtal1011 lets try and keep things simple, the formula for your example becomes 400/60 as everything else cancels out or is irrelevant. The result of 400/60 is 6.66666 these are pulses to the stepper per second which equates to 1 Rev Per Minute, multiply the steps by 60 (60 seconds in one minute) and you get your 400 steps (400 steps in one minute = 1 RPM if you double step a 200 step motor) the command stepper.setSpeed(-stepperRPM); requires a value of steps per second. 400 steps per second will rotate the stepper shaft at 60RPM. so your calculations are correct, you are not doing anything wrong - I made the same mistake as you, it was only when I looked at the stepper.setspeed() command more closely that the penny dropped.

Anonymous user

2 years ago

Thanks Howard... Next Q ? Is the sensor pulse positive pulse or negative pulse ?? I'm assuming positive....

Anonymous user

2 years ago

I'm totally confused about the StepperRPM: For test sake: using EnglishCalc Spindle RPM=1 Lead Screw = 16 TPI .0625 pitch USE Thread TPI = 16 .0625 pitch I think the pully ratio would be 1 ???? Now this seems to me that the spindle speed will match the stepper/Leadscrew speed I can't make it work. StepRPM = [Ratio * LS-tpi * Steps/rev] / Thread-tpi * 60s StepRPM = 1 * 16 threads * 400 steps 16 threads * 60s ---------- ------ / --------------- inch rev inch StepRPM = 6400 threads steps 960 threads s ------------------ / ------------- inch rev inch StepRPM = 6400 threads steps inch 6.666 steps ------------------ * -------------- ===>>> -------------- inch rev 960 threads s rev s This does not compute for me, What am I doing wrong?????????

Anonymous user

2 years ago

I'm totally confused about the StepperRPM: For test sake: using EnglishCalc Spindle RPM=1 Lead Screw = 16 TPI .0625 pitch USE Thread TPI = 16 .0625 pitch I think the pully ratio would be 1 ???? Now this seems to me that the spindle speed will match the stepper/Leadscrew speed I can't make it work. StepRPM = [Ratio * LS-tpi * Steps/rev] / Thread-tpi * 60s __________1 * 16 threads * 400 steps__16 threads * 60s StepRPM = ----------------------------- / --------------- ___________inch_________rev_________inch _______6400 threads steps___960 threads s StepRPM = ------------------ / ------------- ________inch_____rev_____________inch ________6400 threads steps__inch______________6.666 steps StepRPM = ------------------ * -------------- ===>>> -------------- ________inch_____rev___ 960 threads__s_______rev___s This does not compute for me, I would expect 400 steps, What am I doing wrong?????????

Anonymous user

2 years ago

This did not post properly but I get 6.6666 steps/rev s 6.6666 is a log way from 400

nsr5058

2 years ago

If you are talking about the stepper drive, it is wired positive.

nsr5058

2 years ago

Try changing line 142 From this, stepper.setSpeed(-stepperRPM); To this, stepper.setSpeed(-1*stepperRPM); I will check my working code tonight....

nsr5058

2 years ago

For the gear ratio I can see your confusion. I did not use the # of teeth to calculate the gear ratio. I used the actual pitch diameters of the sprockets. The gear ratio of 1.529 is calculated based on the pitch diameter for the 22t and 14t sprockets which are 2.6in and 1.7in respectively. 2.6/1.7 = 1.529.

stro38

5 years ago

Hi really liked your project I would like to fit a rotary encoder instead of the hall effect speed probe and have an enclosed system could I respectively ask if you could help with the alterations to the sketch...many thanks, excellent project

Anonymous user

5 years ago

So many mistakes, check out the schematic!, not enough comments in code to work out what you have done. so, changed code to what I think it should be, using metric leadscrew is much simpler for me. I would like some explanation of how you derived the formulas for the MetricCalc() and EnglishCalc(). Otherwise just what I wanted, as most other ELS were far too advanced/complicated, just wanted something simple to cut threads and change feeds without messing with change gears.

stro38

2 years ago

Thank you for your reply, really useful. One of many reasons I am going for it is that my Chester DB7 (similar to Warco 180) is that there is no reverse lead screw option to cut threads or feed, also its a bit of a pain to change gears as well. Anyway thank you and the author for your help I am nearly there done most of the mechanical work waiting for some cases.

stro38

2 years ago

Thank you very much for the help. Uploaded the sketch to my mega 2560 and some of the functions don't appear too work if l swap pin 5 and 6 from the buttons to the three way switch I can get CCW and CW and limited functions on transferring button to position 4 and 3, are the button layouts the same on the mega 2560 as the UNO? and finally I can just work out that the resistors are 47K but I am not sure. Meanwhile thank you for all the effort you have put into the project

stro38

2 years ago

Hi I have a lathe with 2mm pitch could you please show me how to alter the user inputs as I have troubles trying to alter the sketch...Much obliged

Anonymous user

2 years ago

resister values are not that important, any value between 5k and 50 k should be ok. The UNO pins to the switches shown on the diagram are wrong, the code is right (or vice versa of course), very easy to transpose, not sure about mega 2560 but you should be able to test the outputs quite easily with a serial.print() command with the Arduino serial window open. fitting a rotary encoder would I think need a much faster board then the UNO, unless someone would like to prove me wrong of course!!! my code for the speed calculations are as follow:- // =========================== metric stepper speed =========================== // synchronous belt gear ratio, * current pitch, * 400 is stepper motor microsteps, * RPM is main lathe spindle, pitch is as set on lcd menu ??? void metricCalc() { stepperRPM = ( 2 * pitch[currentPitch] * RPM * 400 ) / 120 ; //120 is leadscrew pitch (2mm) * 60 servoRPM = RPM * pitch[currentPitch] / 2; } // =========================== english stepper speed =========================== void englishCalc() // synchronous belt gear ratio, * TPI equivalent of 2mm pitch, * 400 / (current TPI * 60) { stepperRPM = ( 2 * 12.7 * RPM * 400 ) / (tpi[currentTPI] * 60 ); servoRPM = 12.7 * RPM / tpi[currentTPI]; for changes to the user selection of pitches/tpi look at the following:- const int nTPI = 18; //the number of options for TPI const int nPitch = 20; //the number of options for pitch int tpi[nTPI] = {256, 128, 64, 56, 48, 40, 32, 24, 20, 18, 16, 14, 13, 12, 11, 10, 9, 8}; int currentTPI = 0; float pitch[nPitch] = {0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.10, 0.20, 0.40, 0.45, 0.50, 0.70, 0.75, 0.80, 1.00, 1.25, 1.50, 2.00, 2.50}; you can have as many options you like here. have fun chaps

Anonymous user

2 years ago

No problem, managed to suss the code once I understood the set speed() command. I am using a metric lathe with lead screw of 2mm pitch. everything works ok apart from the 8tpi setting where the stepper does not like it, suspect UNO not quite fast enough, but not likely to need that TPI, I used a 2 to 1 ratio pair of gears as it would double the torque from the stepper and that may just have taken it over the boundary for reliable stepping. I also added some more ranges to the pitch range to set different feed rates. As I said , this was just what I wanted, so many thanks for your efforts

nsr5058

2 years ago

Hi Howard, The MetricCalc() and EnglishCalc() are as follows EnglishCalc() (Ratio of pulleys) * (lead screw TPI) * ( steps/rev) / [(desired TPI) * 60s)] MetricCalc() (Ratio of pulleys) * (lead screw TPI) * ( 1/(steps/rev) * 25.4 ) *(desired pitch) / (60s) I intended to write this as a showcase and not full instructions but I got carried away and probably made a few mistakes along the way trying to describe what I did. If you want to message me, I would appreciate some feedback!

nsr5058

2 years ago

OK so, the speed calculations should be metricCalc() stepperRPM = gearRatio * 2mm * steps/rev * pitch * rpm / 60 servoRPM = gearRatio * 2mm * rpm * pitch englishCalc() stepperRPM = gearRatio * 1/(2mm/25.4) * rpm * / ( tpi * 60 ) servoRPM = gear ratio * 1/(2mm/25.4) * rpm / tpi You have to convert the 2mm pitch to # of threads per inch by converting to english 2mm/25.4 = 0.0787in pitch, then divide one inch by the pitch 1 in / 0.0787in = 12.7 threads per inch. As far as using the encoder, I am not sure how that code would look. I would suggest finding a block of code someone else has made for speed/position measurement and add that into this program.

stro38

5 years ago

I liked your simple ELS just for screw cutting and feeds and this what appeals to me. I would like to put a rotary encoder instead of the hall effect sensor and create a closed system. The mechanical fitment of the hardware is not a problem but the arduino code is my nemesis, therefore if I fit the rotary encoder what code do I have to write in the script. I have a super mini Warco 180. I would be very much obliged if this can be done

Anonymous user

2 years ago

I have a concern that 1 pulse/rev isn't going to be enough when cutting the coarser threads.

Anonymous user

6 years ago

I was quite pleased to see and read this project, I have entered this world, precisely to finally learn CNC, having been a machinist for fifty years, introduced to it, on paper tape, in high school, but working manual machines all my life. I've got my own machine shop, I'm retired from the Marines, and do research and development, and I was very pleased to see the comment, "if I'd known, I'd have gone to Nema 24". These are issues one only finds when doing a job, a bit too much for "what I thought would do". I've got three lathes of similar size, and one, while being a 1946, is in practically unused condition, and set aside for exactly the project I just read. Thanks for giving me the foundation, and some important information. I'm glad to finally be on a site I can learn what I want to know. Semper Fidelis, John McClain

Anonymous user

6 years ago

Excellent code for button flag setting!!

Anonymous user

6 years ago

Nick; Debouncing is only necessary for mechanical switches. Optical and magnetic switches don't bounce when changing state. The debouncing code on your rpm sensor signal processing, although not necessary, won't hurt, but you are wasting cpu time, ram and flash space. The debouncing code will also limit the maximum rpm you could successfully read in your case (since you are only reading one pulse per revolution it won't hurt either, but it will if somebody tries to port your code while using a high ppr rotary encoder). The fact that there might be others doing it this way does not legitimize the use of debouncing in this case. Good job on your electronic gearbox!! Thanks for sharing!

nsr5058

2 years ago

I changed the speed sensor loop to run without debouncing. It does work when the lathe motor is off but when the lathe is running I get EMI. So actually in this case debouncing the speed sensor signal is necessary.

nsr5058

2 years ago

Thanks for the info. I will try changing the code and if it works well I will revise!

Anonymous user

6 years ago

Why do you need a debounce on an electronic speed sensor..??

nsr5058

2 years ago

The electronic speed sensor sends a pulse like a momentary push button. Since we are measuring the time between pulses we need to double check that the signal was generated. See the debounce example for more info https://www.arduino.cc/en/tutorial/debounce I actually grabbed that part of the code from tony here is his writeup. He explains it very well and it worked seamlessly. https://www.hackster.io/TonyScarp/arduino-ir-lathe-tachometer-500733

nsr5058

2 years ago

I changed the speed sensor loop to run without debouncing. It does work when the lathe motor is off but when the lathe is running I get EMI. So actually in this case debouncing the speed sensor signal is necessary because we need to double check that the speed sensor signal was generated as I stated before.

Anonymous user

2 years ago

The reason the original author of the code used debounce was because in the code you linked to in one of your replies, the author was using a reed switch as a pickup sensor. Nothing to do with anything else you mentioned. This is what happens when you copy paste code and and have either not checked it or don't know any different.

Anonymous user

6 years ago

I agree with Dougal, I think you've created an electronic gearing system rather than an electronic lead screw. When I google "Electronic Lead Screw" the first hit is my web page http://www.autoartisans.com/ELS/ and if you join the Yahoo E-Leadscrew group formed about 12 years ago there is a huge amount of information so you don't have to re-invent the wheel. Learn from our mistakes. https://www.youtube.com/watch?v=qu0GToSvnxk&t=21s If you wanted to take it one step further the BeagleBone Black runs MachineKit ( a port of LinuxCNC) and with a multi-line encoder creates a full featured CNC lathe for the price of a BBB and some sort of breakout board cape. All the other costs for motors, pulleys etc. remain the same no matter what approach you use. Still congratulations on getting your motor to move. Quite the thrill isn't it.

nsr5058

2 years ago

Thank you. Yes you’re right this is more of an electronic gearbox. There are no canned threading cycle features like the one you referenced. I purposely decided to stray away from any CNC functions and keep it simple for this application. Many bench top lathes like mine do not have the rigidity and require ball screws for full blown CNC. Now if I had a more stout larger lathe I would be more inclined to take it a step further.

dougal

6 years ago

Really Brilliant - well done, made for a small fraction of the cost of a commercial unit. I suppose the next step is multi-start threads but I think you will need encoders as you have already said. The commercial item you where initially looking for is called an "electronic gearbox" or "electronic gearing". PARKER HANNIFIN electronic servo drives include systems for them.