Xmega usart using RS485 lines

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

Hi all,

I need some help on this topics.

I am using the RS485 to do communication with a few of the device in full duplex.

There is a master controlling the lines. The baud rate is 921600.

The problem is sometime my device cannot receive the protocol.

I am using ATxmega64A3U running at 32MHz.

Thanks in advances

ChawCS

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

Are you aware that 485 does not support full duplex?

Perhaps you are using 422? Something else?

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

 full duplex

Perhaps you are aware of this already, but it might be worth mentioning.

 

 

Full Duplex means that both parties, (devices), can transmit simultaneously, at the same exact time.

 

Simplex means that only one part can transmit at a time.  One might have two-way communications, but only one party can transmit at any given moment.

Then the other party might transmit a reply, if desired. 

 

Classically, Full Duplex used two communications channels.

Those channels could be separate sets of wires, separate transmission frequencies, etc.

Simplex used one communications channel, and both parties shared the channel, and could not both use it at the same time.

 

These days, with high speed time division multiplexing and data packets, it is possible to simulate a duplex communications system, using a single communications channel.

 

Many Master/Slave setups might share a single communications channel, be it wired or RF, and have two-way communications; yet they take turns using the communications link, and the system is actually simplex, not duplex.

 

JC

 

Edit:

I guess one has to be careful with the above definitions.

 

Wiki Duplex telecommunications agrees with the above Duplex def'n, Duplex supports two simultaneous comm's paths.

"Duplex", in this regard, is an abbreviation of "Full Duplex", which clearly states the dual comm paths.

 

The above further defines: Half Duplex is defined as bi-directional comm's, but not simultaneously, (e.g. a walkie-talkie, or Push-to-Talk systems).

 

And, for completeness, it notes that simplex comm's allow only one device to transmit, the other device is listen only, (e.g. commercial radio station, garage door opener, etc.)

This is one way comm's only.

 

However:

Wiki Simplex communications starts off by saying that it supports comm's in one direction only, AND then goes on to state that the ITU and the NFPA both use the term Simplex to describe half-duplex systems, where two way comm's is present, but not simultaneously,  (e.g. a walkie-talkie, or Push-to-Talk systems).

 

The National Association for Amateur Radio, (ARRL), also, in its glossary, defines Simplex as Transmitting and Receiving on the same frequency, (i.e. two way communications, but not simultaneously).

Gotta love it, the ARRL Simplex definition then refers one to the Duplex definition, which isn't included in the glossary...

 

JC

 

 

 

 

Last Edited: Wed. Jun 3, 2015 - 12:07 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Full-duplex means both parties can Tx simultaneously.

 

Half-duplex mean both parties can Tx, but must takes turns.

 

Simplex means one and only one party can Tx ever.

 

You can most definitely do full-duplex with RS-485.  I used to work on entry systems that did so.  It requires a single master whose Tx pair is tied to the Rx pairs of all the slaves and whose Rx pair is tied to all the Tx pairs of the slaves.  Collisions are avoided by having the slaves only Tx when selected by the master.  The selected slave can Rx while it is Tx'ing.

 

Chawcs, what wire lengths are you using?  Are you following the manufacturers recommendations for the RS-485 transceivers as far as grounding, cross-talk, etc. are concerned?

Greg Muth

Portland, OR, US

Xplained/Pro/Mini Boards mostly

 

Make Xmega Great Again!

 

Last Edited: Sun. May 31, 2015 - 06:24 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You can most definitely do full-duplex with RS-485.  I used to work on entry systems that did so.  It requires a single master whose Tx pair is tied to the Rx pairs of all the slaves and whose Rx pair is tied to all the Tx pairs of the slaves.  Collisions are avoided by having the slaves only Tx when selected by the master.  The selected slave can Rx while it is Tx'ing

That sounds more like RS-422 to me Greg but maybe my definitions are off.

 

If my understanding is correct, RS-485 is a single bi-directional channel on which only 1 device can transmit at a time.

RS-422 from what I understand is effectively 2 x RS485 channels; 1 x Tx, 1 x Rx. Multiple access can certainly be achieved as you describe.

 

Note that a chip designed for RS-485 will typically have the driver and receiver pins (A/B or +/-) connected together as only a single channel is expected for use in half-duplex.

Chips targeted for RS-422 will have separated driver and receiver (commonly designated A/B and Y/Z).

There are also driver chips compatible with both 422 & 485 and have controls to connect/disconnect the bus pins internally as required.

 

Steve

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

You can most definitely do full-duplex with RS-485.  I used to work on entry systems that did so.  It requires a single master whose Tx pair is tied to the Rx pairs of all the slaves and whose Rx pair is tied to all the Tx pairs of the slaves.  Collisions are avoided by having the slaves only Tx when selected by the master.  The selected slave can Rx while it is Tx'ing

That sounds more like RS-422 to me Greg but maybe my definitions are off.

 

If my understanding is correct, RS-485 is a single bi-directional channel on which only 1 device can transmit at a time.

RS-422 from what I understand is effectively 2 x RS485 channels; 1 x Tx, 1 x Rx. Multiple access can certainly be achieved as you describe.

 

Note that a chip designed for RS-485 will typically have the driver and receiver pins (A/B or +/-) connected together as only a single channel is expected for use in half-duplex.

Chips targeted for RS-422 will have separated driver and receiver (commonly designated A/B and Y/Z).

There are also driver chips compatible with both 422 & 485 and have controls to connect/disconnect the bus pins internally as required.

 

Steve

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

Greg Muth

Portland, OR, US

Xplained/Pro/Mini Boards mostly

 

Make Xmega Great Again!

 

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

Hi Steve,

I had been looking at this topic since start of this project.

It get confuse on the RS485 and RS422, there a lot of different explation on this.

Rs422 - I understand is a 4=20mA current loop, but if you see most of the RS485 IC it can be wire as RS485 or RS422.

The problem is that my hardware is a 4 wire system, with 2 wire for the transmissions, balancing.

It had a termination resistor at the end.

Any different if it is a current loop or volatage loop? Just that I had a problem need to solve it.

Cheer

Chaw CS

 

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

20mA current loops haven't been used since teletypes and dumb terminals were state of the art. 

 

The problem is sometime my device cannot receive the protocol.

What protocol?  RS-485 only specifies the signal levels and rates.  A network communications protocol is typically implemented on top of the RS-485 signalling.  ModBus is the only one I can remember, but there are many others.  What is the Master device the Xmega is trying to receive from?  What code are you using to interpret the protocol the Master is sending? 

 

EDIT:

It had a termination resistor at the end.

Does this mean you removed the termination resistor?  How many devices are on the RS-485 bus and how are they interconnected.  They should be configured in a multi-drop configuration where the two pairs connect from one device, then to the next, then to the next.  The two devices at either end of the cable should have termination resistors enabled.  Putting the Master at one end of the bus is considered a bad practice.  Ideally the Master is in the center of the bus.  If the devices are connected in a star configuration where the wires from all slaves come back to the Master and are interconnected there, you are going to have problems.  You have to follow RS-485 recommendations (or at least those of the manufacturer of the Master device) or you will have a difficult time getting it to work.

 

Greg Muth

Portland, OR, US

Xplained/Pro/Mini Boards mostly

 

Make Xmega Great Again!

 

Last Edited: Tue. Jun 2, 2015 - 01:32 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Greg,

I agree with you that the master at the end of the bus is bad, but I cannot install it in the central. Still need a termination resistor at the end of the bus.

There are 2 pairs of cable, Tx and Rx. It had a termination on each of the end. Tx only the last station of the bus. Rx only the master, that why the master had to be the end of bus.

I do encounter some design that had termination on both end of the bus, of 120ohm. This design I think the master can be in the central of bus.

 

As for the protocol, is our own. We dont follow any of the standards, but the baudrate is at 921600kHz, near to 1M

 

CS

Last Edited: Tue. Jun 2, 2015 - 02:52 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Regardless of where the master is, the both the Rx bus and TX bus should be terminated at both ends.  Your original post says " sometime my device cannot receive the protocol."  Does this mean that sometimes it can receive OK?  If that is the case, properly terminating both ends of both busses might help.

Greg Muth

Portland, OR, US

Xplained/Pro/Mini Boards mostly

 

Make Xmega Great Again!

 

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

Thanks Greg,

 

Is this mean that you advice that both end of the Tx and Rx must be terminated? Will a 120 ohm do the tricks?

As for the protocol. Is that I can see that it do send out on the RS485 lines but just that the devices do not received it.

 

I also suspect that the signal maybe to fast, so I lower the speed. Still the same things happen.

 

Regards

CS

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

The need for termination depends on distances, speed and rise times. If the signal looks good in all different talker situations, you don't need the termination. It is a good practice to use the termination, but that increases the current consumption.

 

Search for application notes describing different termination stragies and equations for maximum distances without termination.

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

So, the master is sending data and you can see this data with some piece of test equipment?  At the Xmega end the signal goes into a RS-485 receiver, and that output connects to Rx on one of the USARTs?  What do you see if you look at the Rx pin on the Xmega?  If the data is getting that far (without being corrupted), then the problem is with your code.  So, what do you see on the Xmega Rx pin?

 

Greg Muth

Portland, OR, US

Xplained/Pro/Mini Boards mostly

 

Make Xmega Great Again!

 

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

RS422 is just basically a better RS232.  It uses a twisted pair for sending and another twisted pair for receiving.  It is capable of much higher speeds and much longer distances than RS232.