Re: Conversion of RS232 serial data from Fire Alarm to MODBUS




"albertleng" <albertleng@xxxxxxxxx> wrote in message
news:1156298083.272190.107180@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I tried to simulate Master and Slave in my PC with ModScan and ModSlave
from win-tech. They worked well where Slave could response to the polls
by ModScan without any error.

Since my PC has no RS485 ports, i used a RS232 to RS485 converter but
this time, the Slave could receive the polls from the Master but the
Master kept showing "Invalid response from Slave" and "Message Time
Out". Fyi, i connected the A+ and B- to pin 2 and pin 3 respectively
and i twisted them to try also. Also, GND to GND also. But it still
didnt work.

OK.

Now you've stumbled into a whole new area of pain - the physical layer.

Are you using RS485 on 2 wires or 4 wires (forget the screen/drain for a
moment or two)?

A quick "popular serial comms physical layers" primer:

RS232 is voltage level signalling on 2 wires - transmit and receive. It has
poor noise immunity.

RS422 is differential voltage level signalling on 4 wires, often called A,
A', B, B'. Due to being differnetial on twisted pairs, even though its
typically only TTL levels, it is quite noise immune. It is point to point.
Depending on the manufacturer, you connect A to B and A' to B' and vice
versa.

RS485 is the same signaling levels as RS422, but with the ability to make
the receiver "back channel" to the master tri-state (high impeadance) so
that you can have a master and multiple slaves. In 4 wire the A and A' wires
are usually the channel out from the master to all of the slaves. B and B'
are often the returns from the slaves again wired in parralel.

In RS485 2 wire you devise a mechanism to change the direction of the line
drivers in each interface. One simple way is to use a handshake line from
the master (CTS usually) to tell the master computer line driver whether the
master computer is meant to be sending or receiving. The slaves listen all
of the time and control their line drivers so that they can make replies,
always assuming that the master will go silent after an interrogate long
enough for the required slave to reply.

Another approach is if there is data at the "master" converter (the start
bit of a framed character for instance), to force the line driver into
transmit. A number of timeouts after the stop bit, you can flip the line
driver and listen for replies. Now you see where the 3.5 character "silent"
periods are included in the MODBUS spec - a "smart" RS485 driver uses the
silent periods to determin if it is a talker or a listener in 2 wire RS485.

You need a 3rd (or 5th) wire not only for screening but as a drain. The
drivers and receivers might be capacitively coupled, but if you transmitted
a long series of 1s or 0s then you would move the reference around unless
there is a drain path for the receivers.

Checklist for your situation:

* Look at the documentation for both converters (you do have 2 converters
don't you?!)
* There will often be a diagram showing typical connections.
* It is usually easiest to loop out all of the handshake lines on the PC so
that you don't have to worry about hardware handshakes at the PC end. Link
RTS to CTS and Link DCD to DSR to DTR at each end. Make up a cross over test
lead (if you haven't already) with just GND<->GND and TX<->RX and RX<->TX,
handshakes looped out. Make sure that both test PCs are on the same
electrical supplies so that their grounds are something like the same
potential otherwise you get a surprise when you connect up this non-isolated
cable.
* Now connect in the converter pair:
* If the converters are from different manufacturers (or even different
models from the same manufacturer) you might need to experiment with which
RS485 wires do what - often labelled differently like A, A', B, B' or RX+,
Rx-, Tx+, Tx- or some other code invented by the manufacturer - especially
if you run 4 wire. I often resort to trial and error and then re-label
throughout UP+, UP-, DOWN+, DOWN- where DOWN goes from master to slaves and
UP goes from slaves to master. Technicians much prefer this nomenclature.
* If your converters support 4 wire, try this first - that way you don't
have to worry about handshaking or timing to get the line drivers to flip
* Your converters might need switches or jumpers changing to select RS485 2
wire, CTS or auto driver control. If your RS232 leads from PC to converter
don't use CTS then you will need auto.

You will find a combination that works eventually. NOW DOCUMENT IT!

If in doubt, refer to Horowitz and Hill "The Art of Electronics", roughly
page 700 or so onwards which explains quite clearly and succinctly the whole
field of RS232, handshaking and RS485 and gives great practical advice. You
don't do electroics and computers unless you have a copy of the silver
"bible" on the shelf next to your desk!

Good Luck,

David.


.