I have a project that uses a Mega as the primary board and a Nano as a secondary board. They communicate with each other through the serial lines and I somehow fried the Serial 2 line on the Mega. I'm not 100% sure how it happened, but I think the Nano lost its power supply (ground, power, both, I'm not certain) and caused a short on the serial line. The Nano came out fine, but the Serial 2 line on the Mega does not work, it pulls about 200mA constantly, and gets very hot. It has since been replaced. I would like to add some sort of protection to the serial line to keep this from happening again.
The two devices communicate at 9600 baud over a shielded cable and may end up being as much as 15ft (4.5m) apart. Should I just add some series resistors to limit the current in the event of a short-circuit? I don't have a clue where to start when it comes to using an opto-isolator/coupler, but many I have seen require power and ground on both sides of the circuit which I don't want to deal with (the fewer cables between the two MCUs, the better). I know there are 4 pin options, but I don't know what to look for.
I have seen mentions of using a buffer chip, but that was with multiple devices trying to communicate simultaneously.
What should I do? Series resistors? Opto-isolators? Buffers? Something else? Any guidance is greatly appreciated! Thanks!
I threw some 390Ω resistors in series with the TX and RX lines on the Mega side of things. In my initial testing, I had no issues with communications through the existing 15ft (4.5m) of shielded 22ga wire I have been using for testing. I'll report back if I run into any issues with it!
This will work fine if the environment is clean minimal electrical noise and reliability is not a problem. The processors were not designed to drive cable, yea it might work but for how long? They are also prone to external faults as you have learned. There are many different protocols and drivers you can use, check a few of them out. This will be much better then a guess. To keep your cables a minimum use CAN, it is a multi master bus that is fault tolerant. The same two wires go to all modules and each can send or receive at will. They have a limited length maybe in the thousand foot range. Posting a schematic, not of your project will help all of us help you.
That will do it. You should never connect a powered device to an unpowered device, without some sort of protection. Power will flow from the output pin through the input protection diodes of the unpowered device, possibly destroying both.
An optocoupler is by far the safest and most common solution. A 10K series resistor is a poor man's substitute, but of course, the circuit won't work anyway, if the power is off somewhere.