有朋友测试过esp32当 modbus slave从站(我拿的esp32当从站,用的是RTU模式)吗? 我用modbus poll软件测试下来,主站这边一直收不到从站的modbus响应报文,不知道啥情况
但是从esp32的日志打印来看,从站这边确实是可以收到主站的请求报文的,但是主站就是收不到从站的响应报文,也没看到esp32有什么报错,大概可以从哪些角度去排查问题呢,谢谢大家了。
esp32当 modbus-rtu slave从站通讯,但是主站收不到从站的响应报文
-
- Posts: 211
- Joined: Fri Feb 01, 2019 4:02 pm
- Contact:
Re: esp32当 modbus-rtu slave从站通讯,但是主站收不到从站的响应报文
Hi @andycui,
Could you check the RS485 communication interfaces if they can work in both directions? The uart RS485 echo test https://github.com/espressif/esp-idf/tr ... echo_rs485 can help with this.
Then you need to check the slave response time in your master and also check that your master and ESP32 slave example configured correctly to use RTU communication mode (CONFIG_MB_COMM_MODE_RTU) in kconfig. Also check the CONFIG_MB_SLAVE_ADDR address of the slave and make sure that the Modbus Poll is sending the data to this address.
Thanks.
Could you check the RS485 communication interfaces if they can work in both directions? The uart RS485 echo test https://github.com/espressif/esp-idf/tr ... echo_rs485 can help with this.
Then you need to check the slave response time in your master and also check that your master and ESP32 slave example configured correctly to use RTU communication mode (CONFIG_MB_COMM_MODE_RTU) in kconfig. Also check the CONFIG_MB_SLAVE_ADDR address of the slave and make sure that the Modbus Poll is sending the data to this address.
Thanks.
Re: esp32当 modbus-rtu slave从站通讯,但是主站收不到从站的响应报文
thanks, there is, in addition, I don't have RTS pin in my usb-to-485 adaptor, so how should i do?
And, Here is my code
And, Here is my code
Code: Select all
ESP_ERROR_CHECK(uart_set_pin(MB_PORT_NUM, CONFIG_MB_UART_TXD,
CONFIG_MB_UART_RXD, UART_PIN_NO_CHANGE,
UART_PIN_NO_CHANGE)); //CTS is not used in RS485 Half-Duplex Mode
// Set UART driver mode to Half Duplex
ESP_ERROR_CHECK(uart_set_mode(MB_PORT_NUM, UART_MODE_RS485_HALF_DUPLEX));
-
- Posts: 211
- Joined: Fri Feb 01, 2019 4:02 pm
- Contact:
Re: esp32当 modbus-rtu slave从站通讯,但是主站收不到从站的响应报文
@andycui ,
If RS485 part of your USB-RS485 adapter uses the auto-switching of direction like on the link below then your code should work just fine.
https://docs.espressif.com/projects/esp ... r-receiver
I think you need to check your adapter schematic to get more details on why it does not work. What is clear it can not switch the direction of the RS485 line in Half Duplex.
If RS485 part of your USB-RS485 adapter uses the auto-switching of direction like on the link below then your code should work just fine.
https://docs.espressif.com/projects/esp ... r-receiver
I think you need to check your adapter schematic to get more details on why it does not work. What is clear it can not switch the direction of the RS485 line in Half Duplex.
Who is online
Users browsing this forum: No registered users and 59 guests