2 wire rs485

Started by Vasilis February 10, 2009
Hello list,

I'm having problems talking to a 2 wire rs485 device.
This is my following configuration:

- embedded pc104 board AAEON PFM-530I
- programmable electricity meter with rs485 interface for
communication.

Now, setting a few jumpers on the board toggles an rs485 port on
ttyS1.
My specific problem is this: i don't seem to connect the board and the
meter correctly. This is what i did:

1. found out which pins on the db9 connector attached on port ttyS1
are rs485 data+ and data-.
2. connected data+ to a hole on the meter labeld A, and data- on an
other one, labeled B. (i tried the opposite too, data+ to B, data- to
A)
3. tried to communicate with the meter

what happens is that i receive garbage bytes, and not the response i
expect.
i'm aware(sort of) that i have to do something with the ground wire on
the
db9 connector, do not know exactly what though. My meter has only two
inputs, labeled A and B.

Furthermore, If i use an rs232-rs485 converter, and switch back the
jumpers
to the rs232 configuration for ttyS1, everything works great.

I do not want to use a converter.

I also read a lot about a 100ohm resistor between the wires connected
to the slave devices. Could this be the solution?

Thanks everyone,
Vasilis.
On 10 Feb, 18:15, Vasilis <VASILI3...@HOTMAIL.COM> wrote:
> Hello list, > > I'm having problems talking to a 2 wire rs485 device. > This is my following configuration: > > - embedded pc104 board AAEON PFM-530I > - programmable electricity meter with rs485 interface for > communication. > > Now, setting a few jumpers on the board toggles an rs485 port on > ttyS1. > My specific problem is this: i don't seem to connect the board and the > meter correctly. This is what i did: > > 1. found out which pins on the db9 connector attached on port ttyS1 > are rs485 data+ and data-. > 2. connected data+ to a hole on the meter labeld A, and data- on an > other one, labeled B. (i tried the opposite too, data+ to B, data- to > A) > 3. tried to communicate with the meter > > what happens is that i receive garbage bytes, and not the response i > expect. > i'm aware(sort of) that i have to do something with the ground wire on > the > db9 connector, do not know exactly what though. My meter has only two > inputs, labeled A and B. > > Furthermore, If i use an rs232-rs485 converter, and switch back the > jumpers > to the rs232 configuration for ttyS1, everything works great.
Hi, this means that the problem could be related to the RS485 direction (TX/RX) control which can lead to bus conflicts; I have experienced similar problem with built-in RS485 ports. What is probably happening is that the slave starts responding before the master has released the bus
>
> I also read a lot about a 100ohm resistor between the wires connected > to the slave devices. Could this be the solution?
If your network is composed by just 2 nodes and the cable is short, then termination is not necessary
On Tue, 10 Feb 2009 11:31:29 -0800 (PST), Capoccetta
<er_capoccetta@tiscali.it> wrote:

> >> I also read a lot about a 100ohm resistor between the wires connected >> to the slave devices. Could this be the solution? > >If your network is composed by just 2 nodes and the cable is short, >then termination is not necessary
If you do not have a signal ground connection, you _must_ use the termination resistor to supply the bias current for the receiver transistors, regardless of the number of nodes or cable length. Paul
Vasilis wrote:

> Hello list, > > I'm having problems talking to a 2 wire rs485 device. > This is my following configuration: > > - embedded pc104 board AAEON PFM-530I > - programmable electricity meter with rs485 interface for > communication. > > Now, setting a few jumpers on the board toggles an rs485 port on > ttyS1. > My specific problem is this: i don't seem to connect the board and the > meter correctly. This is what i did: > > 1. found out which pins on the db9 connector attached on port ttyS1 > are rs485 data+ and data-. > 2. connected data+ to a hole on the meter labeld A, and data- on an > other one, labeled B. (i tried the opposite too, data+ to B, data- to > A)
So you have JP1 links set as:- 2 to 3, 5 to 6, 8 to 9 and 11 to 12. ...and JP2 pins 5 to 6 connected. ...and JP3 pin 3 to 4 open ...and have connected CN9 pin 15 to Meter A ...and have connected CN9 pin 11 to Meter B (sorry if it states what you already have found out from the manual).
> 3. tried to communicate with the meter > > what happens is that i receive garbage bytes, and not the response i > expect. > i'm aware(sort of) that i have to do something with the ground wire on > the > db9 connector, do not know exactly what though. My meter has only two > inputs, labeled A and B.
Not necessary to do anything with the ground except to endure one end is connected to ground to provide shielding if the cable length is appreciable or data is fast and you have a noisy environment. On the bench in the lab with a short link you should be OK on unshielded twisted pair.
> Furthermore, If i use an rs232-rs485 converter, and switch back the > jumpers > to the rs232 configuration for ttyS1, everything works great.
Interesting that this works. I would check that the processor board is behaving as expected. Have you scoped across the pair and tried to manually decode the data stream? I am wondering if the TX/RX pairs on the processor board have been swapped in error. After you see what happens on the data pair look beyond the drivers on the board to see if the data polarities make sense (the sort of fault that can creep in if the layout guy got things swapped). -- ******************************************************************** Paul E. Bennett...............<email://Paul_E.Bennett@topmail.co.uk> Forth based HIDECS Consultancy Mob: +44 (0)7811-639972 Tel: +44 (0)1235-811095 Going Forth Safely ..... EBA. www.electric-boat-association.org.uk.. ********************************************************************
On Feb 10, 11:34=A0am, "Paul E. Bennett" <Paul_E.Benn...@topmail.co.uk>
wrote:
> So you have JP1 links set as:- > =A0 2 to 3, 5 to 6, 8 to 9 and 11 to 12. > > ...and JP2 pins 5 to 6 connected. > > ...and JP3 pin 3 to 4 open > > ...and have connected CN9 pin 15 to Meter A > ...and have connected CN9 pin 11 to Meter B
yes exactly.
> > 3. tried to communicate with the meter > > > what happens is that i receive garbage bytes, and not the response i > > expect. > > i'm aware(sort of) that i have to do something with the ground wire on > > the > > db9 connector, do not know exactly what though. My meter has only two > > inputs, labeled A and B. > > Not necessary to do anything with the ground except to endure one end is > connected to ground to provide shielding if the cable length is > appreciable or data is fast and you have a noisy environment. On the > bench in the lab with a short link you should be OK on unshielded > twisted pair. > > > Furthermore, If i use an rs232-rs485 converter, and switch back the > > jumpers > > to the rs232 configuration for ttyS1, everything works great. > > Interesting that this works. I would check that the processor board is > behaving as expected. Have you scoped across the pair and tried to > manually decode the data stream?
ok, i suppose you are talking about an oscilloscope. we don't have one, sorry.
> I am wondering if the TX/RX pairs on the processor board have been > swapped in error. After you see what happens on the data pair look > beyond the drivers on the board to see if the data polarities make sense > (the sort of fault that can creep in if the layout guy got things > swapped).
do you mean the pins 11 and 15 swapped? or that tx and rx are really another pair of pins? if you're talking about the first option, then i could just swap the A and B inputs, right? well, if i do swap them, then i do not get any response from the meter (which made me think about terminations and connection issues in the first place) well, thank you for your answer. vasilis.
On Feb 10, 11:34=A0am, "Paul E. Bennett" <Paul_E.Benn...@topmail.co.uk>
wrote:
> > I am wondering if the TX/RX pairs on the processor board have been > swapped in error. After you see what happens on the data pair look > beyond the drivers on the board to see if the data polarities make sense > (the sort of fault that can creep in if the layout guy got things > swapped).
oh and by the way, i know that rts/cts handshake must be performed manually. could you please tell me what actions must be performed? the only thing i do now is to raise the request to send signal, send data, then lower it and wait for response. thanks again, vasilis.
Vasilis wrote:

> On Feb 10, 11:34&#2013266080;am, "Paul E. Bennett" <Paul_E.Benn...@topmail.co.uk> > wrote: >> So you have JP1 links set as:- >> 2 to 3, 5 to 6, 8 to 9 and 11 to 12. >> >> ...and JP2 pins 5 to 6 connected. >> >> ...and JP3 pin 3 to 4 open >> >> ...and have connected CN9 pin 15 to Meter A >> ...and have connected CN9 pin 11 to Meter B > > yes exactly.
[%X]
>> Interesting that this works. I would check that the processor board is >> behaving as expected. Have you scoped across the pair and tried to >> manually decode the data stream? > > ok, i suppose you are talking about an oscilloscope. we don't have > one, sorry.
Yes, using an oscilloscope. It is a worthwhile piece of test equipment to have in your toolkit.
>> I am wondering if the TX/RX pairs on the processor board have been >> swapped in error. After you see what happens on the data pair look >> beyond the drivers on the board to see if the data polarities make >> sense (the sort of fault that can creep in if the layout guy got >> things swapped). > do you mean the pins 11 and 15 swapped? or that tx and rx are really > another pair of pins?
I saw a layout error of this type made in another system. The TX+ and RX- were joined together on the PCB track and consequently the TX- and RX+ were joined. This is a manufacturing error of course but they do happen. It required some track cutting and re-wiring to fix that one. The maker of the board had tested it with another board of the type and with the same fault. It just didn't work with any other system.
> vasilis.
-- ******************************************************************** Paul E. Bennett...............<email://Paul_E.Bennett@topmail.co.uk> Forth based HIDECS Consultancy Mob: +44 (0)7811-639972 Tel: +44 (0)1235-811095 Going Forth Safely ..... EBA. www.electric-boat-association.org.uk.. ********************************************************************
"Paul E. Bennett" <Paul_E.Bennett@topmail.co.uk> wrote in message 
news:6ve6ltFje4m0U1@mid.individual.net...
> Vasilis wrote: > >> i'm aware(sort of) that i have to do something with the ground wire on >> the >> db9 connector, do not know exactly what though. My meter has only two >> inputs, labeled A and B. > > Not necessary to do anything with the ground except to endure one end is > connected to ground to provide shielding if the cable length is > appreciable or data is fast and you have a noisy environment. On the > bench in the lab with a short link you should be OK on unshielded > twisted pair.
Careful. The ground connection *is* necessary (RS-485 does not have an infinite common-mode; in fact it's +/-7V on top of the 0-5V signal swing) - *but* it may be implicit. If both pieces of equipment are grounded to the same ground, it's implicit. If one is not connected to ground at all, it *may* work, or may not - the non-grounded end might happen to self-bias in the right range via receiver input current , but might not. This is probably what Paul Keinanen meant in his post:
>> If you do not have a signal ground connection, you _must_ use the
termination resistor to supply the bias current for the receiver transistors, regardless of the number of nodes or cable length. << If not, Paul, then I'm puzzled ;). To the OP: be distrustful of A/B marking, or indeed Rx/Tx+/- marking. RS-485 *is* defined in terms of A and B (and ground), but unfortunately all the major RS-485 transceivers have them reversed for bad historical reasons, and designers often don't spot this and mark incorrectly. (The Rx/Tx+/- system is unofficial and in any case subject to misinterpretation.) You say it works with an RS-232/RS-485 converter: are you controlling the driver with e.g. RTS? (Seems so from another post.) In principle, an external converter is no different from an internal transceiver, except that *some* external converters offer "auto-gating" - i.e. they figure it out for themselves (usually needing some help in the form of knowing the baud rate via e.g. some DIP switches). If it works with an external converter, I'd suggest this is A Clue. Tell us more about the converter and the cabling - and ideally also the grounding. Steve -- http://www.fivetrees.com
On Wed, 11 Feb 2009 22:21:54 -0000, "Steve at fivetrees"
<steve@NOSPAMTAfivetrees.com> wrote:

>"Paul E. Bennett" <Paul_E.Bennett@topmail.co.uk> wrote in message >news:6ve6ltFje4m0U1@mid.individual.net... >> Vasilis wrote: >> >>> i'm aware(sort of) that i have to do something with the ground wire on >>> the >>> db9 connector, do not know exactly what though. My meter has only two >>> inputs, labeled A and B. >> >> Not necessary to do anything with the ground except to endure one end is >> connected to ground to provide shielding if the cable length is >> appreciable or data is fast and you have a noisy environment. On the >> bench in the lab with a short link you should be OK on unshielded >> twisted pair. > >Careful. The ground connection *is* necessary (RS-485 does not have an >infinite common-mode; in fact it's +/-7V on top of the 0-5V signal swing) - >*but* it may be implicit. If both pieces of equipment are grounded to the >same ground, it's implicit. If one is not connected to ground at all, it >*may* work, or may not - the non-grounded end might happen to self-bias in >the right range via receiver input current , but might not. > >This is probably what Paul Keinanen meant in his post: > >>> If you do not have a signal ground connection, you _must_ use the >termination resistor to supply the bias current for the receiver >transistors, regardless of the number of nodes or cable length. << > >If not, Paul, then I'm puzzled ;).
It is self-biased by the input current. I have been using this both with CAN as well as RS-422/485. One RS-232/485 converter manufacturer even dropped the signal ground connector entirely from the floating RS-422/485 converter in a recent version http://www.westermo.com/dman/Document.phx/Manuals/RS-422+485+Converters+%26+Repeaters/MDW-45+manual+ENG?folderId=%2FManuals%2FRS-422+485+Converters+%26+Repeaters&cmd=download check block diagram on page 3 and connector list and connection diagrams on other pages. An older converter version http://www.westermo.com/dman/Document.phx/Manuals/RS-422+485+Converters+%26+Repeaters/MA-45_manual.pdf?folderId=%2FManuals%2FRS-422+485+Converters+%26+Repeaters&cmd=download in the diagram on the last page had a screw terminal labeled as "Shield", which was connected to the internal floating 0VB supply, The line connection diagram on page 13 suggest that the cable shield is connected only at one end to that "Shield" terminal to avoid ground loops. These converters have been used for years in various industrial installations all over the world. So the signal ground connection is not necessary nor desirable in systems with large ground potential differences.
> >To the OP: be distrustful of A/B marking, or indeed Rx/Tx+/- marking. RS-485 >*is* defined in terms of A and B (and ground), but unfortunately all the >major RS-485 transceivers have them reversed for bad historical reasons, and >designers often don't spot this and mark incorrectly. (The Rx/Tx+/- system >is unofficial and in any case subject to misinterpretation.)
This is really a mess (as the comment on page 12 of the latter link suggests), I have seen converters and RS-422/485 PCI cards with A/B defined in opposite ways and also various combinations of T+/T- both ways. As long as the devices have RxData LEDs, it is quite easy to detect, if the RS-422 is connected the wrong way. If the RxData LED is constantly lit when there is no traffic, just reverse the R+ and R- pin at the receiver end. On RS-485, use one end with active fail safe termination (typically the master) as a reference and check the RxData LED on all slaves when the bus is idle. If the RxData LED is constantly lit on a specific slave only, just reverse the D+ and D- connections on that slave. Paul
Paul Keinanen wrote:
> > One RS-232/485 converter manufacturer even dropped the signal ground > connector entirely from the floating RS-422/485 converter in a recent > version >
http://www.westermo.com/dman/Document.phx/Manuals/RS-422+485+Converters+%26+Repeaters/MDW-45+manual+ENG?folderId=%2FManuals%2FRS-422+485+Converters+%26+Repeaters&cmd=download
> check block diagram on page 3 and connector list and connection > diagrams on other pages. > > An older converter version >
http://www.westermo.com/dman/Document.phx/Manuals/RS-422+485+Converters+%26+Repeaters/MA-45_manual.pdf?folderId=%2FManuals%2FRS-422+485+Converters+%26+Repeaters&cmd=download
> in the diagram on the last page had a screw terminal labeled as > "Shield", which was connected to the internal floating 0VB supply, The > line connection diagram on page 13 suggest that the cable shield is > connected only at one end to that "Shield" terminal to avoid ground > loops. > > These converters have been used for years in various industrial > installations all over the world. > > So the signal ground connection is not necessary nor desirable in > systems with large ground potential differences.
It looks to me like both the converters you referenced are isolated converters, with no common ground between the power supply and RS-485. In that case, I can see that the RS-485 ground wire may be optional. -- newell N5TNL