The USB's many advantages have led designers to come up with a wide range of applications for the bus. For example, the figure shows a USB-based controller for four stepper motors built using inexpensive off-the-shelf components. The circuit requires no microcontroller or DSP. It uses simple logic circuitry and application software to control selection of the stepper motors, their clockwise or counter-clockwise motion, and the step size: full step, half step, or microstep.
The design is based on a USB-to-FIFO parallel interface module (IC1). The module, a DLP-USB245M (for details, go to www.dlpdesign.com), provides an 8-bit bidirectional data bus and control signals like WR, RD, RXF, and TXE, which can be used to control the data flow between the PC and any external circuit employing the USB protocol.
Using this module eliminates the need to handle the cumbersome intricacies of USB interfacing. Also, the unit comes with driver software that enables easy and quick control of the module's functions via any high-level language—without having to bother much about the USB protocol.
The rest of the controller circuit consists of general-purpose digital components like octal D flip-flops (74LS273), inverters (7416), a three-to-eight decoder (74LS138), and Darlington array drivers (ULN2003). The USB-to-FIFO module utilizes an external 5-V power supply connected to pins 3, 10, and 11.
The operation is as follows: When the PC has no data to send to the USB-FIFO, IC1's Transmit buffer is empty and RXF is held at logic 1. This makes RD and CLK to the octal D flip-flop (IC2) a logic 0, so IC2's output remains unaffected. However, if the PC sends a byte to the USB-FIFO receive buffer, RXF is pulled low, automatically indicating that at least 1 byte of data is available.
This sets—after a short delayRD and CLK to logic 1 and the data byte output of the Transmit buffer (available at D0D7) gets latched at the output of IC2. Once the data transfer is over, and if the Transmit buffer becomes empty, RXF returns to logic 1. That means no more data is available. This, in turn, sets RD to low so further data transfers can take place.
The lower nibble of the latched data— Q0-Q3 of IC2—drives the other four 74LS273 octal D flip-flops (IC4-IC7), while outputs Q4 and Q5 control the 3-to-8 decoder (IC3). After inversion, the decoder outputs (A', B', C', D') serve as the clocks for IC4-IC7. The Darlington array drivers (IC8-IC11) boost the outputs of IC4-IC7 so they can drive the stepper-motor coils. Thus, by writing a correct data byte to IC1, the PC can select one of the four stepper motors and power its motor coils as desired.
For example, when the PC sends 0x0A to the USB-FIFO, stepper motor 1 gets selected and its coils are energized in the pattern L1 L2 L3 L4 = 1 0 1 0. To move stepper motor 1 forward by one step, the PC sends 0x09 as the next byte, whereas to move it in reverse, the PC sends 0x06.
The table lists the byte values for control of the four motors in full steps. With suitable changes, users can operate the motors in half steps and microsteps. The rate at which the data bytes are written— that is, the time interval between successive data writes—controls the stepper-motor speeds.
Except for the current boosters and the USB-FIFO converter, the discrete components can be implemented in a CPLD/FPGA. Software for the motor control can be developed in many ways. You can use either C or VB or a graphical program like LabVIEW. If you use the VCP (virtual COM Port) driver software provided with IC1 (available as a free down-load), the application program will view the USB stepper-motor controller module as another COM port. But the commands to set the baud rate are ignored and the data is sent at its fastest, regardless of the application's baud rate settings. You can also use the D2XX Direct Drivers for Windows provided, so you can directly control every operation, like FIFO_write, etc.
For basic testing of the circuit's functions, you can use either the DLPTEST application software provided or simply go with serial port programs like Hyperterminal and continuously send the required bytes. The design shown uses 12- and 5-V external supplies. Therefore, you must be careful about the current forcing down the USB bus when the PC or USB hub (if used) is powered down.