Go Down

Topic: Due compatible modbus slave on RS485 (Read 1 time) previous topic - next topic

slawa92

Hi. Does anyone have a decent modbus slave library compatible with Arduino Due. I need at least functions 03 and 16. The interface is RS485 (using MAX485 ic). Also must be compatible with 8N1 port configuration.

Thank You

ard_newbie


I don't know a Library for an RS485 communication, but I guess you should start with an USARTx RS232 implementation as a starting point, enable the RTS pin, note that the behavior of the RTS pin is controlled by the TXEMPTY bit. Therefore you will have somewhere in your code (e.g. with USART1):

//Wait for transmission to complete
while ((USART1->US_CSR & US_CSR_TXEMPTY) != US_CSR_TXEMPTY);


The USART is set in RS485 mode by programming the USART_MODE field in the Mode Register (US_MR) to the value US_MR_USART_MODE_RS485.

And look over section 35.7.6 page 801 of Sam3x datasheet.

rockwallaby

#2
Jul 22, 2017, 02:17 pm Last Edit: Jul 22, 2017, 02:19 pm by rockwallaby
If you search for SimpleModbusSlave library, there is a version for DUE.
It seems to work reliably and I have not had any issues with it for the past year or two.

For my solar system, I have a DUE set up as Modbus RTU slave, using SimpleModbusSlave_DUE, being polled by a small GNU/Linux board which runs Modbus RTU master, using Libmodbus, which is a library for GNU/Linux systems.

You will find a thread in Networking, Protocols and Devices: this thread https://forum.arduino.cc/index.php?topic=176142.0
Search in there and you should find the link to get the DUE version of the library.
I don't have the actual link to the library source unfortunately, but do have the library.

Essentially, there is little difference between what interface you use.
The only thing that is needed for TIA-485 is the data direction control line if you are using half duplex.
I use it over USB as a serial device.
____________
Paul - VK7KPA
Paul - VK7KPA

rockwallaby

I couldn't help myself, I found it at the following link:
https://drive.google.com/drive/folders/0B0B286tJkafVYnBhNGo4N3poQ2c

Hover over the file names and you will see which one is for DUE.
You have slave or master for DUE.

Also, very importantly, make sure you read the documentation file before asking questions, as everything is fairly well explained in the documentation PDF.
____________
Paul - VK7KPA
Paul - VK7KPA

Go Up