RS232 advice

moxhamj

New Member
I’m designing an RS232 router and I’d appreciate some advice from people who have used RS232 devices such as GPS loggers etc. I have a PC controlling all sorts of things around the house and as the number of devices grows I have an increasing need for some sort of standardised communication system. A common Wire-OR bus has served very well up to about 15 devices but data clashes are now getting more common and sometimes I arrive home at night and the lights don’t come on!

I had an idea about routing little RS232 packets via picaxes but the problem with this approach is that the number of data bytes in a packet is limited to the 14 registers (b0 to b13). So this is great for a propriatory system but isn’t so useful for a system where unknown future devices might be added. It is quite possible that one day I might want to add on a device that uses standard RS232 and produces a whole stream of data that is much longer than 14 bytes.

So that limits the design to a router that is simply a multiplexer for the single RS232 connection on the PC. Asynchronous comms using just Tx and Rx and ground will work, but I’m thinking it may be better to at least use the Request to Send line as well which is an output from the PC to a device. The PC can control a picaxe which controls a multiplexer. Say there were 8 RS232 lines – the PC could poll each one sending out a RTS in turn to each and then a burst of Tx data and the device would respond with a packet. Devices that need to alert the PC to a data change can simply hold their data until they are polled and if the polling happens many times a second then the data will go through fast enough. The serin hang is not an issue as the RS232 lines simply go through to the PC and the PC RS232 input buffer can handle a hang.

I think this can be done with 4 wires – Gnd, Tx, Rx and RTS.

The question I would appreciate an answer to is whether there is a need to also multiplex CTS which is the signal from the device to the PC saying it is clear to send. And also whether DTR is needed? Are there common RS232 devices where these lines are essential?
 

papaof2

Senior Member
The only thing consistent about rs232 devices is their inconsistency ;-)

Some things are OK with TD, RD, and GND (Casio pocket organizer). Others require a full set of control leads (most modems, my HP 7475A serial plotter).

If I were designing a serial "router", I think having all the control leads *available* would be a good choice - but with an option to only provide the needed control leads to each port (either pass-through or pre-set active/inactive).

A really fancy router would talk to the PC at 115KB and to each connected device at its preferred speed (this is way beyond current PICAXE designs).

An alternative to the router would be a multi-port serial card (8, 16, etc) such as the ones used on the old dialup BBS systems. An 8 port card with 8 devices on each port would provide for 64 devices with the current pass-along bus design. Since some of the old BBS systems ran on very limited hardware (by current standards), there should be no problem running a couple of multi-port cards on newer hardware. One card could handle the PICAXE network(s) and another card could handle individual devices needing higher speeds or more data throughput.

John
 

hippy

Ex-Staff (retired)
I wrote a whole page which I've deleted - The bottom line IMO is that a PICAXE isn't suitable for such a generic network.

The best option is a multi-port serial hub with RTS and CTS for each device. That could be implemented with a multi-port serial card as suggested by papaof2, a whole load of USB to serial adapters, a LAN-based Terminal Server or a micro or micros with UART(s), alternatively Telnet modules for each node and put them on a LAN.

A PICAXE-only network is fine when nodes are receive from PC only ( act on received data, report back 'done it' ), or when they get data when commanded ( get the data, report it back ) and where what they are doing can be interrupted by the PC when it needs to send or ask for data (X1's), but the blocking nature of the PICAXE and lack of multi-tasking makes it hard to implement a generic network which in anyway matches the ideal it should be.

For the case you have, where it's contention and collsion causing a problem, it may be best to make each node demand driven, so nodes only put data on the multi-drop when told they can.

I'd put that and any other serial control on separate networks. Trying to meger the two just gets incredibly complex.
 

gbrusseau

Senior Member
With 15 devices on the buss, you are probably just exceeding the fan-out limits of the buss drivers. You may be able to just increase the fan-out limit on the buss by getting more powerful buss drivers to replace the ones you have that will handle more devices on the buss.

Without a schematic or buss driver chip part number, I am just speculating at this point.
 

MPep

Senior Member
Just adding my 2 cents worth, but what is wrong with using Jurjen Kranenborg's network? It appears that he has it sorted out.

Also, instead of RS232, try using RS422 (4 wire), or perhaps RS485 (2 wire). JK's network runs along the lines of RS485 from what I can tell. As well as supplying power to external nodes.
 

andrewpro

New Member
Also, instead of RS232, try using RS422 (4 wire), or perhaps RS485 (2 wire). JK's network runs along the lines of RS485 from what I can tell. As well as supplying power to external nodes.
RS485 is a 4 wire network. 422 differs from 232 in that it's differential. That's really about it. With 485 you get the differential of 422, but add in multidrop and addressing along with it.

--Andy P
 

MPep

Senior Member
RS485 is a 4 wire network. 422 differs from 232 in that it's differential. That's really about it. With 485 you get the differential of 422, but add in multidrop and addressing along with it.

--Andy P
My understanding is that RS485 is multi-drop bi-directional, where-as RS422 has 2 pairs, one for Rx, and one for Tx. most literature I have seen indicates this.

www.advantech.com/products/Isolated-S-232-to-S-422-485-Converter/mod_1-23HZ1P.aspx

Download the manual, in which it states the above.
I use these for work. Excellent for the job they do.

Mark.
 

moxhamj

New Member
Many thanks for all the help and suggestions. I think I may go for connecting as many lines as possible - I'll also post a schematic etc once I have a prototype working. RS485 and 422 look interesting - I'll research these further.
 
Top