Close

Spindle Encoders, PID and Threading

A project log for Shoptask 1720 LinuxCNC

Finally automating my 1998 Lathe/Mill/Drill which was built for CNC

Alastair YoungAlastair Young 10/13/2021 at 00:480 Comments

I had an interesting time getting the spindle speed feedback to work with the feed-per-revolution and G76 threading. 

The position interpolation in the HAL encoder component for the single pulse encoder is not available in the Mesa encoder component. 

So the encoder itself is wired into the A channel on the Mesa encoder - not the index. I intend to move it to the index when I get the quadrature encoder installed. The input A signal on the mesa encoder is fed to a HAL encoder on the A and Z channels. I can then take position interpolation for threading from there. However as the Mesa is only read at servo-thread speed, this will probably not work at higher rpms, unless I install a wider magnet on the pulley to make the index pulse wider. So for now I am threading at the minimum speed which is 165RPM. The pulley table says 120, but it lies.

I made myself a little function to simplify cutting UN threads - it takes the thread length and TPI and figures out the rest.

Initially the first threads in each pass were too wide - I could see the X handwheel still turning for the first 5 revs or so. Giving it a "run up" was a workaround but clearly my PID was not taking up the backlash quickly enough - X currently has 0.011 backlash possibly due to the earlier toll crash loosening the acme nut. 

So I spent a couple of evenings playing with that. 

This youtube playlist was helpful https://www.youtube.com/playlist?list=PLPgfyZozUfKrY_qa1ZNW0ldwaJJl6c5Qm

I eventually found the following:

Watch the github repo for the numbers I settle on.

Discussions