Greetings everyone, I am developing an industrial 3d printer and I need your help about CanBus. I am using one PLC in the system and BTtT Octopus as the motherboard. Is it possible to communicate the PLC with Klipper via RS485 Modbus RTU? Has anyone worked on this before? (I will do it as communication, for example, functions such as activating an output of the PLC or receiving input).
Hi, my current plan is just to introduce the PLC as my 2nd motherboard. For example, the outputs of my servo motors such as alarm or brake are connected to my PLC, I interpret them and send a lot of signals to my BTT card such as emergency stop trigger etc. For all of these signals, I gave input from a lot of fan outputs of my BTT card, for example, or I used the endstop pins to detect the outputs from the plc etc. So frankly, the wiring on this side is in great confusion and I want to minimize it.
Well that seems pretty possible, but probably will require additional hardware and custom python code. Most probably it will be slow but it should work.
It should look like this:
Debian (with klipper Host) <–USB/CAN/Serial–> BTT Octopus (MCU)—>SPI<----> Transceiver <—RS485—> PLC
You must be sure that PLC communication is not related to time critical stuff because of klipper architecture (Klipper Host and Klipper MCU live in different worlds and real-time gap can reach few seconds).
Directly UART/RS485 is not supported in MCU firmware so HOST can’t ask MCU to do something on it’s UART interface, but SPI is supported on most boards and as I can see your BTT Octopus (STM32F446ZET6 chip) MCU firmware should support SPI ports. So you will need to introduce SPI-RS485 transceiver, something with MAX3140 or something similar.
As MAX3140 (or similar) is currently not supported by Klipper Host - you will need to develop custom python module which will handle everything what you need, as a starting point look at sources around maxxxxxx-temperature-sensors as I remember those temp sensors works thru SPI by utilizing spi-commands, another entry point is adxl345 - it also use SPI