Test of USB to serial port adapters.

October 4th, 2013.

Introduction

Genuine RS-232 serial ports are scarcely found on newer computers. Unfortunately, some older devices only communicate through an RS-232 serial port. This is the case of SAN2PC, a device allowing to digitize the waveform from a spectrum analyzer. There are many adapters between the USB world and the RS-232 world. Unfortunately, according to feedback from users, and also based on our own experience, all these adapters do not work flawlessly.

This document focuses on tests conducted on various RS-232 to USB adapters, as found on the market. It should help anyone moving from RS-232 to USB (and spare them hours of frustration).

A brief summary follows:

"RS232" adapter at 115kb Linux 64 bits Windows XP Windows 8 64 bits
"Cheap blue cord" Does not work Does not work Does not work
PIC18F14K50 adapter Works Works Works
CH340 adapter Works Works Works
CP2102 adapter Works Works Works


Several of the adapters we refer to as "Cheap blue cords" do not work at 115200 bauds. These cords are recognized by the Linux host as PL2303. Our tests show that they do not comply with the electrical characteristics of the RS-232 standard. Prolific, the company that manufactures the PL2303 integrated circuit (IC), also warns its customers: there are cheap knock-offs of this very IC (counterfeit IC)!

A few adapters are sold as an interface between a serial bus with TTL levels and a USB port. We think these are the preferred low-cost solutions to move a RS-232 device to the USB world.
Last, some more expensive adapters are genuine RS-232 to USB converters and also work perfectly.

1. Methodology

A microcontroller-based development board is used as the RS-232 compliant device. More information about this board is found on the F2DC web site. It relies on a PIC18F2525. The RS-232 driver and receiver is based on a MAX232A or a ST232 IC. The baud rate is 115200 bauds with 8 bits of data, no parity and one stop bit.


Figure 1. PIC18F2525 board.

The device sends the same text-only data to the host. This text is made of integers ranging from 1 to 50,000, sent as text, one integer per line. Last, 50,000 pseudo random numbers are sent, 10 per line, preceded by the line number. This is the reference text used throughout the test, see figure 2.

Moreover, at startup, ten alphabet lines "ABCDEFGHIJKLMNOPQRSTUVWXYZ" are sent. These allow a quick visual checkup of the RS-232 transmit capability (if one character is missing, the pattern is broken, which is easy to spot).

49996
49997
49998
49999
50000

        0 22128 43832 21916 10958 5479 35507 17753 8876 37206 51371
        1 58453 29226 14613 7306 36421 18210 41873 53704 59620 29810
        2 47673 56604 28302 14151 7075 3537 34536 17268 8634 4317
        3 34926 50231 57883 28941 47238 56387 60961 30480 15240 40388
        4 52962 59249 29624 14812 7406 36471 51003 58269 61902 30951
        5 48243 24121 44828 22414 11207 5603 2801 1400 700 33118
        6 16559 8279 4139 34837 17418 41477 20738 10369 37952 18976
        7 42256 21128 43332 54434 59985 62760 31380 48458 56997 61266
        8 30633 48084 56810 28405 46970 23485 11742 5871 2935 34235
        9 49885 57710 61623 63579 31789 15894 40715 20357 10178 5089
       10 2544 34040 17020 41278 53407 59471 62503 64019 64777 32388
Figure 2. Example of numbers sent from the board.

Last, the board listens to the serial port and outputs a sentence with the decimal code of the received character. This allows us to test both transmit and receive lines of the RS-232 adapter, see figure 3. The code has been written in C.

ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
BAUDCON=72
         
PRESS A KEY OR ! FOR THE BIG TEST
YOU PRESSED Y VALUE=89 59H
PRESS A KEY OR ! FOR THE BIG TEST                                            
YOU PRESSED Y VALUE=89 59H                                                   
PRESS A KEY OR ! FOR THE BIG TEST
Figure 3. Example of communication between the PC RS-232 port and the microcontroller.

The voltages were measured on the MAX232 side while a genuine RS-232 adapter was used. The voltages of the transmit signals from both the PC and the PIC approximately swing from -10 V to 10 V. An example of the signal, captured with a digital storage oscilloscope, is shown on figure 4.


Figure 4. RS-232 voltages when using a genuine adapter.

The reference text, generated by the same C code on the microcontroller and on the PC, has been saved to a file on a PC. As the pseudo random number generator is the same for both programs, the pseudo random numbers are exactly the same, which allows the comparison. The reference text is then compared to the one received by the adapter under test.

To check the validity of this approach, we first received the data from the board using a genuine RS-232 adapter on a desktop PC. Two main operating systems were used during the tests: Windows XP 32 bits, and Gentoo Linux 64 bits. The mainboard was an ASUS P7P55D-LE. Some other tests have been carried out on Windows 8 64 bits on an ASUS P8Z77V-LX mainboard, also with a genuine RS-232 adapter.

On Linux, the software Minicom was the serial communication program, and cmp and Meld were the comparison softwares. On Windows XP, Hyperterminal was the serial communication program, and fc and Winmerge were the comparison softwares. On Windows 8 64 bits, Hercules and Hyperterminal (from Windows XP) were the serial communication programs, and Winmerge was the comparison software.

2. Tests Results.

2.1 USB to RS-232 adapters

2.1.1 Cheap blue USB to RS-232 cord.


Figure 5. Cheap blue USB to RS-232 cord.

A picture of one of these cords partly reveals the inside of the adapter in figure 5. A black spot protects (and hides) the integrated circuit. On Linux, a call to dmesg, a software which prints messages from the kernel, leads to figure 6.

[88026.797070] usb 1-1.6: New USB device found, idVendor=067b, idProduct=2303
[88026.797074] usb 1-1.6: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[88026.797078] usb 1-1.6: Product: USB 2.0 To COM Device
[88026.797081] usb 1-1.6: Manufacturer: Prolific Technology Inc.
[88026.797306] usb 1-1.6: usb_probe_device
[88026.797312] usb 1-1.6: configuration #1 chosen from 1 choice
[88026.797615] usb 1-1.6: adding 1-1.6:1.0 (config #1, interface 0)
[88026.838803] usbcore: registered new interface driver pl2303
[88026.838814] usbserial: USB Serial support registered for pl2303
[88026.838821] pl2303 1-1.6:1.0: usb_probe_interface
[88026.838822] pl2303 1-1.6:1.0: usb_probe_interface - got id
[88026.838825] pl2303 1-1.6:1.0: pl2303 converter detected
[88026.840585] usb 1-1.6: pl2303 converter now attached to ttyUSB0
Figure 6. Output of dmesg after pluging the USB cord.

The cord claims to be based on an IC from Prolific Technology Inc. When used, some characters are lost, as one can see on figure 7.

ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
AUDCO=2
      
PESS A KY OR ! FR THEBIG TEST
PRESS A EY OR !FOR TH IG TET YOU PESSED YVALUE=8959H
YO PRESSE Y VALUE89 59                                                       
PRESSA KEY O ! FORTE BIGTEST                                                 
PRESS  EY OR! FOR TH BIG TET
Figure 7. Example of communication between the USB cord port and the microcontroller.

The outputs of the RS-232 signals, as measured by a digital storage oscilloscope, are  presented on figure 8. The signal should swing from at least -3 V to +3 V to comply with the RS-232 electrical specifications. The measured signal is obviously a TTL signal (0 V to 5 V). This alone would rule out this cord as a true RS-232 to USB adapter.


Figure 8. RS-232 voltages when using the blue cord.

The second finding about these cords is the fact that many characters are lost during reception. An example of what is received is displayed on figure 7. There is no need for a file comparison software to infer that something is wrong with this cord.

Last but not least, if you test this cord with the software provided by Prolific, you will see that the IC is not detected as being a Prolific! Moreover, if you plug this cord in a PC with the genuine Windows drivers provided by Prolific, you run into an error documented by Prolific (yellow mark error code 10 in the Device Manager). Our conclusion is that this cord, and its siblings  that we bought for a few Dollars, embed the "counterfeit (fake) PL-2303" mentioned by Prolific.

Another test was conducted: the same test file was send by Minicom on a genuine RS-232 port and was received by another instance of Minicom using the USB cord connected to the RS-232 port. The USB cord stopped receiving after number 1971, and many characters were lost during this short time. See figure 9 for an example. This last test removed any concern one could have had about the microcontroller board being the cause of the malfunction.

261
262
263
264
265
266
267
268
269
270
271
2
279
280
281
282
283
284
285
286
287
288
289
290
29
298
299
300
301
302
303
304
Figure 9. Typical example of corrupted data received by the blue cord.

What can you do with such a cord?
We will investigate the use of these cords with a TTL logic inverter instead of the MAX232 chip, as the voltage problem might lead to unpredictable behavior of the MAX232A, and we will update this document. Moreover, we noticed during our many experiments that the USB cord behaves slightly better (less data losses) when 7 data bits and 2 stop bits are transmitted instead of the usual 8 data bits and 1 stop bit. But it never reached the bit accurate transfer one could expect. Weird, isn't it?

2.1.2 USB test helper V1.0

This adapter was sold in Canada for approximately $20 in 2012. It is based on a PIC18F14K50 as the USB to serial converter, a MAX232 as the voltage shifter and a 12 MHz crystal. It is provided with the official demonstration software by Microchip. It has a standard ICD connector so you can also upload your own software in the microcontroller, see figure 10.


Figure 10. PIC18F14K50-based USB to RS2232 adapter.

On Linux, a call to dmesg, a software which prints messages from the kernel, leads to figure 11.

[17054.491358] usb 1-1.6: New USB device found, idVendor=04d8, idProduct=000a
[17054.491362] usb 1-1.6: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[17054.491366] usb 1-1.6: Product: CDC RS-232 Emulation Demo
[17054.491369] usb 1-1.6: Manufacturer: Microchip Technology Inc.
[17054.491585] usb 1-1.6: usb_probe_device
[17054.491591] usb 1-1.6: configuration #1 chosen from 1 choice
[17054.491969] usb 1-1.6: adding 1-1.6:1.0 (config #1, interface 0)
[17054.492015] usb 1-1.6: adding 1-1.6:1.1 (config #1, interface 1)
[17054.524659] cdc_acm 1-1.6:1.0: usb_probe_interface
[17054.524663] cdc_acm 1-1.6:1.0: usb_probe_interface - got id
[17054.524665] cdc_acm 1-1.6:1.0: This device cannot do calls on its own. It is not a modem.
[17054.524687] cdc_acm 1-1.6:1.0: ttyACM0: USB ACM device
[17054.525504] usbcore: registered new interface driver cdc_acm
[17054.525507] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
Figure 11. Output of dmesg after pluging the USB to RS-232 adapter.

This adapter is recognized as a USB Abstract Control Model (ACM) device and it can be accessed through /dev/ttyACM0.

On Linux, you can start the serial communication program Minicom with the following command line:
minicom -D /dev/ttyACM0

On Windows, you can access it as another COM port (COM6 for instance).

On all operating systems, the full reference text was perfectly transferred.

2.2 USB to TTL adapters

These are not real USB to RS232 adapters, as they only work at TTL levels (0 V and 5 V). They do not include any voltage shifter to comply with RS-232 specifications. Nevertheless, they are easy to find, and they are often sold as USB adapters for Arduino boards. They are also very low-cost solutions to migrate your system from the RS-232 world to the USB  world (they cost less than $3 in 2013).

As they work at TTL voltage levels, we had to remove the MAX232A from its socket on the PIC18F2525 development board. We connected these adapters directly to the transmit and receive pins of the PIC microcontroller. All the adapters tested are based on ICs that accept 5 V signals, even if they work at 3.3 V.

2.2.1 CH340 USB to serial adapter with TTL levels

This adapter is based on the CH340 IC from WinChipHead / Nanjing QinHeng Electronics Co., Ltd. It has a 12MHz crystal, a few light emitting diodes (LED) to monitor the transmit signal, the receive signal, and the power supply, as seen on figure 12.

Figure 12. CH340 USB to serial adapter.

On Linux, a call to dmesg leads to figure 13.

[23036.495336] usb 1-1.6: new full-speed USB device number 7 using ehci-pci
[23036.506288] hub 1-1:1.0: port 6 not reset yet, waiting 10ms
[23036.580089] usb 1-1.6: ep0 maxpacket = 8
[23036.581144] usb 1-1.6: default language 0x0409
[23036.581416] usb 1-1.6: udev 7, busnum 1, minor = 6
[23036.581419] usb 1-1.6: New USB device found, idVendor=1a86, idProduct=7523
[23036.581421] usb 1-1.6: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[23036.581423] usb 1-1.6: Product: USB2.0-Serial
[23036.581584] usb 1-1.6: usb_probe_device
[23036.581589] usb 1-1.6: configuration #1 chosen from 1 choice
[23036.581809] usb 1-1.6: adding 1-1.6:1.0 (config #1, interface 0)
[23036.602236] usbcore: registered new interface driver ch341
[23036.602246] usbserial: USB Serial support registered for ch341-uart
[23036.602251] ch341 1-1.6:1.0: usb_probe_interface
[23036.602252] ch341 1-1.6:1.0: usb_probe_interface - got id
[23036.602255] ch341 1-1.6:1.0: ch341-uart converter detected
[23036.604321] usb 1-1.6: ch341-uart converter now attached to ttyUSB0
Figure 13. Output of dmesg after pluging the CH340 USB to serial adapter.

This adapter is recognized as a USB to serial port and it can be accessed through /dev/ttyUSB0

On Linux, you can start the serial communication program Minicom with the following command line:
minicom -D /dev/ttyUSB0

On Windows, you can access it as another COM port (COM6 for instance).

On all operating systems, the full reference text was perfectly transferred.

2.2.2 CP2102 USB to serial adapter with TTL levels

This adapter is based on the CP2102 IC bridge from Silicon Labs. It has no crystal. Instead, it relies on an integrated clock. It also has a few LEDs to monitor the transmit signal, the receive signal, and the power supply, as seen on figure 14.


Figure 14. CP2102 USB to serial adapter.

On Linux, a call to dmesg leads to figure 15.
[23334.101513] usb 1-1.6: New USB device found, idVendor=10c4, idProduct=ea60
[23334.101517] usb 1-1.6: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[23334.101520] usb 1-1.6: Product: CP2102 USB to UART Bridge Controller
[23334.101524] usb 1-1.6: Manufacturer: Silicon Labs
[23334.101527] usb 1-1.6: SerialNumber: 0001
[23334.101636] usb 1-1.6: usb_probe_device
[23334.101639] usb 1-1.6: configuration #1 chosen from 1 choice
[23334.101890] usb 1-1.6: adding 1-1.6:1.0 (config #1, interface 0)
[23334.122888] usbcore: registered new interface driver cp210x
[23334.122898] usbserial: USB Serial support registered for cp210x
[23334.122908] cp210x 1-1.6:1.0: usb_probe_interface
[23334.122910] cp210x 1-1.6:1.0: usb_probe_interface - got id
[23334.122913] cp210x 1-1.6:1.0: cp210x converter detected
[23334.133494] hub 1-1:1.0: port 6 not reset yet, waiting 10ms
[23334.195251] usb 1-1.6: reset full-speed USB device number 8 using ehci-pci
[23334.206232] hub 1-1:1.0: port 6 not reset yet, waiting 10ms
[23334.281428] usb 1-1.6: cp210x converter now attached to ttyUSB0
Figure 15. Output of dmesg after pluging the CP2102 USB to serial adapter.

This adapter is recognized as a USB to serial port and it can be accessed through /dev/ttyUSB0

On Linux, you can start the serial communication program Minicom with the following command line:
minicom -D /dev/ttyUSB0

On Windows, you can access it as another COM port (COM6 for instance).

On all operating systems, the full reference text was perfectly transferred.

Conclusion

It seems safe to stay away from cheap USB to RS-232 cords that embedded a counterfeit PL2303. More expensive solutions based on PIC18 microcontrollers and RS-232 drivers work perfectly.
The safe, nevertheless cheap way to go, is to use USB to serial adapters with TTL levels. These are often sold for Arduino boards. They have been found to be easy to use and reliable across many operating systems.

To be continued when other adapters are tested!

Links

CH340: http://wch-ic.com/product/usb/ch340.asp
CP2102: http://www.silabs.com/products/interface/usbtouart/Pages/usb-to-uart-bridge.aspx
Gentoo: http://www.gentoo.org/
Hercules: http://www.hw-group.com/products/hercules/index_en.html
Meld: http://meldmerge.org/
Minicom: http://alioth.debian.org/projects/minicom/
PIC prototyping board: http://roland.cordesses.free.fr/pic_card3.html
Prolific: http://www.prolific.com.tw/US
Pseudo random numbers generator: http://en.wikipedia.org/wiki/Linear_feedback_shift_register
SAN2PC: http://roland.cordesses.free.fr/san2pc.html
Winmerge: http://winmerge.org/


Back to electronics and signal processing