I'm trying to program an Atmega328 on a custom-made PCB to act as a Modbus RTU master. I realize there's a big topic already on the forum, but this seems way too complicated for what I need, so I was hoping for a simplified solution.
The setup is a PCB that was originally designed to be used as a DMX master (DMX uses RS-485), and this worked flawlessly. As the hardware serial port on the board was used for something else, the transmit line from the microprocessor to the MAX485's "DI" pin was just a normal digital output pin (14, Arduino 10) which I used with the SoftwareSerial library.
With that same PCB I'm trying to control a commercial stepper motor that has a Modbus RTU interface. For the moment I'm not even trying to interpret any acknowledge response, just trying to write a value to a certain register.
As a physical layer I'd like to re-use the MAX485 that is already on-board. The stepper has been configured at 9600 Baud, 8 data bits, even parity and 1 stop bit. The register that I have to update is 0x007D, and I'd like to give it a value, say 0x0008. The slave ID is 1.
I have been looking at the Modbusmaster library, and for what I understand it seems like you can only use the hardware serial port. Is there a way to tell the library to use another pin, like in my PCB "Arduino output 10"? Or do I have to rewire the board with the TX pin from the Atmega328 to the DI pin of the MAX485?
I'm also not sure how to update that certain registry with a value.
Any light on the subject would be much appreciated!
Thank you very much,