1
\$\begingroup\$

I'm trying to connect two devices which in both of them use pic micro. I am curious to select best connection solution. I can use uart for connection between them and also with helping of MAX232 rs232 connection could be used. Anyone with experience have recommendations about it? Which is better and what are their advantages and disadvantages?

\$\endgroup\$
  • \$\begingroup\$ How far are the devices apart, and how are they connected (PCB traces, wires)? \$\endgroup\$ – stevenvh Sep 30 '12 at 9:52
  • \$\begingroup\$ Tow devices separated of two meters and for connection wires will be used. \$\endgroup\$ – mehdi Sep 30 '12 at 10:01
  • 3
    \$\begingroup\$ UART is a functional block for implementing serial communications, not really a protocol or signal voltage specification. It would be much better to say "logic level" vs. "RS232 level" Either way a UART (or whatever your vendor calls it - USART, UCI, etc) will likely be involved, the question is if you will also use external line transceivers. \$\endgroup\$ – Chris Stratton Sep 30 '12 at 15:22
6
\$\begingroup\$

UART
Cheaper, since you don't need any extra hardware.

EIA-232
(the name RS-232 is obsolete.) Will give you better noise-immunity, because it uses higher voltages and has lower impedance.

EIA-422
has an even better noise-immunity, thanks to the balanced signal, but unless your environment is extremely noisy (think high power electric machines, like several kW) you probably won't need it. You would need differential transceivers, and twisted wire cable.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Though maybe not applicable here, isn't RS-422 also better suited for long distances? \$\endgroup\$ – Federico Russo Aug 12 '13 at 8:44
2
\$\begingroup\$

The comment from @chris-stratton is correct and an important point. If you are talking about using EIA-232 or EIA-422 you are almost certainly talking about using a UART as the functional block that performs serial communication. And as @stevenvh said, EIA-232 is not a good choice for a new design. So, do you need to add an EIA-422 transmitter/receiver to each microcontroller? There are several things to consider.

One of them is speed (bits per second). At high speeds the UART output pins from your microcontrollers may have trouble driving the capacitance of two meters of cable. The microcontroller is capable of driving a few cm of wire to a 422 transmitter at high speeds, so if you need high baud rates you might want to use 422 just for that reason.

Another consideration is common-mode voltages. If you use the raw UART pins to connect the microcontrollers then you must also connect the grounds of the two microcontrollers. Depending upon the physical situation and how the boards are powered, the ground levels of the two boards might be different. There might be other good reasons for not connecting their grounds together, and if that's the case then using a differential signalling scheme, like 422, will allow the microcontrollers to talk to each other even if there are several volts difference between their ground levels.

You can get 422 receivers and transmitters in fairly small packages at low cost, but there are disadvantages to using 422 instead of directly connecting the UARTs. Since 422 is differential instead of single-ended you need two wires each for the two directions of information flow and a termination resistor at the receiving end, where a direct connection would require three wires (signals in both directions plus ground) and no termination resistors. The dc current consumed by a 422 connection is several milliamps so the increased power consumption (on the order of 100mW per transmitter) might also be an issue for you.

You should also consider LVDS (low-voltage differential signalling, EIA-644) which works at lower voltages and consumes much less power. The disadvantage is that the common-mode range is reduced, but over 2 meters that might not be a problem for you.

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

For 2 meters you might or you might not need MAX232 to convert levels. It depends on the bitrate. I think that for 2 meters it's safe to use 0-5V level for up to 9600 bits/s. For higher rates you should use MAX232. Note than MAX232 will increase the voltage difference between 0 and 1 from 5 V to about 18-20V (from -10 to +10V).

But if you use shielded cable you can safely use TTL levels for a bit higher bit rate if you shielded cable. The only problem would be cable capacitance. If you don't have oscilloscope to measure rise time go with MAX232 to be 100% sure. It'll also allow you to extend the cable for up to 15m later.

Alternatively (because max232 requires a lot of components) if power consumption is not that big problem (if not battery powered) you can from 470ohm to 2k resistors on RX pins of MCU. This will increase the current on the wires and reduce the chance noise to interfere.The cable capacitance will still be an issue, so be careful with higher speeds

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.