Understanding RS232

Hi,

Can someone please shed some light on how I can determine if two devices can talk to each other?

I've got a arduino mega which can 'talk' rs232 on any of it's serial ports, and I've got an old yachting GPS which also claims to have a rs232 port. The arduino mega operates from 5 to 12 volts, and the GPS operates at 24v DC.

In my naivety, I had assumed that if two devices both talk RS232, then I could just wire one directly to the other.However, my research on RS232 suggests that sometimes two devices can be connected directly together, and sometimes a level shifter is required. My question is, how do I actually know (as opposed to just guessing)? Is there a specific phrase or value I should be checking for on each devices datasheet? Do I just need to check the power supply voltage? If both devices operate at the some voltage level, is it safe to directly connect them?

My guess is that connecting a 24 volt GPS to a 12 volt arduino is going to end in tears. Is there anyway of checking before the sparks fly?

RS232 "standard" is an oft abused standard. The actual standard calls for positive and negative pulses of 15v (I think).

Many devices use 0v and 5v.

You will need to know what each device requires and adjust as needed.

Weedpharma

The standard can include voltage swings up to +/- 25V, though much lower voltages are common these days.

Using buffers like the Maxim MAX232 (etc) devices helps prevent the presence of sparks.

You can always check with an oscilloscope.

You will need to know what each device requires and adjust as needed.

Yes, but how do I know what each device requires? is there a specific phrase and/or parameter I should be checking on the datasheet?

I note that the spec for the mega includes the phrase

hardware UARTs for TTL (5V) serial communication

Is this significant? do I need to look for a similar phrase in the spec of the device I'm communicating with?

You can always check with an oscilloscope.

Unfortunately I don't have one of these anymore.

Concentrate on the GPS. Besides the RS-232 port, you need to know what communications protocol it uses. Many devices with an RS-232 port need to be told what to send and when to send it by messages from the the other device, in this case your Arduino.

Paul

The arduino uses 0v and 5v (TTL serial).

You will have to consult the documentation for the GPS, or determine it's voltages levels experimentally.

DrAzzy:
The arduino uses 0v and 5v (TTL serial).

You will have to consult the documentation for the GPS, or determine it's voltages levels experimentally.

Beat me to the TTL point but makes me think of an interesting test. If you connect an arduino TTL level output via a MAX232 to another arduino (on the TTL side of the MAX232) will it work or not?
Obviously trying with input pin on non TTL side will probably blow the port but can the MAX232 convert TTL input to TTL?

Basically the Arduino does not use RS232 at all. It uses TTL aysynchronous seriall communication.
If both devices use RS232 they can be connected together. Either RX to TX on each device or RX to RX and TX to TX depending on the class of the RS232 devices. There are two classes an RS232 device can be wired as. CTE, computer terminal equipment or DTE, data terminal equipment.

Ok, so here's my understanding so far......

If two devices both say "TTL voltage levels" then it's safe to physically wire them together?

But if both devices just say "RS232", then that's not enough, and I need to find out what voltage they work at (or more accurately, what voltage their communications ports works at). Is this correct?

Is it safe to assume anything from the power supply voltage of each device? If I have two 12 volt DC devices, can I assume they both use the same voltage levels on their com ports? is that likely to be a mistake?

What RS-232 assures you of is the voltage is bi-polar and can be from -25 volts to +25 volts with the region of -3 volts to +3 volts being an undefined region and should not be relied on. Generally, the voltage is somewhere between -12 and +12 volts. It also assures you that any pin may be shorted to ground for an indefinite time without harming the electronics, and it assures you that +_25 volts may be applied to any pin without harming the device.

Rs-232 also defines the limit to the speed which the signal may change from + to -. This specification is why the RS-232 limits the distance between devices.

These are the reasons why RS-232 connected to TTL devices will kill those devices.

RS-232 devices that have 6 volt power may be connected to RS-232 devices with 20 volt power without a problem because the RS-232 standard ensures there will not be a problem.

Paul

Fulliautomatix:
Ok, so here's my understanding so far......

If two devices both say "TTL voltage levels" then it's safe to physically wire them together?

But if both devices just say "RS232", then that's not enough, and I need to find out what voltage they work at (or more accurately, what voltage their communications ports works at). Is this correct?

No.

You can always wire up RS232 devices together even though the voltages are different because those interfaces are designed to allow all the variations that can occur.

Im not sure but I think you think that feeding Arduino mega with 12 volts turns it on a 12 v device, thats wrong. Arduino megas logics will be 5v wether you feed it with 5V or 12 V.

I think it is safe to connect the Rs232 port of the Gps to a Max232, and connecting max232 to the mega.

Ive done this with a pc rs232 port and had no issue.

No one ever suggested connecting a 12V signal to a Mega. To connect an RS232 system to a Mega or any other Arduino you need a level and logic converter.

RS232 is à mixed norm : data protocol and electrical level.

With microcontroler we use UART norm (RS232 protocol only)
UART does not specify voltage which can be 5V, 3.3 V, 2.5V, and so on.
It is your responsability to control if both devices are level compatible.

If not, you have to use a level converter like Grumpy says.

Grumpy_Mike:
No one ever suggested connecting a 12V signal to a Mega. To connect an RS232 system to a Mega or any other Arduino you need a level and logic converter.

I know, i was refering to op but I didnt state it. Op says mega works from 5v to 12v and gps with 24v, thats why I said that.

I believe RS-232 spec talks about minimum of +-12 volts signals... But as others have pointed out, its often abused by manufacturers... Cant remember of the bat what was the idle state.

Basically it goes like this, if you need to go from TTL to RS-232 or RS-232 to TTL, you need level translator. Maxim and few others makes tons of those. So plenty of selection available.

If for example you have two Mega's both talking in TTL level, then its safe to connect them directly if distance is short...

I have personally used MAX232 to do my level conversions without problems when needed to interface with RS-232 bus. Depending how many signals you need to convert you may need different level translator chip...

Yes, but how do I know what each device requires? is there a specific phrase and/or parameter I should be checking on the datasheet?

My understanding of the rs232/TTL operations is that at resting state the tx and rx pins of an rs232 device will be 0v or less. The resting state of TTL tx and rx pins will be ~5v. This is why the signals need to be inverted when rs232 and TTL ports are to communicate together. You might check the resting state voltage on the tx/rx pins of the devices with a multimeter to determine the type of protocol is being used by that device.