Using ArduinoRS485

Hi all,

Since we are using ArduinoModbus for our Modbus TCP interfacing (Thanks again, Tom), I thought a good idea to try and use ArduinoRS485 as my regular Modbus RTU master / slave library through the "Serial" (RS485) port of the IndIO.

I had to change a bit my RS485.cpp file so :

// Original Code ------------------------------------------------------------------------- Modified DD.28/06/2021
// RS485Class RS485(SERIAL_PORT_HARDWARE, RS485_DEFAULT_TX_PIN, RS485_DEFAULT_DE_PIN, RS485_DEFAULT_RE_PIN);
// Modified Code ------------------------------------------------------------------------- Modified DD.28/06/2021
RS485Class RS485(Serial, 1, 0, 9);
//End of changes ------------------------------------------------------------------------- Modified DD.28/06/2021

I tried every permutation of the pin numbers, and I get this :

RS485Class RS485(Serial, 9, 0, 1); : No communication, break condition every read or write

RS485Class RS485(Serial, 9, 1, 0); same-o

Any other combination : 1 "break condition error" every 2 read / write from / to the slave.

Something I did not get right in the RS485 file or what ?

This is using the Arduino RTU "kitchensink" examples straight from the library, except a "Serial" to "SerialUSB" change for the messages.

 

Didier DORGUIN
Didier DORGUIN
152
| 4 1 3
Asked on 6/28/21, 5:15 PM
0
vote
269 Views

Hi Didier,

Thanks for pointing to that library, i have not used it myself but maybe this suggestion will help. In the usual Arduino setup with MAX485 the RE and DE pins are joined, and used as TxEnable, which is D9 on the INDIO. The txPin in the library is only used for the break functions, i'm not sure what their use is, they are not mentioned in the examples. So my best bet for the 3 pins:

  • txPin: 1
  • dePin: 9
  • rePin: 9

(the library has a function setPins() so you don't have to edit the .cpp)

Tom
Tom
5675
| 1 1 3
Answered on 6/29/21, 3:28 AM
1
vote

Works perfectly, back to the original .cpp code with a "RS485.setpins(1,9,9);" instruction before the ModbusRTUServer.begin, and with the middle jumper on in the D21G to activate the termination resistor.

I'll get to the master side now. Thanks, Tom !

Didier, DG2R

 

Didier DORGUIN
Didier DORGUIN
152
| 4 1 3
Answered on 7/1/21, 8:58 AM
0
vote

Your answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

Ask a Question

Keep Informed

About This Forum

This community is for professionals and enthusiasts of our products and services.

Read Guidelines

Question tools

64 follower(s)

Stats

Asked: 6/28/21, 5:15 PM
Seen: 269 times
Last updated: 7/1/21, 8:58 AM