Modbus with different variations

Thread Starter

anukalp

Joined Jul 28, 2018
158
Could someone guide me what we need to understand about Modbus ?

From what I gather, Modbus seems to be a protocol that is used to exchange data between two devices like microcontroller and temperatures via rs485. I am being confused with different variations such as Modbus RS485 , Modbus TCP/IP, Modbus RTU.
 

Ian0

Joined Aug 7, 2020
13,097
The most common form of Modbus is Modbus RTU which is sent via RS485. The other form is Modbus ASCII which works the same way but the numeric information is sent as ASCII text rather than 16-bit numbers.
Modubs TCP/IP is the same as Modbus RTU, but instead of being sent by RS485 it is sent over Ethernet via TCP messages.
There is a good explanation on Wikipedia.
Modbus is easy. It might not look easy when you first see it, but when you see the alternative (Bacnet) then it starts to look easy.
 

Thread Starter

anukalp

Joined Jul 28, 2018
158
It might not look easy
Hey there,

I'm need help to establish a generic Modbus network with a master microcontroller and several slave devices, including a temperature sensor, motor, and switch. It seems we'd need a minimum of three RS485 modules to wire these devices individually. I am assuming rs485 interface not Ethernet.

What's your take on this setup? Any additional requirements I should consider?
 

Ian0

Joined Aug 7, 2020
13,097
Are you interfacing directly to a temperature sensor, or are you interfacing to a temperature sensor that already has a Modbus interface?
If it has terminal blocks, then it's RS485 Modbus. If it is Ethernet it will have an RJ45 connector.
 

Thread Starter

anukalp

Joined Jul 28, 2018
158
If it has terminal blocks, then it's RS485 Modbus. If it is Ethernet it will have an RJ45 connector.
So, observing the terminal blocks for RS485 or an RJ45 connector for Ethernet can provide valuable information

Assuming we have setup involving one master microcontroller and two slave devices, each with different interfaces - one employing RS485 and the other using an RJ45 connector.

In this scenario within a MODBUS setup, I'm curious about how the master microcontroller determines which slave it intends to communicate with and how it ensures it's engaging the correct slave device.

It seems each salve has unique adress as all I2C devices

I am trying to understand basic frame of modbus protocol.

how the master identifies and communicates with the specific slave devices within the MODBUS network? Additionally, how does the master ascertain that it's communicating with the intended slave?
 

nsaspook

Joined Aug 27, 2009
16,250
Your code contains and 'knows' all of the slave ID's and expected return responses.
For canned static messages and responses the MODBUS code can be very simple.
https://raw.githubusercontent.com/nsaspook/ihc_mon/re20a/ibsmon.c

1702138150255.png
Half-Duplex 485
Exchange sequence:
The Master asserts TX control of the BUS and sends data , releases the bus and switches to RX mode. Master waits for Slave response for some short period of time. If that short period of time passed with no response, there is a error.
Response:
The selected Slave receives the message, does the required action, the Slave asserts TX control of the BUS and sends response data, releases the bus and switches to RX mode for the next Master command.

Repeat.
 
Top