Modbus commands to control spindle inverter? SKR 2

I have built my mpcnc for a while now and soon I only have the table to do :slight_smile:
And how to control the frequency inverter for the cnc spindle. I have been thinking about this a lot and chat with the support on bigtreetech (I have an SKR 2 REV B), I asked if I can send Modbus commands from the SKR 2 to the inverter through rs485 and he said it should be possible and that I can use the TX and RX pins for the WiFi module :smiley::+1:

But now the problemā€¦ how can I make the marlin code send Modbus commands???

Does anyone know in what end I should start?

Is it to hard to do?

Is it a good idea?


Couldnā€™t tell you if itā€™s a good idea or not, but after avoiding work by scanning the Marlin codebase a bit, my suggestion would be to add a Modbus feature class (Marlin/src/feature/modbus.h/.cpp) to handle the Modbus communications (you could look at the I2C feature in the twibus feature as a start), then you just need to figure out how to get the spindle_laser feature to use your new Modbus feature instead of either PWM or on/off on a given pin. Simple, reallyā€¦ :japanese_ogre:

Rather than modifying Marlin, you could handle it through g-code. See Serial print | Marlin Firmware

thank you i will se if i can manage to do this or the other method Robert Bunney write about? if you know how modbus works can you please tell me for example how the command to start spindle would look like? (0x2000(8192)1:0 b10?) i referred to the picture i uploaded (start command)

thanks! i will dive deeper in this and K Cummins suggestion to and se how i can do, im not very skilled at this so need to try and fail until i succeed

Hoo-boy! OK, youā€™re talking about implementing a protocol you donā€™t really know. Thatā€™s going to be a tall order. Letā€™s take a step back. Does your spindle frequency inverter (BTW, Iā€™m just parroting your terms back, I honestly donā€™t know what a frequency inverter actually is) only talk Modbus, or is there another way you can control it? Does it take a PWM signal? We understand PWM signals.

Took a quick dip into modbus, and you almost need a separate microcontroller just to handle the modbus communications. Thereā€™s a lot going on in there, more than you probably want your CNC controller handling. I mean, itā€™s probably doable, and if youā€™ve got a decent processor, it could probably handle it, but it wouldnā€™t be simple. I see that thereā€™s an Marlin feature request thatā€™s just to access the UART or SPI for someone who wants to talk to temperature sensors via modbus, and theyā€™re talking about using a separate microcontroller to handle the modbus.

edit: Gah! Now you have me reading the modbus protocol docs! No! I have to do my real work! Aaaiieee!!! :scream:

2 Likes

Ok. K is the new resident modbus expert.

1 Like

Maybe it is like you says K Cummins, I may be taking water over my head here.
It would be much simpler to use pwm, but the inverter does not have that function sadly :flushed: but it will work with an pwm to 0-10v or 0-5v converter. Just thought it would be nice to have free ports.

The frequency inverter is the ā€œsmartā€ product that the cnc spindle are connected to that controls speed, forward/back and more things (maybe I did not get this word correct? :thinking:)

A separate microcontroller :sweat_smile: No no thatā€™s to much, the processor on the skr 2 is 168MHz but I donā€™t know ANYTHING about this so I will use the converter instead and you should go back to work :astonished::+1::grin:

Thanks for your reply and ideas :grin::grin:

1 Like

It sounds like thatā€™s an industrial-level spindle thatā€™s designed to be connected to a beefy controller (something like Mach3 or LinuxCNC) thatā€™s either designed to handle Modbus, or has a dedicated Modbus controller to handle the communications with all of the Modbus devices.

I think it is industrial grade :thinking: it is 1500w and 400hz

Your right! Better to do this simpler for now and if I can understand modbus in the future I will try this then :smiley:

1 Like