tobby
Hi, I'm testing Modbus RTU with Raspberry Pi as master and ESP32 as slave recently. In addition, Max485 is used as TTL to RS485 module.
 
 
There are three questions:
1. What's the meaning of serial1/serial2/serial3 in Modbus RTU Interface and Tx Pin (Figure1)?
2. Is it appropriate to set DE/RE pin on Max485 to low rather than blank program in slave program (Figure1)? 
 
Figure1:
[203128%2F8249146%2Fmceclip0]
 
3. Is it right to choose general RTU device rather than ESP32 in order to use Modbus RTU when adding new device on the web server (Figure2)?
 
Figure2:[203128%2F8249145%2Fmceclip0]
 
Thanks!
Reply 0 0
thiagoralves
1) For chips that have multiple UARTS, each one of the Serial (1, 2, 3, etc) refers to a particular UART inferface according to the Arduino framework.
 
2) DE/TE should be controlled by the pin you define on the “Tx pin”:  https://electronics.stackexchange.com/questions/153500/correctly-using-re-and-de-with-rs485
The pin number is in Arduino pin numbering format
 
3) Yes. If you pick esp8266 template it will force it to be added through Ethernet
Reply 0 0
tobby
2) Assume that I tie DE and RE together which are controlled by "Tx pin" and set "Tx pin" to GPIO16. How to set Tx pin to HIGH or LOW?  
 
[203128%2F8251481%2Fmceclip0]
Reply 0 0
thiagoralves
tobby wrote:
2) Assume that I tie DE and RE together which are controlled by "Tx pin" and set "Tx pin" to GPIO16.
Yes
 
How to set Tx pin to HIGH or LOW?  
You don’t. OpenPLC does that automatically for you
Reply 1 0
tobby
1. Master(RaspberryPi): Tie DE, RE pin of its Max485 together and controlled in program(FBD)(Figure2)
2. Slave(MH-ET live ESP32 Minikit): Tie DE, RE pin of its Max485 together and controlled them by setting "Tx pin" as 16(using GPIO16)(Figure3)
 
Master can't make the LED of slave on when running OPENPLC program. Here is the runtime logs below. I'm wondering where is going wrong?
I'm very grateful for your suggestion!
 
Runtime Logs:
OpenPLC Runtime starting...
Interactive Server: Listening on port 43628
Device esp is disconnected. Attempting to reconnect...
Connected to MB device esp
Warning: Persistent Storage file not found
Issued start_modbus() command to start on port: 502
Server: Listening on port 502
Server: waiting for new client...
Issued start_dnp3() command to start on port: 20000
DNP3 ID manager: Starting thread (0)
DNP3 ID DNP3_Server: Listening on: 0.0.0.0:20000
Issued start_enip() command to start on port: 44818
Server: Listening on port 44818
Server: waiting for new client...
Issued stop_pstorage() command
 
Figure1:
[203128%2F8262522%2Fmceclip0]
 
Figure2:
[203128%2F8262524%2Fmceclip0]
 
Figure3:
[203128%2F8262544%2Fmceclip0]
Reply 0 0
tobby
Hi thiagoralves, I am really thankful for your answering a few days ago. According to this issue above that I am still figuring out why, is it possible to communicate modbus rtu master(raspberrypi) and slave(esp32) via each UART pin(Rx/Tx) instead of USB port?
Thanks!
Reply 0 0
thiagoralves
TE/RE cannot be controlled by a PLC program. This is a hardware feature and therefore must be controlled by a driver. Perhaps the easiest way would be to have one of those RS485 USB adapters plugged into your Raspberry Pi.
Reply 0 0
Reply