Rolling Your Own USB Devices?
greasyHacker asks: "Back in the old days when every computer under the sun had a parallel port, it was quite easy to whip up a simply parallel port device of some sort, and pretty easy to write software for it.. Now that USB is here and standard, I'd like to make use of the 'power of USB' and roll my own devices. Specifically I'd like to start with a simply interface box that allows me to control a number of simply on/off out/input channels - much like this. (Then maybe fulfilling some other ideas later).. Can anyone suggest where to get information on such a project, both the hardware and the driver side of things?"
Unfortunately, as it stands now, the easiest thing to do seems to be to get a USB to serial/parallel converter, as serial and parallel devices are much easier to construct.
:) ).
Of course, you could disassemble the converter to intergrate it into whatever you are building, as well as tapping the power current from the USB port.
Think of it this way: it's like building a SCSI mouse (sidenote: I own a compaq scsi keyboard... strangest contraption ever built
I really don't think USB is suited for this task. It's just too complicated, and parallel and serial seem to work just fine for now, as they use much simpler communication mechanisms (if USB were simple, it would have been invented a long time ago. duh!)
-- If you try to fail and succeed, which have you done? - Uli's moose
30 seconds of effort revealed this.
I have been pwned because my
Since it sounds like speed isn't really an issue with your projects, you can get relatively cheap USB-to-Parallel and USB-to-Serial converters. Buy a bunch of them if you want and throw them on a USB hub. I know first hand that the USB-to-serial is compatible with Linux (at least kernel 2.4.x) -- not sure about the other one.
Trolls lurk everywhere. Mod them down.
ActiveWire has a nice looking USB project board, and a number of add-on boards that will probably do what you want, with Linux and Windows drivers. USB Central is a good USB resource page with links to that and other USB boards.
Giga Technology USB Devices
Dontronics is reputable place to get stuff. In the end you may want to stick with a serial port to a microcontroller, and use USB serial port cables to work with them.
Many, many products still work this way.
-Adam
can be found here for both USB v1 and v2
--Ks9
Many microcontroller families now have parts that include support for USB, as an on-board peripheral. With one of these, building your own USB device shouldn't be too hard. I say "shouldn't", because I have yet to try it out for myself. I've looked a bit on the PIC16C745 part from Microchip. It has on-board USB support, but only for "interrupt" transfers (suitable for e.g. a mouse or keyboard, but not for something requiring data streaming). It's fairly cheap ($5.45 in ones from DigiKey), too. Of course, it's a one-time-programmable part, which isn't very good for experimentation. It's also available in a EPROM version, for $11.74), though. And you'd need to learn the PIC instruction set, and get the required programmer hardware... Still, I think it looks like at least a possible way to get in to doing your own USB devices. There are USB-enabled micros from other manufacturers as well, but I haven't looked into them in any detail. Search the web.
main(O){10<putchar(4^--O?77-(15&5128 >>4*O):10)&&main(2+O);}
Cypress have a number of different USB 1.1 and 2.0 solutions that work extremely well. They have the SX series and FX series. The SX series is very simple to use, as it is essentially a fifo that an external processor can control. The FX series is a flexible io device with a 8051 that controls it. You might look into either of these as a way to develop your product. They have dev kits for $500 or so (I don't remember the exact price). The kits come with development software and a demo driver.
I have done this already, having built a USB controlled robotic webcam mount for senior project. It has an internal USB hub too, so it doesn't take up any extra USB ports. Just plug it in, plug the camera into the base, and you're ready to go.
It took several months of head-scratching to get this to work. I used Motorola's MC68HC908JB8 USB 1.1 microcontroller, and highly recommend it to anyone who wants to build a low-speed device. Even at low speed, you can transfer data over 64kbps, so it's pretty useful for a wide range of control applications. It has a good in-circuit serial programming interface, and the development tools from PEMicro are excellent and free.
The route I suggest, and the one I eventually took, is to program the device to enumerate as HID-compliant hardware. This makes things vastly simpler, since Windows has built-in drivers for HID devices, and with a little tweaking you can pipe as much data back and forth as you want. It took me a week of evening work, and a solid 24-hour coding spree before I got two-way communication working correctly, but after that everything was a breeze. If you want your device to be compatible with Windows 95, you need to keep it USB 1.0 compatible, which means just Endpoint 0 and Endpoint 1. You have to tunnel data to the device through control transfers, which after you figure it out, becomes mostly transparent to the rest of your program.
I like the 908JB8 because it's Motorola, has 8k of Flash, and costs a couple bucks. The surface-mount profile is big enough so that you can solder it without huge headaches. You can get these chips from Digikey.
Using the HID method also opens up some cool possibilities. Just by changing a few identification numbers, you can make the device into a mouse, keyboard, joystick, volume control, or other recognized HID devices. It would be pretty simple to take a MC68HC908JB8 and turn it into a custom joystick with 50 buttons, or flight yoke or some other crazy peripheral. The hardest part would the mechanics, unless your good at that sort of thing.
If you want a high-speed device, you are in for a few more headaches, but nothing impossible for you wizard coders out there (I accomplished what I needed to with zero training in assembly or C++). Definitely go with the Cypress chips, they are widely documented and have lots of great features. I've even seen that some of their hub controllers have microcontrollers that you can program as well.
Highly recommended book: USB Complete by Jan Axelson. This book will be infinitely useful to anyone who wants to program USB devices. Also check out the comp.arch.embedded newsgroup. Jan posts there are lot, as well as many others knowledgable in the field.
There isn't much documentation out there on the MC68HC908JB8, but for anyone who wants to see what I've worked on, shoot me an email at garrett.r.mace@rose-hulman.edu.
Have fun!
So, I do A LOT of USB hardware/software stuff in my disseration work, and I think the Cypress series is by far the best. If you get an elcheapo chip to convert the USB signals then you have to program the protocol manually which is a serious pain (that was the first thing I tried). I gave up and switched to a Cypress EZ-USB because it's the most popular, meaning it has the most support out there. You don't have to use the microcontroller because you can access the USB directly using a DMA to the USB memory location. The microcontroller runs at 24MHz, while the full speed mode (USB 1.1) runs at 12Mbits/s, but the project you describe doesn't need to be faster than 24MHz. For a slow speed application you can just route the data from the USB memory to an output port, and capture the input data on another port. It's a 52 pin package (surface mount) - two 8-bit ports and one 2 bit port on this package.
There's a book released by Intel called "USB Design by Example" which has the EXACT project you're working on. It details all the hardware setup and provides software examples. Its software is in Microsoft Visual Basic and C++. If you want to reproduce that project this is the best way to go. Let the microcontroller deal with the USB protocol to keep it simple.
gtstapler