Automatic spindle gear detection updated for vfd

More
05 Mar 2026 21:05 - 05 Mar 2026 21:17 #343921 by jtrantow
I have been running my mill and lathe without accurate RPM control/calibration. Recently, I stumbled upon forum.linuxcnc.org/47-hal-examples/27071...r-detection?start=20

I broke down my implementation of this idea into three files:
  • LatheSpindle.hal - General spindle control and automatic gear detection scaling.
  • cmdr_wrapper.hal - Implements hm2_modbus for CommanderSK VFD.
  • Spindle_postgui.hal - Scaling for use with gmoccapy.Using hm2_modbus provides much faster communications and better gear detection during accel/decel than the user mode driver I previously used. 

     

    The gear detection magic occurs by using the ratio of the spindle frequency to the vfd motor frequency. If you have a number of gears or belts, each combination will have a distinct ratio. You use this to populate the x values of the lincurve. For the y values you use the scaling necessary to scale the spindle command frequency to the required vfd motor frequency. It's quite easy to collect this information.

I used a wrapper around the VFD commands so I could share code with my mill that uses a GS11 VFD.



I'm very happy with how this turned out! 
Last edit: 05 Mar 2026 21:17 by jtrantow. Reason: cleanup
The following user(s) said Thank You: tommylight, 0x2102

Please Log in or Create an account to join the conversation.

Time to create page: 0.134 seconds
Powered by Kunena Forum