RS485 problems

ndjurov
Posts: 65
Joined: Wed Mar 25, 2020 11:34 pm

RS485 problems

Postby ndjurov » Wed Aug 18, 2021 8:20 pm

Do you have any idea what else to try?

The ESP32 WROVER-E based board that I'm using is must use RS485 to talk to another controller.
It has SP485EE IC with all pins controlled individually (no link between DE and RE).
The first byte I'm sending 0xFD goes through, but I'm not receiving the response, although I see that the other side is getting 0xFD and sending proper response.
I connected logic analyzer and I'm hoping that some of you may have an idea what is going on.

logic analyzer is connected like this:
RS485_TXD = DI = CH1 – Data being transmitted and it is 0xFD, just like logic analyzer shows.
RS485_TXEN = DE = CH3 – Driver Enabled – High all the time (This may wrong according to the logic tables below).
RS485_RXEN = RE = CH5 – Receive Enabled – Low all the time, except during data Tx
RS485_RXD = RO = CH7 – Received data – Nothing but a spike (seen as a “framing error”), no data although it is being sent by the other side, after it properly receives the 0xFD byte.
CH9 is not connected to anything

The code uses:
#define PIN_TXD_DI (26)
#define PIN_TXEN_DE (2)
#define PIN_RXEN_RE (19)
#define PIN_RXD_RO (32)


And it sets UART like:
uart_set_pin(UART_NUM_2, PIN_TXD_DI, PIN_RXD_RO, PIN_RXEN_RE, PIN_TXEN_DE)

It also sets mode to UART_MODE_RS485_HALF_DUPLEX

The example in esp-idf (https://github.com/espressif/esp-idf/tr ... echo_rs485) shows RE and DE pins shorted so it is not applicable for the way this transceiver is wired.

Thanks a lot for your time and ideas.

RS485LA.jpg
RS485LA.jpg (48.12 KiB) Viewed 4789 times
RS485LA1.jpg
RS485LA1.jpg (48.89 KiB) Viewed 4789 times
RS485 TT.jpg
RS485 TT.jpg (25.47 KiB) Viewed 4789 times

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: RS485 problems

Postby WiFive » Wed Aug 18, 2021 10:31 pm

Yes why don't you try connecting DE and RE?

ndjurov
Posts: 65
Joined: Wed Mar 25, 2020 11:34 pm

Re: RS485 problems

Postby ndjurov » Wed Aug 18, 2021 11:09 pm

Thanks a lot WiFive,
I was hoping to have it working with no HW changes. I thought this was the most straight-forward connections, but now I'm not sure.
I don't know if the same can be achieved by assigning the same GPIO to both DE and RE. Probably not - I guess they have to be connected physically and RE should not have any GPIO assigned to it, is that right? Easy to test.

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: RS485 problems

Postby WiFive » Thu Aug 19, 2021 1:22 am

It might work to set both output pins connected to the rts source in the gpio matrix

ndjurov
Posts: 65
Joined: Wed Mar 25, 2020 11:34 pm

Re: RS485 problems

Postby ndjurov » Fri Aug 20, 2021 7:13 pm

Thanks a lot WiFive,

I'm now setting the driver in "normal" - UART mode and controlling the RE and DE lines myself. It took some time to get the timing right, but I think it is now OK. What I see using a scope and an LA is that the SP485EE transceiver sends a byte which can be seen on A and B lines, that the other side responds by putting a response byte back on A and B lines (probed straight on SP485E legs), but the SP485EE receiver never converts this byte from A and B to Rx. Once I get another board I'll try the same and that will hopefully tell me if the transceiver is wrong. So far the waveform looks very clear except that the scope told me that data on A and B lines have very different voltages, depending whether it was sent by the SE485EE or another RS485 adapter, on the other side of the communication line.
Thanks a lot.

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: RS485 problems

Postby WiFive » Fri Aug 20, 2021 7:40 pm

Sp485 is a 5v transceiver so you should be using sp3072 or something 3.3v with esp32 or using dual supply with a level shifter but I don't know if that accounts for your problems.

ndjurov
Posts: 65
Joined: Wed Mar 25, 2020 11:34 pm

Re: RS485 problems

Postby ndjurov » Thu Aug 26, 2021 5:59 pm

Thanks a lot WiFive. I just got another board and hoped that it would behave better than the previous one, but I got the same issue. I'll try the transceiver you suggested for sure First - it can't hurt and second - I don't really know what else to test.
Cheers.

ndjurov
Posts: 65
Joined: Wed Mar 25, 2020 11:34 pm

Re: RS485 problems

Postby ndjurov » Tue Aug 31, 2021 12:41 am

One more question about the serial communication.
Our ESP32-WROVER-E application runs on a custom board and transmits on GPIO pin 26 and receives on GPIO pin 32. It is using RS485 transceiver, but I had no luck initializing the communication by putting UART driver in RS485 half-duplex mode. So, I put it in "normal" mode, and control Tx enable and Rx enable transceiver lines manually. In order to receive data, this chip RE (receive enable) pin needs to be kept low all the time and when it gets differential data on A and B, it will produce output on RO (receiver output) line, which is connected to ESP32 Rx line - GPIO 32. Before data is sent, the application enables transmit driver (DE line), keeps it high for some time during and after the transmission and the other side gets all the data correctly. It sends response which reaches the transceiver, which sets RO line, but only to 1.6 Volts. So ESP32 GPIO 32 gets only that low voltage and doesn't recognize that as the response data for the ESP32 application. I was thinking that maybe something else interferes with GPIO32, so I called gpio_config() to disable both pull-up and pull-down resistor on this pin. Now I can see 2.7 volts, ESP32 recognizes as data and passes it to the application. It all works, although 2.7V is also low.
My question is - is there something on WROVER-E that is used by the system that uses GPIO32 and messes up with our serial communication?
Thanks a lot.

Who is online

Users browsing this forum: elDi@mond and 130 guests