February 28, 2012

Arduino Uno serial port

I finally bought an "original" Arduino Uno. It costs far more than the Arduino Mega local clone that I've been using, but the main reason is because I want to see how the ATmega16U2's COM port emulation works in Windows. (I have the Uno R3, older revisions of the Uno has the ATmega8U2.) Of course, I want to support the Arduino project.

Older Arduino's and most of the Arduino clones use the FTDI FT232R chip for the USB UART. FT232R works great with Windows, and has the ability to change COM ports, which is really important for supporting older programs that have fixed COM ports. In fact, after discovering how good the FT232R works from using my Arduino Mega clone, I started buying USB to RS232 adapters that use this chipset, and they work with everything I've thrown at them, including DOS applications running in Windows.

One feature the FT232R chip has is that if the COM port is fixed to a particular adapter or Arduino board, Windows will remember the setting and it will continue to be that COM port, unless manually changed. This is important if I have multiple serial port devices all connected to the same computer. They all remember what COM ports they're supposed to be, and everything just works.

You might think this is the standard USB behavior for Windows, but NOOOOOOOO. Recently we got some industrial barcode printers from Argox. While they're decent barcode printers, whoever designed the idiotic USB interface needs to have infinite barcode printers stuffed up their behinds. The problem is that every single Argox printer looks like the same printer to Windows. So whichever printer I turn on first is always "Printer 1". This might be fine for people with just one printer, but I need to have multiple different sized labels printed simultaneously. So my users have to remember to always turn on their printers in a particular order.


Anyway, I discovered both the FTDI driver and the standard Windows driver lets you change the COM ports without any limitation. But the FTDI has an additional option that's really useful: the ability to disable the serial port enumerator. The serial port enumerator is a left-over thing from when mice were plugged into the serial port. If Windows sees incoming data over the serial port when booting up or configuring hardware devices, it will automatically configure the serial port device as a mouse. This is problematic if you have an Arduino or other serial port device connected, and your mouse pointer goes crazy, this is what's happening.


Unfortunately, Arduino Uno's ATmega16U2 emulates a standard COM port so perfectly, it still uses Windows' own driver. Fortunately, the ability to change the COM port number is still there, but sadly there's no built-in way to disable the serial port enumerator.

Before Windows 7, Microsoft had a COMDisable Tool that does the job. With Windows 7, it looks like you're outta luck. Either go back to Windows XP, or use an FTDI based adapter with the serial port enumerator disabling option. But wait, what about the Arduino Uno? Well, don't let it send data over the serial port in a mouse-like manner, and all should be fine.

... Speaking of serial port mouse. You think Apple invented shiny white products? Nope, Microsoft did with the 9-pin serial mouse, also known as the soap mouse at the time. It was shiny and white, and five minutes after you start using it it's covered with fingerprints and scratches, and people loved it. I had one and I hated it.

Image courtesy: The MCA Mafia

No comments: