USB (universal serial bus) was supposed to solve a lot of problems when connecting devices to PCs, but in many ways it’s still a bit of a pain in the plughole. Typically, each new device needs a new driver to be installed. Often, a COM port then gets assigned, and you have to find out from the operating syssystem what the COM port number is. And with some products, that COM port number can change if you plug it into a different socket! A sneaky way round the driver problem is to use the Human Interface Device (HID), as used by mice and keyboards, or the Mass Storage Device (MSD) interface, as used by flash drives.
This is because just about all the flavors of Windows, Mac and Linux operating systems available today have HID and MSD drivers pre-loaded. HexWax Ltd. have adopted this approach for their driver-free USB chip sets. Their USB to UART, SPI and I2C bridges use the HID interface and their embedded file system and data logger chips use the MSD interface. A particularly flexible friend is called ‘expandIO- USB’. As its name suggests, it is an I/O expander with a USB interface. But that’s a modest description, considering its analog-todigital inputs, interrupts, PWM, comparators, counters, timers, SPI, I2C, UNI/O, etc. The USB interface is designed so that all the programming is done on the PC rather than on the chip, which saves a lot of development time. For example, to measure the analog voltage on AN6, you send the following 4-byte command from the PC (0x prefix denotes hexadecimal): 0x96 0x06 0x00 0x00
The chip takes the measurement and reports the result as a 4-byte response: 0x96 0x06 0x02 0x36. In this example, the voltage measured is 5 V × 0x0236 ÷ 0x03FF = 2.76 volts.
Similarly, the following command exchanges three bytes with a slave SPI device: 0xAF 0x03 0x45 0x67 0x00. Command: Send
0x45 0x67 0x00 to slave. 0xAF 0x03 0x00 0x00 0x89. Response: Slave sent 0x00 0x00 0x89. The commands are sent using the operating system’s HID interface, which is very similar to reading and writing to a file. Example source code is provided at . In the basic circuit of the driver, Figure 1, only a crystal and filter capacitors are required in addition to the ‘expandIO-USB’ chip also described in some detail at . Although it is available as a through-hole device, the surface mount version has the advantage that it is small enough for ‘dongle’-style applications as shown in Figure 2. Surface mount USB plugs can be quite difficult to source, but an elegant, zero-cost solution exists. You can design one into the printed circuit board itself, so long as you don’t mind a PCB 2.0–2.20 mm thick including tracks (arrow ‘A’ in Figure 2) for the dimensions. For best reliability, the PCB contacts (‘B’) should be plated with hard gold flash (0.25-1.27 μm) over nickel (2.6-5.0 μm). Finally, shoulders (‘C’) are required to prevent over-insertion force.