Hi folks,
I am fairly new to Arduino and I have a project that I am working on where I could use some assistance.
My project is to achieve very basic lathe leadscrew synchronization with the spindle. I'm aware of some other solutions such as ELS but I want to learn how to do this while using the resources that are available to me without having to buy into a third party solution. I'n not really interested in a full CNC option either.
I have the core components which include the Arduino, a large stepper motor (200 step/rev), appropriate stepper driver (step and direction type), timing pulleys and timing belt to drive the leadscrew, and a mechanism to provide pulses based on spindle revolution, etc... I have not built the spindle 'timing disc' yet but the concept is to fix a slotted disc to the spindle and use a photodiode to send a 5 volt pulse every time the slot(s) pass through the photodiode. Alternately a hall-effect sensor with one or multiple magnets on the disc could be another option.
I have done a bunch of research and have been looking for some code examples however I have not been able to find something similar to my requirements.
I am having a hard time figuring out the logic of how to synchronize the stepper with the spindle based on the spindle timing disc.
Here are some of the specs:
Stepper Motor (1/16 micro-stepping): 3200 steps/rev
Spindle timing disc: 1 pulse per rev (for the sake of simplicity)
Stepper to Leadscrew ratio: 1.25
NOTE: Stepper has a 15 tooth timing pulley and lathe leadscrew has a 12 tooth timing pulley.
Leadscrew: 8 TPI (3/4" acme thread)
Lathe Carriage feed based on a single spindle revolution: 0.0167"
NOTE: Eventually I will code this so that I can manually set different carriage feed rates but for the sake of this discussion, a single feed rate is sufficient.
I think these are all of the numbers that would be required in order to do the calculations. I'm having a hard time trying to figure out the formulas and I am hoping that someone here can help me to figure out the formulas and logic to make this work.
Here is the concept:
I need to be able to rotate the leadscrew so that between each pulse (rising edge) from the spindle timing disc, the lathe carriage will move a total of 0.0167 inches.
The lathe spindle will be spinning at a variable RPM. The RPM will only vary slightly based on the load. The spindle / timing disc will provide 1 pulse per revolution of the spindle. For the sake of calculations, lets use a constant RPM and say that for each spindle revolution, it takes 1.66 seconds (or 100 RPM).
My thought is that I would need to start a timer to capture the milliseconds between each pulse from the spindle. for the sake of calculations, lets just say that the spindle speed is constant and there is 1660 milliseconds between pulses
Then I would need to calculate the number of steps (X steps) required to move the carriage 0.0167".
The last part would be to figure out how to step the motor X steps over 1660 milliseconds.
Does this sounds about right? Any suggestions on how to calculate the required number of steps and then how to drive X number of steps over a given time period? Math isn't my forte so I am having troubles trying to figure out what the formula would look like.
Any help with this would be super!