@gloomyandy said in Modbus Spindle Control:
@dc42 I had a quick look at the linuxCNC HAL code for the VFD that the user over on discord was using. That looks like it uses the same crc16 and seed as modbus but has a different payload. I get the impression from a quick scan of the linuxCNC stuff that this is fairly common, devices which claim to be "modbus" use the modbus signal timing. framing and crc but do not use the modbus register/coil model and associated commands. But I'm certainly no expert on this.
This is my understanding as well. Theres at least a couple quite common Chinese VFD's which advertise Modbus support but don't follow the modbus-rtu data format - the Huanyang one encountered on Discord seems to be the most common though.
For my own understanding of the RRF codebase, I spent a bit of time looking at how custom spindle control might be implemented using DoFileMacro
.
It seems like adjusting spindle state and rpm would probably need to move to some type of reconciliation based system - where direct calls to spindle->SetRpm()
and spindle->SetState()
would store values that would then be applied later while spinning a GCodeBuffer
.
Applying the settings could be simply setting pin output states for a standard spindle config, like what happens now, or calling DoFileMacro
to execute a user-provided control system.
However - there's areas in the code where spindle control actions appear to be taken from outside any particular GCodeBuffer
(Tool::Activate()
for example, called from direct LCD requests). These would not map cleanly onto just switching into a spindle control state in the current GCodeBuffer
where the request was made.
My initial thought was to use the Daemon buffer for all spindle control, but a long-running daemon macro could impact spindle control, and vice-versa.
Does it make sense to run the spindle control actions in their own GCodeBuffer
instance and synchronise it with the other buffers?
For example - when File
buffer calls M3
to start the spindle, we change the pending spindle settings, notify that the spindle needs to be reconciled and then don't allow the File
channel to continue until the Spindle
buffer reports the settings have been applied?
Any thoughts on this appreciated, or if I'm missing any prior art that might indicate a smarter way to do this?
I'm going to be at SMRRF in a couple weekends so I'd be happy to chat about this in person if you're going to be there (David / Andy)?