Author Topic: Strange issue with RS485  (Read 16640 times)

0 Members and 1 Guest are viewing this topic.

Offline nardevTopic starter

  • Supporter
  • ****
  • Posts: 411
  • Country: ba
Strange issue with RS485
« on: February 07, 2024, 09:01:43 pm »
I just "solved" one issue and now a new one appeared. Strange one.

If you have any hint, i would be grateful a lot!


Ok, Three things:

 - Main Board OR Computer
 - "My RS485-to-Serial" module OR "Aliexpress RS-485 <-> TTL"
 - The Device

1. Computer communicates to "The Device" through both "My RS485-to-Serial" module OR "Aliexpress RS-485 <-> TTL"   - OK

2. My "Main Board" communicate just fine with "The Device" if i use "Aliexpress RS-485 <-> TTL"    - OK

3. However, if i use "My RS485-to-Serial" to communicate between "Main Board" and "The Device", it works partially.
    - If i send message from "Main Board" through "My RS485-to-Serial" module, it passes and "The Device" responds ok as long as i'm catching the response on the side. So, the TX on "My RS485-to-Serial" module is not connected to RX on "Main Board".
    - If i also connect Everythign as it should, the response never arrives from "The Device".

What's confusing is that it does work with of the self module in all situations but with my board it seems like when "return message" line is connected, everything is down.


I checked all the schematics, i had an issue with wrong capacitors but i changed it and everything should be 1:1 same as "Aliexpress RS-485 <-> TTL".

Here is the schematics (caps are corrected).


If you have any suggestion what to do now, how to check this, please.
 

Offline berke

  • Frequent Contributor
  • **
  • Posts: 258
  • Country: fr
  • F4WCO
Re: Strange issue with RS485
« Reply #1 on: February 07, 2024, 10:24:00 pm »
It seems that there is an attempt at automatically controlling the transmit enable using an R/C timer discharged using the data signal.  Could work but it's tricky and the timing needs to be right, so that part of the circuit looks suspicious to me.

Are you able to probe those signals (/RE,DE) with a scope or a logic analyzer at the same time as RXD/TXD and A/B to see what's going on?
 
The following users thanked this post: nardev

Offline nardevTopic starter

  • Supporter
  • ****
  • Posts: 411
  • Country: ba
Re: Strange issue with RS485
« Reply #2 on: February 08, 2024, 12:09:58 am »
I'm gonna try now with logic analyzer...
 

Offline ajb

  • Super Contributor
  • ***
  • Posts: 2607
  • Country: us
Re: Strange issue with RS485
« Reply #3 on: February 08, 2024, 02:13:33 am »
What does "as long as i'm catching the response on the side" mean?

So "The Device" has an RS485 interface, and your "Main Board" and computer are using the TTL side of the adapter?  What's the baud rate?  What did you correct the cap value to?

As pointed out in your other thread as well as by berke here, using a cap to control the transceiver direction is tricky and could be part of the problem if the cap value isn't exactly right.  It's worth checking that your stop bit configuration is the same between computer and "Main Board", a difference there could be part of the problem with this circuit. 

Since you have a second RS485-TTL converter and a computer, you could tap into the RS485 bus and view the activity in a serial terminal.  Seeing what appears on the bus might give a useful hint. 
 
The following users thanked this post: nardev

Offline nardevTopic starter

  • Supporter
  • ****
  • Posts: 411
  • Country: ba
Re: Strange issue with RS485
« Reply #4 on: February 08, 2024, 02:07:43 pm »
What does "as long as i'm catching the response on the side" mean?

So "The Device" has an RS485 interface, and your "Main Board" and computer are using the TTL side of the adapter?  What's the baud rate?  What did you correct the cap value to?

As pointed out in your other thread as well as by berke here, using a cap to control the transceiver direction is tricky and could be part of the problem if the cap value isn't exactly right.  It's worth checking that your stop bit configuration is the same between computer and "Main Board", a difference there could be part of the problem with this circuit. 

Since you have a second RS485-TTL converter and a computer, you could tap into the RS485 bus and view the activity in a serial terminal.  Seeing what appears on the bus might give a useful hint.

First of all, thank you.

"catching the response on the side" means that i wire TX from the device to a USB-Serial-Computer and catch the response.

Btw. in that case the RXD LED on this board actually blinks where if i connect botx RX/TX to TX/RX, RXD LED doesn't blink. Whic is unusual for me.

Yes, i used exact caps as are used on the "Off the self" RS485 board.

I'm just about to probe bot of the things, my Digilent was not available until now.




 

Offline ajb

  • Super Contributor
  • ***
  • Posts: 2607
  • Country: us
Re: Strange issue with RS485
« Reply #5 on: February 08, 2024, 03:52:57 pm »
Can you show a diagram of how everything is connected?  Specifically, do you have grounds connected between boards on the TTL and RS485 sides?  What you're describing with the RX line and the LED makes me think something isn't connected properly.  Worth checking the RS485 A and B connections, having one of those disconnected can cause weird intermittent operation sometimes.

And what's the baud rate? 
 

Offline nardevTopic starter

  • Supporter
  • ****
  • Posts: 411
  • Country: ba
Re: Strange issue with RS485
« Reply #6 on: February 09, 2024, 11:38:59 am »
The baud rate is 9600.

No, i did not connect grounds there.

Btw. Here is the scope difference, the aligned one is TX/RX on a working board and the one which is significantly shifted is the one which has the problem i was complaining about.

Here is more.


first one:
when my RS485 is plugged in as it should be, orange is TX from my board, blue is the response from "The Device" that i'm talking to

second one:
Same as above but the response TX from "The Dervice" is on the side and probed separately.
Ground connected between My device, through My RS485 and "The Device" i'm talking to.

third one:
Same as the second but Ground disconnected


fourth one:
The "Aliexpress" module which works ok, conencted between as it should be

p.s. third one i can't reproduce now...
« Last Edit: February 09, 2024, 12:05:52 pm by nardev »
 

Offline ajb

  • Super Contributor
  • ***
  • Posts: 2607
  • Country: us
Re: Strange issue with RS485
« Reply #7 on: February 09, 2024, 03:58:10 pm »
You need to run your scope at a much higher sample rate.  ~8ksps is nowhere near enough for even 9600 baud, you should be running at least 10x faster so you can see the individual bits in the serial stream properly. 

But the first trace does give a hint about the problem: since we can see that the blue trace is stuck near 3.3V, something is holding the TX line up. 
 
The following users thanked this post: nardev

Offline nardevTopic starter

  • Supporter
  • ****
  • Posts: 411
  • Country: ba
Re: Strange issue with RS485
« Reply #8 on: February 09, 2024, 10:11:08 pm »
You need to run your scope at a much higher sample rate.  ~8ksps is nowhere near enough for even 9600 baud, you should be running at least 10x faster so you can see the individual bits in the serial stream properly. 

But the first trace does give a hint about the problem: since we can see that the blue trace is stuck near 3.3V, something is holding the TX line up.

Thank you @ajb

Well, the bits are the same, it's just "looks" attenuated  when compared to the working module.

Which tells me that i should really check out the schematics again. Only things which could be slightly different is the hex inverted 5-6 that i used to power up the RX led.

Wondering, if that can ruin the signal?

p.s. removing R7/RXD, nothing changed
« Last Edit: February 09, 2024, 10:17:24 pm by nardev »
 

Offline nali

  • Frequent Contributor
  • **
  • Posts: 657
  • Country: gb
Re: Strange issue with RS485
« Reply #9 on: February 09, 2024, 10:26:27 pm »
What exactly are you probing here? The A & B lines?

RS485 as you have it here is a differential, half-duplex signal, so both A&B lines should have data for both devices transmitting (one should be the inverse of the other). There is no seperate RX & TX.
 
The following users thanked this post: nardev

Offline nardevTopic starter

  • Supporter
  • ****
  • Posts: 411
  • Country: ba
Re: Strange issue with RS485
« Reply #10 on: February 09, 2024, 10:30:07 pm »
What exactly are you probing here? The A & B lines?

RS485 as you have it here is a differential, half-duplex signal, so both A&B lines should have data for both devices transmitting (one should be the inverse of the other). There is no seperate RX & TX.

No, not A and BA. I'm only focused on TX/RX as i can confirm that A/B are consistent.

But here is another thing.

I just wired scope to R0 of MAX3485 and here is what i have got. Looks like this could be ok signal just not inverted.




« Last Edit: February 09, 2024, 10:32:39 pm by nardev »
 

Offline nardevTopic starter

  • Supporter
  • ****
  • Posts: 411
  • Country: ba
Re: Strange issue with RS485
« Reply #11 on: February 09, 2024, 10:42:29 pm »
Or completely different theory, something is not ok with my main controller board, despite the fact that it works ok with "Aliexpress board".
 

Offline nali

  • Frequent Contributor
  • **
  • Posts: 657
  • Country: gb
Re: Strange issue with RS485
« Reply #12 on: February 10, 2024, 09:21:17 am »
OK, in that case looks like you've got a short somewhere. Ajb mentioned it above, something's pulling txd high, so I'd guess you either have a short probably between pins 3&4 on J2, or maybe a defective U1.
 
The following users thanked this post: nardev

Offline mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 13748
  • Country: gb
    • Mike's Electric Stuff
Re: Strange issue with RS485
« Reply #13 on: February 10, 2024, 10:43:50 am »

No, i did not connect grounds there.

RS485 NEEDs a common round - without it you have no idea if the inputs are within the common-mode range of the receiver. There are some cheap 485 interfaces with no ground connection - throw them in the bin.

Trying to control TE with  an RC network will often end in tears. Use a proper interface with active TE control produced by the UART to accurately enable the transmitter.

When debugging RS485, a scope (even a cheap crappy one) is essential. RS485's intrinsic robustness can be its downfall, as even when the hardware is partly broken ( data line open/shorted, resistive connections, water ingress, flaky transceiver etc.), it can "sometimes" work, so you may not be aware of issues until something else changes ( cable length, common-mode voltage, Phase of the Moon etc.) and problems surface.
« Last Edit: February 10, 2024, 10:47:57 am by mikeselectricstuff »
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 
The following users thanked this post: nardev, tooki

Offline nali

  • Frequent Contributor
  • **
  • Posts: 657
  • Country: gb
Re: Strange issue with RS485
« Reply #14 on: February 10, 2024, 11:53:10 am »
Agree with avoiding the RC network if possible. Some converters just use the data line to enable the transceivers directly which sort of works but it's only using half the transciver to drive the Space and relying on bias resistors to bring the line back to Mark (if I've remembered by RS485 polarity correctly)

Below is from a commercial transceiver used by a company I used to work at. These were only used for a 1-1 connection at 9600 with a twisted-pair cable of 5-10m though they do claim 115k max and 4000 feet @19200
 
The following users thanked this post: nardev

Offline nardevTopic starter

  • Supporter
  • ****
  • Posts: 411
  • Country: ba
Re: Strange issue with RS485
« Reply #15 on: February 11, 2024, 12:13:06 pm »
Thank you all guys for looking into this.

Can't wait to come back home to check this again today.

@nali i can't trace any short there, wouldn't it be unusual that it works with PC<->USB-TTL<->My MAX485<->The Device but it doesn't work when instead of my computer and USB-TTL i switch to My Main controller board?

 

Offline nardevTopic starter

  • Supporter
  • ****
  • Posts: 411
  • Country: ba
Re: Strange issue with RS485
« Reply #16 on: February 11, 2024, 12:16:02 pm »
Here is the PCB traces, any clue there?

 :-//
 

Offline S. Petrukhin

  • Super Contributor
  • ***
  • Posts: 1146
  • Country: ru
Re: Strange issue with RS485
« Reply #17 on: February 11, 2024, 01:31:28 pm »
It seems to me that the main problem is the automatic switching of RX/TX.
It takes time for the transmitter to react and the line to discharge.

Personally, I don't like the idea with R5-C2 - you need to select the parameters so that the transmitter can switch, but the starting bit has not yet been completely eaten.

I did not understand the сhinese USB/RS-485, but it is likely that his USB/COM converter signals such as DTR/DSR are used there to control the transmitter, and they are formed not by the front of the incoming signal, but by the presence of a word in the buffer.

Moreover, using an uninsulated RS-485 is not the best solution.
And sorry for my English.
 
The following users thanked this post: nardev

Offline nardevTopic starter

  • Supporter
  • ****
  • Posts: 411
  • Country: ba
Re: Strange issue with RS485
« Reply #18 on: February 11, 2024, 11:53:48 pm »
weee..

new thing discovered but i still can't figure out why.

while connected to My Control main board, TX is connected to ground.

I have no idea why and how. But that explains why the signal is attenuated

However, the "Aliexpress board" doesnt" have that issue.

Also, i checked my board and all traces, also when it's disconnected and GND is definitely not connected to TX
 

Offline nardevTopic starter

  • Supporter
  • ****
  • Posts: 411
  • Country: ba
Re: Strange issue with RS485
« Reply #19 on: February 12, 2024, 01:17:51 am »
One more interesting finding

1. If i check continuity between GND and TX on "my RS485" board, while the board is disconnected from everything, i get very short buzz signal. and that's all. ALWAYS!

2. however, if i connect board to my device which is powered but turned off. So there is only GND connected to power source but power is off, there is continual buzzing sine between TC and GND.

Any help would be appreciated. Schematics is up there.

 |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O |O
 

Offline S. Petrukhin

  • Super Contributor
  • ***
  • Posts: 1146
  • Country: ru
Re: Strange issue with RS485
« Reply #20 on: February 12, 2024, 07:59:07 am »
Obviously, there is a high potential between the two devices.
You can measure it between the GND of two devices. But do not try to connect the GND of two devices - this can be disastrous.

I have already told you that an uninsulated RS-485 is not the best option.
Use ADM2582 or ADM2682 - it is as convenient as possible.
Or isolate your transmitter with optocouplers and separate power supply.
And sorry for my English.
 
The following users thanked this post: nardev

Offline ajb

  • Super Contributor
  • ***
  • Posts: 2607
  • Country: us
Re: Strange issue with RS485
« Reply #21 on: February 12, 2024, 05:03:34 pm »
while connected to My Control main board, TX is connected to ground.

I have no idea why and how. But that explains why the signal is attenuated

Not really, because your scope traces show that TX is pulled UP to 3.3v, not down to Gnd.  So there's something else going on.  But I think you may have measured incorrectly, see below.

1. If i check continuity between GND and TX on "my RS485" board, while the board is disconnected from everything, i get very short buzz signal. and that's all. ALWAYS!

Don't use the continuity mode. Use regular resistance mode, and measure with the meter probes both ways around.  There is active circuitry connected to these pins, with things like ESD diodes and input/output transistors, which can cause misleading measurements.  Exactly what happens depends on the circuitry and the meter you use, but if you see different resistance measurements when you swap the probes, then you know something tricky is going on. 

If you want further help, please provide more information.  Photos or diagrams showing CLEARLY how EVERYTHING is connected would help a lot.  Your descriptions aren't very clear and it's hard to understand how you have everything set up.  That makes it very hard to help you.

Obviously, there is a high potential between the two devices.

No, there's no indication of that at all.  There could be, but OP has not provided any information that suggest that is the case.

Quote
But do not try to connect the GND of two devices - this can be disastrous.

No, ground needs to be connected between all devices on both the TTL UART side AND the RS485 side.  RS485 requires a common connection to work properly. 

Quote
I have already told you that an uninsulated RS-485 is not the best option.
There is nothing wrong with a non-isolated RS485 link in most cases.  RS485 is specifically designed to work with a common mode voltage offset of several volts.  There are some situations that benefit from isolation, but no reason to believe that OP's situation would, or that isolation would solve the problems OP is experiencing. 
 

Offline S. Petrukhin

  • Super Contributor
  • ***
  • Posts: 1146
  • Country: ru
Re: Strange issue with RS485
« Reply #22 on: February 12, 2024, 05:21:10 pm »
If there is a grounding system, of course, it must be connected.
But you can not connect GND together - one of the sources can become a conductor for displacement and is quite rigid.
It is necessary to make sure that this does not happen.

But this does not guarantee the absence of a sufficiently high potential bias.
The sluggish glow of the LED and the ringing just hint at this, an unnecessary current is flowing somewhere.

Modern switching power supplies are not always good and often have the sin of bias.
And sorry for my English.
 

Online tooki

  • Super Contributor
  • ***
  • Posts: 11561
  • Country: ch
Re: Strange issue with RS485
« Reply #23 on: February 12, 2024, 05:30:12 pm »
If there is a grounding system, of course, it must be connected.
But you can not connect GND together - one of the sources can become a conductor for displacement and is quite rigid.
It is necessary to make sure that this does not happen.
This is completely untrue and incorrect. See e.g. the response from TI in https://e2e.ti.com/support/interface-group/interface/f/interface-forum/923991/ground-connections-in-isolated-rs485-system
 

Offline S. Petrukhin

  • Super Contributor
  • ***
  • Posts: 1146
  • Country: ru
Re: Strange issue with RS485
« Reply #24 on: February 12, 2024, 06:07:16 pm »
If there is a grounding system, of course, it must be connected.
But you can not connect GND together - one of the sources can become a conductor for displacement and is quite rigid.
It is necessary to make sure that this does not happen.
This is completely untrue and incorrect. See e.g. the response from TI in https://e2e.ti.com/support/interface-group/interface/f/interface-forum/923991/ground-connections-in-isolated-rs485-system

TI has closed access to its website for Russia. They think closed...  :)

However. Give me specifically what TI refutes my words?
Do the devices not need to be grounded or can you safely connect GND togever?

In addition, TI strangely equates PE to GND - I doubt the qualifications of the specialist who gave such answer.  :-//
I'm talking about the isolated transmitter example.

PE is never equal to GND for a normal engineer, but there is connection. Personally, I install a 1nF 2.5kV capacitor and a 1 MOm resistor between PE and GND.

And pay attention, in that answer talking about an isolated transmitter.
That is, the linear part of the transmitter is connected to one side and isolated from the other.
There will be no significant bias at the different ends of the twisted pair.
I wrote about this earlier too - as a more reliable way.
And sorry for my English.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf