0
\$\begingroup\$

I'm using modbus RTU over RS485 for a project. I use a RaspberryPI as master and Arduino Pro Mini as slaves.

My problem is the following : I plug a sensors on the bus and it returs its value. I plug another sensor, this one returns its value but the first sensor doesn't return its value anymore. So it looks evident something makes them incompatible.

I tried to diagnose it using a logic analyser and the results are the following : When idle, the lines A and B from the master are respectively HIGH and LOW. When idle, the lines A and B from the slave are both HIGH.

I wonder if the line B shouldn't be LOW.. Looking why this line was HIGH, I discovered that the line is pulled HIGH because of the library I use on Arduino. This library pulls DE and RE HIGH when transmitting data, LOW otherwise. (On the max485 module, I tied DE and RE together. I'm not sure it's a good practice)

Here is the library I use on arduino : https://platformio.org/lib/show/1727/ModbusSerial

Here is a schema of a modbus slave module : enter image description here

EDIT :

On logic analyser (1 slave connected to the master) :

I tried with 2 differents usb/rs485 transceivers

Transceiver 1 - 3 seconds record enter image description here

Transceiver 1 - Zoom on request / response enter image description here

Transceiver 2 - 3 seconds record enter image description here

Transceiver 2 - Zoom on request / response enter image description here

So my question is: Is it normal to get HIGH on both lines A and B ? And if not, what can I do to correct it ?

Thanks in advance !!

\$\endgroup\$
6
  • \$\begingroup\$ That's not a schematic btw, it's a pretty picture of wires. And as such, completely useless without an actual schematic. \$\endgroup\$ – Lundin Feb 20 '20 at 15:15
  • \$\begingroup\$ Ok @Lundin. I added the schema \$\endgroup\$ – Raphael Deiana Feb 20 '20 at 15:24
  • \$\begingroup\$ It is still not a schematic but enough for me to spot one problem. A proper schematic would also contain things like the decoupling cap, the bus termination etc. And it is common to have pull-up on the UART rx line unless available on-chip. \$\endgroup\$ – Lundin Feb 20 '20 at 15:42
  • \$\begingroup\$ I'm just a beginer in electronics. My skills are very limited. I've not used a decoupling capacitor. Maybe it would be very useful but I don't know why... About the bus termination, I've not used any resistor because it seems not necessary in my case (I did the calculation). For the pull-up on rx line, once again, I didn't know I have to do it and why. I will learn about it. Thanks \$\endgroup\$ – Raphael Deiana Feb 20 '20 at 16:12
  • \$\begingroup\$ Read something about RS-485: they should sit around 2,5V when idle. When transmitting, A-B>=0,5 volts or B-A>=0,5 (mark or space). Normally, a biasing is made (with pull-up and pull-down) in order to keep A slightly higher than B, to avoid that when the line is idle, noise triggers unwanted reception. \$\endgroup\$ – linuxfan says Reinstate Monica Feb 20 '20 at 17:00
1
\$\begingroup\$

When idle, the lines A and B from the master are respectively HIGH and LOW.

That's because the RS485 interface is outputting an idle condition i.e. B is the inverse of A because the transmitter is enabled.

When idle, the lines A and B from the slave are both HIGH.

This is because the slave is set to receive data and the RS485 chip has no control on the lines . External pull-ups are the likely cause of this.

If master and slave were connected then master (although being in idle) would drive the line high and low and, you would see high and low at the slave.

\$\endgroup\$
10
  • \$\begingroup\$ Thanks for your answer! I tried connecting master and slave and I added a picture from the logic analyser to the question. Do you think everything is normal in the capture ? When the master sends the request, B is not the inverse of A because the B line is HIGH. Is it a correct behaviour ? \$\endgroup\$ – Raphael Deiana Feb 20 '20 at 14:07
  • \$\begingroup\$ It doesn't look like correct behaviour at all. When either master or slave transmit, B is the inverse of A. It looks like the driver on the master is faulty. \$\endgroup\$ – Andy aka Feb 20 '20 at 14:13
  • \$\begingroup\$ I thought as much! What is the driver ? The software library or the usb rs485 transceiver ? \$\endgroup\$ – Raphael Deiana Feb 20 '20 at 14:22
  • \$\begingroup\$ The 485 transceiver is my guess - it has to be hardware by the looks of it and I can't see it being software unless something very strange is happening such as the direction pin being shorted to the data pin. \$\endgroup\$ – Andy aka Feb 20 '20 at 14:35
  • \$\begingroup\$ Ok. I tried with a different transceiver. I added the captures to the question. The signal of the request / response looks better but the line is now very noisy as you can see. What is your opinion ? \$\endgroup\$ – Raphael Deiana Feb 20 '20 at 15:10
2
\$\begingroup\$

RS485 (TIA485) can be tristated when idle. If it is, the terminations would determine the state of the lines. It may be that the Pi terminates them differently than the Arduino.

\$\endgroup\$
0
\$\begingroup\$

Your connection to /RE and DE is incorrect. If you check the datasheet of MAX485 & friends, you'll see that /RE is active low, but DE is active high. If you connect a pull down to both of these pins, one of them will act up. Simply tie /RE to ground and DE to Vcc.

enter image description here

\$\endgroup\$
6
  • \$\begingroup\$ Thanks for your answer Lundin. I got this trick from another post on this forum. (electronics.stackexchange.com/a/470391/237592). However, I removed this pull-down resistor from the module for my tests in this post. I should have removed it from the schema. \$\endgroup\$ – Raphael Deiana Feb 20 '20 at 15:49
  • \$\begingroup\$ If you tie DE to Vcc, the line will be always driven, and that is incorrect for a half-duplex line (or bus, if you prefer). You can tie RE_ to GND, if you want: you will receive everything, included what you transmit yourself. \$\endgroup\$ – linuxfan says Reinstate Monica Feb 20 '20 at 16:55
  • \$\begingroup\$ The fact RE_ is negated and DE is not, permits to do what the OP did, connect them together and with a single wire you control the driving of the line without getting an echo. Or you tie RE_ down and drive only DE, and you get an echo of what you transmit (and if you transmit badly, you receive badly, so it is an added check). \$\endgroup\$ – linuxfan says Reinstate Monica Feb 20 '20 at 17:04
  • \$\begingroup\$ @linuxfansaysReinstateMonica Well it depends on if you wish for half duplex or full duplex, though in the latter case I suppose there would be an additional transceiver (RS-422). However, this pull-up will explain the idle states that the OP is experiencing. \$\endgroup\$ – Lundin Feb 21 '20 at 7:50
  • \$\begingroup\$ The question seems to talk about multi-drop RS-485, not RS-422. In the schematic I see a pull-down, not a pull-up. I believe it is not good to keep the line driven, if not requested: it can consume good power for nothing (hundreds of thousands of mA). \$\endgroup\$ – linuxfan says Reinstate Monica Feb 21 '20 at 8:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.