-2
\$\begingroup\$

I understand the title seems too broad but it's a bit specific and I'm totally new to the communication stuff, so please bare with me. If the question is too broad, please provide some suitable links that I can look upon.

Now I'm given a simulator pyModSlave and a USB driver, that has two output pins.

enter image description here

I've a MAX485 (to be honest, I'm completely lost as to what this does) enter image description here

and an ESP32 .

enter image description here

Task given:

Interface ESP32 with RS485 annd run ModBus library of Arduino IDE with RS485.

Questions:

  1. What is the difference between RS-485 and MODBUS?
  2. How does data get transmitted in this type of system? For example, say I've a temperature sensor, that gives out data in RS-485. What does this mean? All I know about transmitting data is as a binary number as 1s and 0s. What does MODBUS do in all this?
\$\endgroup\$
  • 4
    \$\begingroup\$ Wikipedia should be able to answer these questions just fine. \$\endgroup\$ – Lundin Dec 4 '19 at 9:07
3
\$\begingroup\$

RS-485 is a standard defining electrical characteristics of a serial link. It dictates electrically how multiple devices can send 1's and 0's to each other over a differential bus. What voltage levels represent a 1 and a 0, Impedance of the cabling, etc.

It doesn't define the protocol - i.e. when devices should talk to each other, what they should say, what the 1's and 0's mean. For example, you could send this:

110011011100001

But it doesn't mean anything without a protocol defining how to interpret it.


MODBUS is a communications protocol. It defines what devices should send to each other and when. There are set of rules that devices must obey in order to ensure they are interoperable.

I'm not going to go into detail on the protocol in this answer as there are hundreds of resources online, for example this document from the MODBUS organisation themselves.

In the case of serial transmission over an interface such as RS-485, you will likely be using the "MODBUS RTU" protocol, which is specifically designed for serial links.


I've a MAX485 (to be honest, I'm completely lost as to what this does)

It's a TTL UART to RS-485 Converter, to allow single-ended logic level signals (such as those from a microcontroller IO pin) to be electrically interfaced with an RS-485 bus.

\$\endgroup\$
  • \$\begingroup\$ Thank you very much for your patience, but can you please provide a simple example, like that temperature thing and point out these. \$\endgroup\$ – Aravindh Vasu Dec 4 '19 at 9:10
  • \$\begingroup\$ Does MODBUS, kind of say something like have a start and stop bit (like USART) \$\endgroup\$ – Aravindh Vasu Dec 4 '19 at 9:14
  • \$\begingroup\$ So when I connect a device to a RS485 port, I get a 1 for a particular difference-value between A and B and a 0 for some other difference value. Now MODBUS, tells us how to send this difference values, Am I right ? \$\endgroup\$ – Aravindh Vasu Dec 4 '19 at 9:16
0
\$\begingroup\$

Tom did give a clear answer but i try to simplify it for you

RS485 is a hardware specification like RS232 but for noisy situation. you don't have to deal with it since it's already done internally in both the usb converter (pc side) and the max232 (esp32 side).

Now since you asked about USART. you can forget about modbus and and exchange data using the UART with a start/stop bits...

But if you want to exchange larger block of data with different signification MODBUS is a software specification that help you do that by defining a a format for the packet of your data that you want to exchange:

Addr-Command-Data-CRC

Addr : Address of the device that you want to send to data to (since many device can be connected in the same line(bus) in the RS485 specifications)

Command : specify what type of data we are sending (e.g. read Temperature, Set Com Speed ....)

Data: e.g. temperature

CRC : check if the data is not corrupted after transmission (happen if many devices are in the same line try to communicate simultaneously, or if the line are too noisy too long ...)

Now you have to use google to read more about that.

PS: i never used MODBUS but i implemented multiple proprietary RS485 prototol

\$\endgroup\$

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