I have an atmega389B talking to a SAMD21 chip over UART and am trying to monitor the data sent by the SAMD21 and 389B chip. The baud rate used to be 9600 8N1 and I was able to observe both the sent and received data between the two boards using an RS485 to USB sniffer with a 120 Ohm resistor between the RX and TX pins. The baud rate has since gone up to 38400 and Now I can only observe the data sent from one board or the other, not both, which I need to do. I can switch the TX and RX pins and get one set of commands or the other but I cannot receive both. The data is flowing between two RS232 chips and for some reason I was still able to reliably get TX and RX data with an RS485 sniffer. Now with a higher speed I cannot. Does anyone know what might be causing this and a solution to this problem? I tried a UART to usb sniffer but got gibberish and I have tried Teraterm and another cheap RS485 terminal program. I've tested the cables as well and they are working. I'm quite confused and could use some help. Here is a drawing of the setup
2 Answers
The setup you've shown won't work. UART and RS-485 are very different electrically.
UART uses two unidirectional pins (RX and TX). RS-485 uses a single differential pair (commonly called wires A & B) for bidirectional communication.
To make it work you would need to add RS-485 transceivers next to the ATmega and SAM, only then the 3 devices could share a single bus.
Alternatively you could use two USB to UART converters, hook up their RX lines (one to the TX of ATmega, the other's RX to the TX of the SAM).
-
\$\begingroup\$ Or use a single UART adapter, and put a SP2T switch on its receive line. Connect the NO terminal of the switch to the RX wire of your system to monitor, and connect the other (NC terminal of the switch) to the TX wire. You can now monitor either the Rx or the TX line just by switching the position of the switch. Works like a charm. \$\endgroup\$ Commented Apr 23, 2018 at 21:04
RS485 is a different thing, where two directions share the same pair of wires. There is only one active at once, so you can monitor with ONE port.
The RS485 pair is differential, so one of your signals is being inverted., in the best case.
See Create a Communication Sniffer
You need TWO serial-usb modules, one for each wire. Realterm allows you to open TWO ports, and see them on screen in Monitor mode.
If you can guarantee that only one transmits at a time, you can OR them with diodes to a single port - but you won't know which char came from which wire.
simulate this circuit – Schematic created using CircuitLab