I'm not familiar with analog servo setups but I have implemented a rotary axis/spindle switch with a motor drive that could be run in position(step/dir)/velocity(analog) mode. Which means I did not run the motor with the stepgen while in spindle mode.
forum.linuxcnc.org/10-advanced-configura...code?start=30#272218
I wonder if you could do something similar so I'll try to give a quick overview of what was involved.
Say we start with the rotary running in axis mode.
Switch to spindle mode:
1. Move rotary to position zero
2. Store the current encoder count and switch the rotary feedback from the encoder count to the stored count. (this means the rotary axis 'thinks' it is standing still while in spindle mode)
3. In my case I switch the drive to speed mode and use normal spindle command (M3 Sxxxx) to output an analog signal to run the motor as a spindle. In your case I wonder if you could maybe switch to a different pwm generator.
To switch from spindle back to rotary:
1. use M19 spindle orient to bring the spindle to the zero position. There is a special component that resets the encoder count on a mesa board to zero on an index pulse (in my case this pulse comes from the encoder output of my motor drive if you don't have an index signal you may have to generate one using an extra sensor on the motor). This basically 'rehomes' the rotary.
2. we can now reconnect the encoder count to the rotary feedback position. Note that, depending on the accuracy of the spindle orientation the spindle will have overshot the zero position and the encoder may be somewhere past the zero count. The moment this count is reconnected to the rotary feedback it will be seen as a position error and will be corrected by the pid. This might require relaxing the f-error value to avoid triggering a following error.
All the relevant components (encoder switching, spindle-orient) and mcodes are attached to the post linked above and the one immediately following it.
Maybe this give you some ideas about how to proceed in your situation.