A
A
Andrey Kovalchuk2016-06-02 20:42:52
Arduino
Andrey Kovalchuk, 2016-06-02 20:42:52

Modbus, RS485 data transmission via rx\tx 1-3, any features?

Two arduinos Mega and Nano work on the RS485 bus using the Modbus RTU protocol.
Everything works if configured through tx0 and rx0 outputs, but does not work through others (1-3). Bottom line: I want to start two connection serials:
one is a regular Serial, through which Mega will communicate with the computer: the
Serial.begin(9600);
other is Modbus, which will communicate with slaves:

Modbus modbus (0,3,10);
modbus.begin(19200);

Is there such a possibility? or tx \ rx must match on both devices in order?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Gusev, 2016-06-02
@Sanchogus

Try exactly those pins where the serial is hardware:
For mega: serial bus: 0 (RX) and 1 (TX); Serial bus 1: 19 (RX) and 18 (TX); Serial bus 2: 17 (RX) and 16 (TX);
0, 1 is already for communication with the PC, try the rest for the rest.
It seems that for digital pins there is an opportunity to make SoftwareSerial

O
Ocelot, 2016-06-03
@Ocelot

Most likely, this lib does not know how to raise the interface on arbitrary pins, but uses a hardware UART. But she does not know on which pins this UART lives, therefore it requires you to specify it at startup.
Leave the modbus on the default tx/rx pins, and to communicate with the computer, raise the SoftwareSerial

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question