I added a feed screw onto my lathe so I don't wear out the threading screw doing repetitious feed or boring work, and because driving through the carriage traverse handle always leaves irregularities in the surfacing. This software uses a timer interrupt to precisely sequence stepper motor pulses, and uses multiples of the timer interrupt period to determine stepper speed. Right now it's set up to drive a half-step L298, but can be easily changed to a step/direction driver for a Trinamic or A4988. It could use a 2x16 LCD. I happen to be using a 4x20. Picture shows the same software/hardware driving a mill fourth axis rather than the lathe longitudinal axis.
Files
lathe_stepper_driver_final.ino
arduino sketch: uses timer2 overflow interrupts to evenly sequence half-step signaling to drive a stepper motor with a dual H-bridge. It displays speed, direction, and on/off status to an LCD, and needs two buttons (on/off, left/right) set up with pullups to +5V to operate. Stepper is attached to lower 4 bits of PortB, lcd to portD, and the buttons to upper bits of PortB.