The U401 and U421 USB Interface from USBmicro are an easy way to interface a number of real-world devices to the PC (or Mac/Linux). The U401 and U421 currently have a number of very useful interfacing features.
The USBmicro U401/U421 can be programmed to be simple digital i/o. There are two 8-bit ports on the device that can control 8 bits / 1 port at a time, or individually on a bit-by-bit (each i/o line) basis. There are two commands that set port A and port B i/o directions. The individual lines of the port can be set to inputs or outputs on a per line basis, but the command to set the direction operates on an entire port. The ports can be read with two distinct port read commands. The state of the lines that are set as inputs are returned with the read command. The state of any line that is not set as an input is undetermined and should be ignored.
The ports, when set as outputs, can be written on a byte-wide basis with two distinct port write commands. Also, individual line states may be changed with a set of commands that mask the port state and affect only user-specified lines. This effectively allowsing for bit writes.
Commands to these devices allow for a byte write to one port, while strobing a user-selected line from another port. The strobe can be either negative-going or positive-going. This feature allows a full byte-wide data transfer.
These general i/o commands will let you interface a wide number of devices to your computer. Many “real-world” devices can then present detectable signals to the PC, or can be controlled by signals from the PC.
LCD Interface
Along with the more manual way to interface devices using the general i/o commands, the U401/U421 provide some useful commands that can be thought of as “compound commands”. An LCD, for example, could be interfaced and controlled with the regular i/o commands. The USBm.dll provides function calls that make it a bit easier to interface a standard Hitachi-type of intelligent LCD controller to USB. These commands support communication to the LCD module with a single function call that performs multiple i/o steps. LCD commands include writing characters to the display, and controlling the display (initializing, clearing, moving cursor, etc).
SPI Master
The U401/U421 can be used as an interface to Serial Peripheral Interface (SPI) devices. The firmware of the device provides generic access to read and write many different types of SPI devices. The SPI clock rate transmitted from the device can be adjusted to 62.5 kHz, 500 kHz, 1 MHz, or 2 MHz. The master SPI interface consists of the SPI clock (SCK), Master Out / Slave In (MOSI), and Master In / Slave Out lines. MOSI is the U401 or U421 line that moves information out of the USB device to the SPI slave device. The MISO line is the data line on which the USB device receives data from the slave device. Additional pins are available as generic i/o; the U401/U421 can use these lines as slave select lines (often called “chip select”) to address multiple SPI devices.
SPI Slave
The U401/U421 can be operated as a SPI slave device. A microcontroller circuit external to the device can transfer data via SPI into the U401/U421. The data can then be read from the PC (Win/Linux) or Mac (OSX) with an application. The external processor could be, for example, a PIC or AVR that performs data collection and filtering from an analog sensor, and transfers readings to the PC (Win/Linux) or Mac (OSX) via the U401/U421.
Stepper Motor Control
The U401/U421 can be operated as a two channel stepper motor controller. Through an appropriate voltage/current driver interface, the U401 or U421 can interface to various types of stepper motors. The USB interface device supports the stepper sequences of “Wave”, “Full”, or “Half” with control over direction, speed, and step count.
1-Wire Interface
The U401/U421 can interface with Dallas/Maxim(R) 1-wire devices (temperature sensors, i/o ports, etc) either on each individual U401 or U421 device pin, or on a bus of multiple 1-wire devices.
This is a very versatile interface and a premium way to connect a PC to real-world devices.
Leave a Reply