I have configured my Hardware Serial USART_1 in PA9 as Tx and PA10 as Rx and PC14 as USART_ENABLE to the maxRS485. Whenever I need to send data from microcontroller_1 to microcontroller_2, then I have to make my eable pin HIGH for microcontroller_1 and LOW for microcontroller_2. Then when I need to send data from microcontroller_2 to microcontroller_1 then I have to change the enable pin as HIGH for microcontroller_2 and LOW for microcontroller_1.
I think the above configuration works in the principal of MODBUS protocol. For say, let us make
microcontroller_1 as
Master and
microcontroller_2 as
Slave. If
Master wants request any data from
Slave, then the
enable_pin of
Master must be
HIGH for requesting the slave to send data of the I2C communication (lets say temperature sensor) which is already implemented in Slave device and the the
enable_pin of
Slave must be
LOW in order to recive the message from Master.
Now slave process the requested message which was sent by Master and send back the required data to the Master. To send back the back the data
from Slave to Master, the the
enable_pin of
Slave must be
HIGH and the the
enable_pin of
Master must be
LOW. In order to recive the required data from the Slave to the Master.
The slaves need to know their own addresses, for uart, those control selection lines are not needed, you can keep them enabled throughout.
I do not understand clearly, I do not get the point why you said this.
It is a 'simplex' protocol where it is pretty much request / response and the request is only from the master.
Lets say I have four microntrollers. Each has several sensors with I2C communication having their own addressess. And
one of the microntroller should act as
Master and get all the datas from the
other microntrollers (slave microcontrollers). And this
Master microcontroller will process with all the datas it got from the sensors which it has and also from sensor data values which it got from
other microcontrollers (slave microcontrollers).
So, I dont think it must be simplex protocol. As you said, yes it is pretty much request and response and the request is from Master and the response is from Slave.
But the Slave micontroller needs to give back the required message to the master microcontroller.
I think modbus can be done on tcp, ethernet etc. it is pretty much not tied to the underlying hardware transport.
Yep, just in recent days, MODBUS is done on TCP or Ethernet or whatever availble.
MODBUS is also capable of hardware transport with the physical hardware RS485.
I think 'simplex' request (master) / response (slaves) is pretty much necessary, as otherwise u'd need to deal with collision detection if multiple slaves transmit at the same time.
I think for collision, I can send request from Master to all the other slave microcontrollers to send the required data one by one.
Modbus isn't the only one implementing such protocols, USB has been doing this all along, and it is done for all the millions (billions?) of desktop / laptop and single board computers.
Yes, your right, but now availble hardware configuration is suitable only for MODBUS protocol I think.
Also, I am attaching the similar image of my MODBUS communication with RS485 between my microcontrollers (consider those Arduino's as my custom made PCB's with STM32F103C8T6 chip running in STM32 official core). I am adding this just for refference purpose.