Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

adressing multiple devices with rs232

Status
Not open for further replies.

Gaston

Member
can you address multiple devices with rs232? for instance have three pics each with a unique address all on the same serial bus? would you have to write a routine in the program to only use the data after a certain sequence of bits are seen? or is there an ic made for this that only passes the data after it is addressed?
 
Sort of. RS-485 uses differential lines that often make use of the normal 2 signal wires in UART. THat means you have usually have half-duplex. The half-duplex nature where only one device can send a message on the bus at a time makes it easier to wire networks. You just run the same wire bus to all devices, and TX and RX both use the same set of wires. Just like I2C which is addressed and half-duplex.

Think about it...for RS-232 each device as a TX and RX line right? ANd each device can use both at the same time. You are going to have to connect the TX pin on every device to the RX pin on every other device. THen repeat for all devices in the network. That's a spider web. You have a set of signal wires (which is really just a single TX-to-RX for RS232) for every device (or every TX pin) in the network. With RS-485 you just have one set of signal wires for all devices in the network (two wires for the balanced pair). I suppose you could merge RS-232 TX and RX to only use one wire (similar to RS-485) to reduce the wire count if you did not need the differential signaling of RS485.

If you had a single master, to avoid the spider web with full duplex protocals (like RS-232), you could do what SPI does. It connects the master TX to every slave RX, and every slave TX connects to the master RX. So all devices share the same wires...except then you need chip selects which needs more wires, but much simpler than a spider web. THis however, is not an addressed network.

------------
There is full duplex RS-485 and it uses two balanced pairs connecting TX to RX between the two devices so that you can transmit and receive at the same time, but it's point to point usually or else you run into the same spider web problem as RS-232. The reason you might not simply use RS-232 in this case is because RS-485 handles much longer distances. Full duplex RS-485 might be thought of as long distance RS-232.
 
Last edited:
Pics have the ability to auto detect an address.

From the 16f631 data sheet,
12.1.2.7 Address Detection
A special Address Detection mode is available for use
when multiple receivers share the same transmission
line, such as in RS-485 systems. Address detection is
enabled by setting the ADDEN bit of the RCSTA
register.
Address detection requires 9-bit character reception.
When address detection is enabled, only characters
with the ninth data bit set will be transferred to the
receive FIFO buffer, thereby setting the RCIF interrupt
bit. All other characters will be ignored.
Upon receiving an address character, user software
determines if the address matches its own. Upon
address match, user software must disable address
detection by clearing the ADDEN bit before the next
Stop bit occurs. When user software detects the end of
the message, determined by the message protocol
used, software places the receiver back into the
Address Detection mode by setting the ADDEN bit.

Mike.
 
There is full duplex RS-485 and it uses two balanced pairs connecting TX to RX between the two devices so that you can transmit and receive at the same time, but it's point to point usually or else you run into the same spider web problem as RS-232. The reason you might not simply use RS-232 in this case is because RS-485 handles much longer distances. Full duplex RS-485 might be thought of as long distance RS-232.

@dk: Not quite. I think you'll find RS422 is the protocol for point-to-point differential signaling. RS485 is for multidrop and may be half- (2wire) or full- (4 wire) duplex.

@gaston: There are some abominations of rs232 that allow multidrop; just google rs232 multidrop. Generally it involves an open collector transmit (or diodes), a master and 1 or more slaves. It's dirty. This product uses it: **broken link removed**

Or, as DK said, you can daisy chain your devices, which has it's downfalls - such as reliability (e.g. if a device locks up it can no longer repeat messages along the chain), transmission distance, et al. I wouldn't recommend the 'spider web' method mentioned. That's probably why rs485 was recommended.

The 9-bit addressing available on some devices may not be suitable for communication with a PC, I guess you could use the parity bit to signal an address... but then you have to carefully select addresses, or constantly change the parity config of the PC com port. It's easier just to use a structured message format containing the address.
 
It should also be added you will need a USB-RS485 (virtual UART) adapter or RS-232-RS485 adapter to use RS-485 (it is a physically different protocal)

RS422 is for multi-drop and RS-485 is for mult-point. I understand what multi-drop is (one-way communication between one TX and multiple RX, right?) I always thought of RS-485 as multi-master capable, but perhaps it just means data can flow both ways.

I have another alternative too:

You said you wanted to use an RS-232 network right? You obviously aren't too concerned about distance or you'd be looking another another method. But you also want addressing. Have you considered just using I2C? Just use one of these for the USB-I2C adapter:
**broken link removed**
It is about 5x cheaper than a USB-RS485 adapter.
 
Last edited:
RS422 is for multi-drop and RS-485 is for mult-point. I understand what multi-drop is (one-way communication between one TX and multiple RX, right?) I always thought of RS-485 as multi-master capable, but perhaps it just means data can flow both ways.
That sounds right. RS-485 can be multi-master, and data can also flow in both directions. RS-485 may use 2- or 4-wires to implement half- or full-duplex, respectively.

You said you wanted to use an RS-232 network right? You obviously aren't too concerned about distance or you'd be looking another another method. But you also want addressing. Have you considered just using I2C?
You can extend I2C up to 50m using simple 8-pin extender chips.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top