RS-485, swapping A and B signals

Go To Last Post
21 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Does anyone know if RS-485 transceivers still work if connected incorrectly, ie A->B and B->A.

I'm hoping that the data will simply be inverted (which can be dealt with in software) but don't know if that is the case and have no hardware to try.

______
Rob

Scattered showers my arse -- Noah, 2348BC.
Rob Gray, old fart, nature photographer, embedded hardware/software designer, and serial motorhome builder, www.robgray.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For the most part, yes, your data should just be inverted.

However, sometimes pull-up and pull-down resistors are placed on the board to put the bus into a known state when it isn't being driven, and in that case switching A and B could potentially cause issues.

What are you trying to accomplish?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Can you deal with inverted framing(start and stop bits) in software? Not with an AVR, as far as I know(unless it's a software UART).
However, as this is general electronics, maybe I shouldn't jump to any conclusions.

Four legs good, two legs bad, three legs stable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
What are you trying to accomplish?

PIB (Plug In Backwards) proof network.

I've been working on a network design for some time, lately I've been reviewing the type of connectors to use and have decided on RJ11/45 with two sockets per Node to allow easy daisy-chaining.

The trouble is if you wire the two sockets in parallel you have to use crossover cables. If you do the crossover on the PCB your connectors are different and you have to have an "upstream" and "downstream" connectors and this is prone to plugging things in wrong.

So...

By adding a diode bridge to each Node it doesn't matter which way around the power is, that leaves the data.

If the data is simply inverted I can handle that with software and I now have a system that is PIB proof.

Quote:
sometimes pull-up and pull-down resistors are placed on the board

Hmmm, bias resistors. As this is my own design I specify what it has. Originally I spec'd auto direction 485 drivers with bias resistors on the master PCB. I did this because I wanted to detect bus clashes at the bit level. I'm no longer worried about this and so should be able to lose the bias resistors.

The end result is that some Nodes could be AB and some BA, but as long as the processor on each Node knows which it is and inverts its RX/TX accordingly it should work.

Shouldn't it?

_____
Rob

Scattered showers my arse -- Noah, 2348BC.
Rob Gray, old fart, nature photographer, embedded hardware/software designer, and serial motorhome builder, www.robgray.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Can you deal with inverted framing(start and stop bits) in software?

Sorry John, we crossed posts.

The answer is yes, I see most Nodes using an ATtiny85/84s and as these don't have UARTs the serial will be bit banged. A larger Node (or the master controller) will have a UART, in this case an XOR gate may have to be used to invert the data or not depending on the connection.

Scattered showers my arse -- Noah, 2348BC.
Rob Gray, old fart, nature photographer, embedded hardware/software designer, and serial motorhome builder, www.robgray.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If all of the slaves can deal with either polarity, there's no need to swap polarity in the master. Slaves using UARTS will either need the XOR or will need to run the same bitbang code.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
there's no need to swap polarity in the master. Slaves using UARTS will either need the XOR or will need to run the same bitbang code.

Yes that's true.

Scattered showers my arse -- Noah, 2348BC.
Rob Gray, old fart, nature photographer, embedded hardware/software designer, and serial motorhome builder, www.robgray.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Do you not know an easier way to get into trouble?

HM

HM

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Are you saying? By placing a XOR between the 485 RX and the Micro, if you detect FE, you then set an IO line connected to XOR input, Comms will be restored.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

HM, do you know an easier way to have polarity independence :)

Quote:
Are you saying? By placing a XOR between the 485 RX and the Micro, if you detect FE, you then set an IO line connected to XOR input, Comms will be restored.

That's essentially the case, but I don't wait for a framing error. The Nodes don't try to read data until they have synced with the network. To do this they wait for an idle period by timing from the last transition.

This has always been in the spec, I think the only difference is testing the level of the line after the timing is done. IE

what_for_idle();
if (line == high) 
   polarity = normal;
else
   polarity = inverted;

I'm happy to hear arguments for/against, but I think this should work. Likewise if there's a better way I'm all ears.
______
Rob

Scattered showers my arse -- Noah, 2348BC.
Rob Gray, old fart, nature photographer, embedded hardware/software designer, and serial motorhome builder, www.robgray.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'd put a DPDT switch to swap the 2 lines.

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks Bob but I want auto detection and correction plus I don't have room for switches. Normal Nodes are about 1x1" but I can squeeze some into 1/2x1/2" so any form of switch is out of the question.

______
Rob

Scattered showers my arse -- Noah, 2348BC.
Rob Gray, old fart, nature photographer, embedded hardware/software designer, and serial motorhome builder, www.robgray.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Intersil makes some rs485 transceivers that handle reverse polarity. try ISL32483E & ISL32485E

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for that, a very interesting chip I'll have a good look at the specs.

As it happens I'm just laying out PCBs so it's not too late to use them.

______
Rob

Scattered showers my arse -- Noah, 2348BC.
Rob Gray, old fart, nature photographer, embedded hardware/software designer, and serial motorhome builder, www.robgray.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Every RS485 gizmo I have tried to hook up has a problem with getting A and B hooked up right. I'd say use 1 wire. If you have 5V of noise (Good Grief!) use 12V. How fast? How far?

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Every RS485 gizmo I have tried to hook up has a problem with getting A and B hooked up right.

Exactly why I want to auto detect and correct the polarity. Also with each node having two sockets for easy daisy-chaining there are issues with using crossed or straight cables. So I figured let's remove all that crap by adding a small amount of hardware and code logic.

Quote:
I'd say use 1 wire.

I originally used LIN, for this reason, but I dropped it partly because of the number of nodes allowed (although this is arbitrary because of a 4-bit address and I'm not using the LIN protocol) but mainly because 485 is such an industry standard.

Quote:
How fast? How far?

Slow, I'll be happy with 19200. Length? Who knows, at least 30M in a noisy (vehicle) environment but potentially much longer in a "process control" situation.

I've done most of the small node PCBs (about 10-11) so can't really change the phy level now, I can still change the actual transceiver chip used though on the remaining boards.

______
Rob

Scattered showers my arse -- Noah, 2348BC.
Rob Gray, old fart, nature photographer, embedded hardware/software designer, and serial motorhome builder, www.robgray.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, I used a scheme where I pull B up to 5V and run it to an input. When the bus is in listen, B is hi. When it is in talk mode, B goes lo. So each node can tell when the bus is idle. I used a 'delay the same number of ms as your node number' before trying to transmit. Collision avoidance? So if you plug in and B is lo, you're looking at A, so turn on the swapper.

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
When the bus is in listen, B is hi. When it is in talk mode, B goes lo.

How do you differentiate between an idle line and a high bit?

This is a master/slave setup so (in theory) there shouldn't be any clashes but I will also detect clashes at the byte level and hopefully handle that in the protocol.

Idle detect is by timing from edges, if there's been N bit times since the last edge we have an idle line. At that point however the slaves do nothing but monitor the line for a packet from the master.

Quote:
I used a 'delay the same number of ms as your node number' before trying to transmit.

Also allows a type of priority if you can organize the addresses.

______
Rob

Scattered showers my arse -- Noah, 2348BC.
Rob Gray, old fart, nature photographer, embedded hardware/software designer, and serial motorhome builder, www.robgray.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
HM, do you know an easier way to have polarity independence

If it is a software driven, why don't you use Manchester encoding? Ethernet uses it and it works perfectly..

No RSTDISBL, no fun!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, most of the nodes use software-driven comms, I like Manchester encoding and would like an excuse to use it but I don't see how it helps with the polarity, you would still need to detect that and use true/false or false/true logic with the encoding.

Unfortunately some devices will use hardware UARTs, so it's a moot point I guess.

______
Rob

Scattered showers my arse -- Noah, 2348BC.
Rob Gray, old fart, nature photographer, embedded hardware/software designer, and serial motorhome builder, www.robgray.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
but I don't see how it helps with the polarity,

It is polarity-independent.
Quote:
you would still need to detect that and use true/false or false/true logic with the encoding.

No, you would not. Only pullups/pulldowns need to be software controlled, but can be easily made software driven, if needed.

Anyway, AVRs do not use Manchester encoding.

No RSTDISBL, no fun!