Go Down

Topic: 232 ?? (Read 2950 times) previous topic - next topic


Feb 17, 2009, 01:42 am Last Edit: Feb 17, 2009, 01:42 am by Anthony.Selby Reason: 1
I want to connect multiple 232 devices to the arduino, hopefully to the digital ports ?

Is there any way to do that ?

The end goal is to connect 3 rs-232 devices to the arduino, then use the ethernet shield to let me send and receive short simple string

 send ...     "MOVE_LEFT_1"
 receive     "MOVED"
 send ...     "(1)MOVE_LEFT_1"
 receive     "(1)MOVED"


What you wish to do is certainly possible with a few details to over come. First any RS-232 device is using voltage levels incompatible with an Arduino digital I/O pin without using some kind of voltage level converter. Here is an example of a simple RS-232 to TTL converter, and of course you would need one for each RS-232 channel you want to communicate with.


The second factor is the software side. There is 'softserial' library (several versions these days) that will allow any Arduino digital pins to process serial data communications. However I don't think they can handle having data coming from multiple channels at the same time, so you may have to utilize in your main programming a 'protocol' such that only one channel at a time can be sending at any given time. That's not too hard to accomplish but you do have to deal with the possibility that a remote channel does not respond at all for some reason and have your program hang waiting for a message that will never arrive. A time out function is useful for that possibility.



Thanks for the quick answer ...

do you think I need to worry about two devices talking at the exact same moment ?

but there isn't away to "multi-thread" this is there ... even if I upgrade to the 328 there isn't enough room to write something like that is there ?


I'm sure there is a way to manage the traffic flow, but you need the more experainced software types to give you the right direction to go.



You may be able to talk to more than one device on the serial port if you use a multiplexer (like 74HC157) that selects one device at a time. Selection is, of course, done through software, using extra output pins of arduino.
But I don't think you will be able to handle "two devices talking at the exact same moment". (Can you connect simultaneously 2 devices on a COM port of a PC? And, assume that they are identical, how do you specify the destination device for any of your serial commands?)


I have some devices that I can connect multiples of to my computer (you have to ID them) but that's not really what I'm looking for ... The multiplexer doesn't seem like it would work ... what if I'm not on the device that's "talking" to me. I like the TTL idea but I don't really understand exactly how thats going to work, please correct me if I'm wrong, but that ttl converter allows me to set one pin as an output and flash (set high then low) that pin to create a 232 value ? ... and it does the same in reverse ? when a 232 value comes in it will set an input pin high and low ?

I'm starting to run in to a problem with my sketch sizes though ... if any of you have an idea on what I can do about that (beside make it smaller ... I've already started rewriting and cutting code) but I'm also using a ethernet sheild in this project so I don't have much room to play ... btw the way I've order a 328p hoping I can find it all in there.


The TTL converter only handles the electrical part of the interface, it makes sure that the voltage levels from your external devices are compatible with Arduinos voltagelevels.

It will not handle the serial communications as such.

You could do that with the soft serial library for Arduino. But you would still have to come up with a solution for handeling the concurrency - the devices that could talk at the same time.

If your devices allways only talk back afte some data has been send to them (call - response communication)  it should be possible without too much trouble. Something like send data to device 1 wait for answer, send data to device 2 wait for answer etc. etc.

If your external devices can send data at any time, not just after data has been sent to them, then it's a lot more complicated. You would need to handle a situation where device 1 can send data while you are dealing with incoming data from device 2. This is not easy.


You could put some sort of buffer between the Arduino and each device.  Then the Arduino could retrieve data from the buffers at will and the devices could send data to their buffers at will.  As long as the buffers don't overflow, you should be good.  With that, you could then retrieve data from whichever buffer has a complete data set in it.  This would allow for devices that talk more than others to be served in a timely manner.

I have no idea how this would be implemented, however.  Sorry.
What about elevensies? Luncheon? Afternoon tea? Dinner? Supper?


That would be amazing ... if anyone has an idea on how to do that ... I would love to know


One way is to use an I2C UART :-

This would allow you to connect as many serial devices as you want.


So how would that work ... don't those connect i2c or GPIO devices to a 232 bus ?

How would you use one to connect multiple 232 devices and use it as a buffer storing information until the arduino asks for it ?


Here's another option:


I only glanced over the description, but it looks like it may do what you need for small commands/responses.
What about elevensies? Luncheon? Afternoon tea? Dinner? Supper?


Feb 18, 2009, 03:40 am Last Edit: Feb 18, 2009, 03:44 am by florinc Reason: 1
If I understand correctly, you want to connect 2 serial devices on the same Rx/Tx pair of terminals.
Your concern is about how you detect when one of the 2 devices want to talk to you unexpectedly.

Here is a bit of more elaboration, hardware and software, on the mux/demux idea I mentioned in the earlier post.
- use a 2:1 bus mux/demux, like FST3257 (fast, cheap, easy to find);
- connect the select to an arduino output (say pin 4);
- connect Tx0 and Tx1 to arduino pins 2 and 3 and define ISRs for each of them (attachInterrupt);
- select the device that triggered the interrupt (device that "wants to talk to you") by setting arduino pin 4 accordingly;
- read the input from the selected device;
- when you want to send to the one of the devices, select it with pin 4 as well.

The schematics would look something like this:
Code: [Select]

                   |               |
to Arduino Tx  1A --+               +------ 1B1  to Tx0; also to Arduino digital 2;
                   |               |                   Device 0
                   |               +------ 1B2  to Tx1; also to Arduino digital 3;
                   |    FST3257    |
                   |               |
                   |               |
to Arduino Rx  2A --+     (or       +------ 2B1  to Rx0
                   |  equivalent)  |                   Device 1
                   |               +------ 2B2  to Rx1
                   |               |
                        S (select) to Arduino digital output pin 4

(RS232 signals must be converted to TTL, obviously).


How would you use one to connect multiple 232 devices and use it as a buffer storing information until the arduino asks for it

You have one of these per RS232 input. Each RS232 input is proceeded by an RS235 to TTL voltage converter. The buffering is inside the device (if you read the data sheet), it is limited in size, as is all buffering.

All devices are connected to the same two I2C lines on the Arduino (that's analogue pin 4 & 5)

a 232 bus

RS232 is not a bus.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131