Things are now progressing, after a few issues that took longer that I'd hoped to solve.
The major headache of the past week has been getting the KFlop to talk to the PLC using modbus, and retrieve the information I needed.
First up the Kanalog port is numbered backwards, so what should of needed a straight through cable, actually needed a crossover cable. Once this was realised, I just had to cut the cable and crimp on a new RJ connector, and the sample script provided with the KMotion software burst into life and worked flawlessly.
Then there was the case of figuring out how to read and write to the correct Holding Registers within the PLC, which I only figured out after sitting and going through the Address Picker within the Click software to figure out exactly the sample script was working, and realising you can access the inputs and outputs using two different methods.
Once I'd managed to get past those issues, I managed to get the KFlop reading the current tool position, and writing a new commanded tool position.
The spindle is now setup as a closed loop servo (albeit a very slow reacting one due to still being VFD controlled), so the set speed is highly accurate.
I did have an issue with the spindle reversing direction whenever a new speed was set with it already running, which Tom at Dynomotion explained was due to Mach not issuing a direction command to the plugin on a speed change, so he quickly sent me a modified sample script that stored the previous direction command.
I've also got the homing routines working, so they use the proximity switches followed by the servo index.
I'm now working on getting everything working together,, and getting it all combined into the one initialisation file that gets loaded via Mach.
I've so far got most of the code done for the KFlop monitoring, where an E-Stop has to be activated. For this I've essentially got two levels of E-Stop. First there is the physical circuit that triggers when a limit or an e-stop button is activated, and second there is the monitored circuit for things like a servo fault (the servos are connected and configured to do a fast stop if any fault) or tool changer issue, where the KFlop will stop things and notify Mach.
As Mach can only accept one E-Stop input, all E-Stop control is ultimately mapped to a single virtual bit within the KFlop, that Mach monitors just like a normal input pin.
Next up is the tool changer, which will require several parts. First up the macro within Mach needs to notify and transfer the requested position to the KFlop, then the KFlop has to transfer that position to the PLC, followed by the Tool Change allowed output being activated, then once the TC Ok input is activated again, I need to read the position back into Mach. I don't really need to read the position back into Mach, but I can use it to avoid commanding a tool change when one isn't actually needed.