Pages: [1]   Go Down
Author Topic: 232 ??  (Read 2163 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 28
I need more space !!! Everyone is closing in on me
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

example
 (232)
  send ...     "MOVE_LEFT_1"
  receive     "MOVED"
 (Ethernet)
  send ...     "(1)MOVE_LEFT_1"
  receive     "(1)MOVED"
 
« Last Edit: February 16, 2009, 07:42:52 pm by Anthony.Selby » Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17301
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

http://www.sparkfun.com/commerce/product_info.php?products_id=8780

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.

Lefty
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 28
I need more space !!! Everyone is closing in on me
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 ?

Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17301
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Lefty

Logged

0
Offline Offline
Edison Member
*
Karma: 8
Posts: 1411
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
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?)

Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 28
I need more space !!! Everyone is closing in on me
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Copenhagen / Denmark
Offline Offline
Edison Member
*
Karma: 6
Posts: 2360
Do it !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Atascadero, CA
Offline Offline
Sr. Member
****
Karma: 2
Posts: 468
Arduino addict
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

What about elevensies? Luncheon? Afternoon tea? Dinner? Supper?

0
Offline Offline
Newbie
*
Karma: 0
Posts: 28
I need more space !!! Everyone is closing in on me
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 632
Posts: 34510
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

One way is to use an I2C UART :-
http://www.standardics.nxp.com/products/bridges/uart.i2c.master.gpio/

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

0
Offline Offline
Newbie
*
Karma: 0
Posts: 28
I need more space !!! Everyone is closing in on me
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 ?
Logged

Atascadero, CA
Offline Offline
Sr. Member
****
Karma: 2
Posts: 468
Arduino addict
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Here's another option:

http://www.proteanlogic.com/product_periph_rs232.shtml

I only glanced over the description, but it looks like it may do what you need for small commands/responses.
Logged

What about elevensies? Luncheon? Afternoon tea? Dinner? Supper?

0
Offline Offline
Edison Member
*
Karma: 8
Posts: 1411
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
                   +---------------+
                    |               |
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).


« Last Edit: February 17, 2009, 09:44:39 pm by florinc » Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 632
Posts: 34510
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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)

Quote
a 232 bus
RS232 is not a bus.
Logged

Pages: [1]   Go Up
Jump to: