Machine is almost rockin! X Y and Z are fantastic. Had to get some modbus comms working to talk to the VFD and swap some parameters to get the thing to work as a servo and a spindle. So now I have excellent spindle control up to 6k rpm and can swap it into a C axis and have full rock solid position control. Even got the tool change working in the MDI mode....that's where the fun ends.
In the toolchange macro I enable the C axis and change the parameters in the VFD then turn on the output to set the vfd into run mode (position control enabled). The next thing is to home the spindle to get the orientation correct, using DoOEMButton(1027). This bit is not allowed when running a program. If I don't home it, then the C axis has to "unwind" (even with mach set to roll over at 360 Degrees) to get to position after running as a spindle.
Need a way to home the C axis in a program, by passing the OEM button 1027.