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.
Attachment not found
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.
Attachment not found
I used a wrapper around the VFD commands so I could share code with my mill that uses a GS11 VFD.
Attachment not found
I'm very happy with how this turned out!