Major ACM/Prolific bug fix posted on gitHub

While playing with some cheap USB to RS-232 converters which use counterfeit PL2303 chips I found a bug in acm code which was sitting there from initial release. This bug was causing sluggish response from serial devices, as well as random 0x0d and 0x06 error codes. The bug is now fixed and corrected version of the library has been posted on GitHub a moment ago.

As a side effect to aforementioned bug fix some new functionality is now available. First, ACM and PL2303 classes now have isReady() method which can be used to check if certain device has been enumerated, initialized, and ready for service. This method is now used in all sample sketches, see, for example, pl2303_tinygps.pde, line 98.

Another addition is a block of code which performs proper PL2303 initialization. It is a mix of Linux pl2303.c code and Windows Prolific driver USB protocol traces. This block was added during troubleshooting; it turned out that it doesn’t make any difference on PL2303-based devices that I have – either genuine or counterfeit. However, it is tempting to be able to simulate “proper” manufacturer-recommended behaviour in the code so I decided to keep the initialization. It is turned off by default; if desired, it can be added during compilation by defining PL2303_COMPAT (see cdcprolific.h, line 41 and cdcprolific.cpp, lines 159-179 ). The block adds ~500 bytes to the binary so don’t turn it on just in case.

Please check the new code with your devices and let me know if you can see any improvements or new issues.


USGlobalsat ND-100S GPS receiver works with USB Host library

ND-100S GPS receiver connected to USB Host shield

ND-100S GPS receiver connected to USB Host shield

After posting an article about interfacing USB GPS receiver to Arduino I started receiving e-mails from people asking about a decent inexpensive GPS receiver compatible with USB Host library. After some research and testing I finally found a device which I really like.

ND-100S from USGlobalsat is small, inexpensive (less than $30 shipped at DealExtreme) GPS receiver with excellent characteristics. Below are some bullet points:

  • Lightweight – my scale shows 19g for the dongle without connector cover. It is possible to get weight close to 15g by removing the case, USB connector and hardwiring the module to USB Host shield.
  • Sensitive – SiRF Star III high sensitivity GPS chip allows this module to lock in less than a minute from my basement (!). Outdoor performance is simply amazing while power consumption stays around 50ma.
  • Easy to use – the module uses Prolific PL2303 USB to serial converter supported by USB Host library 2.0 and the sketch from the previous article works without any modifications. Also, the module has status LED showing when GPS position is fixed – comes in handy during field tests when serial console is not available. The dongle ships with semi-rigid USB cable which can be used as a raiser.

Overall, ND-100S is very small, sensitive and inexpensive GPS receiver. It can be used with USB Host shield using PL2303 USB to serial converter support in USB Host library rev.2.0. I have a couple of projects in mind which would use this receiver – will post as soon as I have more information about it.


Communicating to GPS Receiver using USB Host Shield

Navibee GM720 connected to Arduino

Navibee GM720 connected to Arduino

Here is another quick demonstration of USB Host Shield 2.0 Library. This article describes how to communicate to Navibee GM720 GPS receiver based on SiRF Star III chipset and PL2303 USB to serial converter. This GPS device is available on eBay for around $25 new, used units can sometimes be found for $10 or even less. The receiver has waterproof case, magnet mount and comes with 6 foot cable. Another nice feature of this device is its 40mA current consumption. Here are some pictures of the unit – PCB, internal antenna, as well as front and back of the original packaging.

“Classic” GPS receiver sends and receives NMEA 0183 messages via serial port at 4800 bps. Modern GPS units often support faster speeds and vendor-specific messages. However, they mimic classic GPS unit behavior – at power-on they start sending basic navigation messages at 4800 bps. The following sketch outputs messages, received from Navibee GM720 GPS unit via its built-in PL2303 USB to serial converter connected to USB Host Shield. Full text of the sketch is available on gitHub, below is just a fragment where speed is set to 4800.

The OnInit() member function is called to change serial parameters after initialization. A lc structure of type LINE_CODING is declared on line 14. It is filled with baud rate (line 15) and number of data bits per byte (line 18) and then sent to Pl instance in line 20.

Compile the sketch, load and run. The output is depicted on a screenshot after the code fragment.

Continue reading Communicating to GPS Receiver using USB Host Shield

Building PL2303 USB to Serial converter from old data cable

PL2303 and Xbee on a breadboard

PL2303 and Xbee on a breadboard

Despite being quite old, asynchronous serial interface is still popular these days. Xbees, Bluetooth and WiFi embedded adapters, standalone GPS modules are often equipped with asynchronous serial data port. At the same time, standard size Arduino comes with just one asynchronous port – and the same port is used to load compiled sketches and print debug messages. Using these functions while sharing serial port with peripherals is never trivial and often impossible. Recently announced revision 2.0 of USB Host Shield library allows communication with several USB devices simultaneously making it possible to talk to multiple peripherals via USB to serial converters. The converters are available from many places and cost around 15 dollars. However, any old cell phone data cable is essentially a USB to serial converter and can be used as such with not much difficulty. In this article, I will show how to modify data cable originally intended for Sony Ericsson T226 phone into general purpose USB-to-serial.

Continue reading Building PL2303 USB to Serial converter from old data cable