Proper way to control RS485 half-duplex DE and RE pins - ESP32 #9491
Replies: 4 comments 7 replies
-
What I have found on the internet as "RS485 solutions" are:
|
Beta Was this translation helpful? Give feedback.
-
I have no idea what the DE and RE pins are supposed to do. "The proper way" would be to use the ESP32/ESP-IDF half-duplex mode (see https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/uart.html). There is a You could try to wait in micropython for |
Beta Was this translation helpful? Give feedback.
-
That's right. uart.flush() does not return until all bytes have been sent. There is a timeout as fallback to avoid permanent blocking, but that is huge, like 2 times the time it requires to send a full UART transmit buffer, which by default is 256 bytes. |
Beta Was this translation helpful? Give feedback.
-
Just got time to whip up a max485 and tested a bit. Seems to work. It seems that this .flush() feature is only available in the nightly build 1.19.x versions (unstable). The most recent stable version 1.19.1 doesn't have it (checked it and it didn't exist). So is there any projection when a stable version will be released? Thanks. BTW, I've been using 1.17 from 2019 and its .mpy isn't recognized by 1.19. I guess I have to think hard what to do with already deployed units. Maybe only support RS485 on new units? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I wonder if there is a proper way to drive the DE and RE pins of an RS485 half-duplex transceiver like MAX485 with ESP32 micropython. I've read that for an atmega328 for instance there is a TX complete interrupt that is designed to help with half-duplex so when the TX buffer and shift register are both clear, this interrupt calls the service routine to disable DE and enable RE. So on ESP32 specifically, are there any way to do a similar thing? The heuristic way would be waiting some fixed amount of time in micropython before disabling DE and enabling RE. But, since micropython is not necessarily that fast, and I'm expected to have 115200 baud rate, I don't like the wait method. The delay between the other device receiving my command and issuing a response is not well defined because I want to support multiple brands of RS485 devices.
I have a few full-duplex RS485 devices that I used with a MAX490 full-duplex transceiver and ESP32. That worked. I might be able to wire them to run at half duplex. I also have a sensor with half-duplex that I could use for tests.
Beta Was this translation helpful? Give feedback.
All reactions