-1
\$\begingroup\$

I have a system with two serial devices (Arduino uControllers) connected to a single FTDI (USB-to-Serial) chip through a silicon switch. Each devices works fine on its own.

I would like to be able to switch back and forth between the serial output of the two devices while they are both running. It works sometimes, but not reliably and it's more reliable at slower speeds (e.g., 9600). When it fails, I just get garbage after I switch between them. If I reset the device I'm listening to, I get good data.

How can I cleanly switch between the two ports cleanly?

Thanks.

\$\endgroup\$
  • 1
    \$\begingroup\$ Using a multidrop protocol, such as RS-485 is not an option? \$\endgroup\$ – Eugene Sh. Jun 18 '18 at 20:22
  • 2
    \$\begingroup\$ What is a "silicon switch"? How do you control the switch? \$\endgroup\$ – Elliot Alderson Jun 18 '18 at 20:22
  • 1
    \$\begingroup\$ Also sounds like your protocol is not very robust and does not have a missynchronization recovery mechanism \$\endgroup\$ – Eugene Sh. Jun 18 '18 at 20:23
  • 1
    \$\begingroup\$ If you "switching back and forth" randomly then what did you expect the result would be? And if you are not switching randomly then there should not be any problem. It's a simple synchronization task, as @EugeneSh. pointed out. \$\endgroup\$ – Maple Jun 18 '18 at 20:32
1
\$\begingroup\$

I assume the garbled data is due to switching between 'frames', i.e. you get half of the last byte and half of the next byte interpreted as one byte. When you switch you may even get bits from one device mixed with bits from the other device.

You either need:

  • a smarter multiplexer that can only switch between bytes, or 'frames' i.e. extra uC reading both and 'switching' them with software
  • or a data correction protocol; when you detect bad/garbled data ex. with a checksum, and have it restart/reset/realign whatever.

AFAIK serial ports aren't meant to be interfaced this way! One USART per each serial port.

Also n.b. RS-232 includes the line voltages, pin-outs, etc for the 9-pin and 25 pin connectors. The serial part is performed by the USART which never actually uses RS-232 in this case since you are using a USB TTL USART.

\$\endgroup\$
1
\$\begingroup\$

If you have any pauses, even fairly brief ones, in the output of the serial data that would give the receive time to re-establish synchronization, that it may not get if both devices are keeping their serial UARTs constantly busy stuffing words down the wire one after another with no gaps. Note that Arduino serial output is buffered, so typically a "noisy" program can "run ahead" generating data, but once the buffer is full the output calls will start blocking and the program will essentially run at the pace that keeps the serial output constantly busy.

Your multiplexor likely involves a fair amount of customization, which is yet another thing to spec / make, so there could be a lot of logic in giving each board its own unique channel.

  • You could just buy two inexpensive USB serial adapters. Distinguishing them by physical USB port is typically possible but can indeed be a bit painful. There are writeups around the web, perhaps some even here, and of course it depends on the host system.

  • If you get two different chipsets, it may be quite a bit easier to tell them apart. One modern CDC/ACM type Arduino and one legacy FTDI gets easier still, since on Linux or OSX these get device node names of quite different form.

  • You can also get a dual or quad channel converter, like the FTDI-2232 or FTDI-4232. These are typically more expensive than two single channel modules, but are handy gadgets in their own right (they also talk synchronous protocols like JTAG or presumably AVR ISP, alas, while possible trying to get one to be both a serial port and a JTAG adapter at the same time can put you back in the realm of driver battles - but I digress)

\$\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.