Rolling Your Own USB Devices? 46
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?"
USB to Serial (Score:4, Informative)
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!)
Re:USB to Serial (Score:1)
Re:USB to Serial (Score:1)
(Apologies if you do actually have a SCSI keyboard!)
Re:USB to Serial (Score:1)
I've seen ads on PowerMac "wanted" boards for a "SCSI keyboard", I'm wondering if this is just confusion related to connectors, or a brand name?
Re:USB to Serial (Score:2)
Re:USB to Serial (Score:1)
USB Specs (Score:2, Informative)
USB-to-Parallel is an option (Score:4, Informative)
Re:USB-to-Parallel is an option (Score:1)
ActiveWire USB kit, USB reference page (Score:5, Informative)
Re:ActiveWire USB kit, USB reference page (Score:5, Interesting)
Re:ActiveWire USB kit, USB reference page (Score:2)
Ok, sure USB can transmit MUCH faster, but if you want to use this in most viable existing products, you don't need throughput, but quick turnaround times.
And USB repeaters/hubs don't cut it either, they are also way too expensive.
On the other hand, USB is quite a good standard. If there was only a product to do a USB to serial to USB translation... that would be great.
Re:ActiveWire USB kit, USB reference page (Score:2)
part from their products being way too expensive, USB is not a viable technology. As opposed to some serial standards which can go for kilometers, USB is limited to mere meters.
Show me a 12Mbps link that can go kilometres. It's all a speed/distance tradeoff.
Hell RS232 can only go a handful of meters as well. It's the differential standards that go the distance (RS422, RS485, etc.) -- USB is also differential but it's also much much higher speed.
Re:ActiveWire USB kit, USB reference page (Score:1)
Gear for those speeds is fairly expensive still, although OC-1 stuff can sometimes be affordable, assuming that you control everything for the kilometers that you want the connection run (as opposed to other people controlling property in between forcing you to go to the phone or cable company for the cabling run).
Re:ActiveWire USB kit, USB reference page (Score:2)
OC-3, OC-12, OC-24, OC-48, and OC-192 can go 155.52Mbps, 622.08Mbps, 1.244Gbps, 2.488Gbps, and 9.952Gbps, respectively. So, there I shown you 5 links that can go faster than 12Mbps and further then a few kilometers, and all are serial.
No, you've shown me 5 optical links that span more than a few kilometres and are serial, which really isn't much at all. Single-mode fiber can go hundreds of kilometers without issue. Even telco-grade comms are limited though: A 100m coaxial DS3 (44.7Mbps) run is considered "long haul" by its termination equipment, and I believe the max. length for this type of connection is 135m. And that's on two coaxial lines!
100BaseTX can do 100m at 100Mbps using two pair in a 4-pair UTP cable; We're not seeing more links like this because the termination electronics are costly. Your endpoint baluns don't exist in USB and IIRC the USB protocol is quite a bit simpler than 802.3 which helps keep the silicon cost down. Using ethernet is quite popular in industrial segments: power another pair and have the fourth pair for 4-20mA analog signalling. A web search on ModBUS/TCP shows where industry is heading.
In short, thanks for playing. The article is about consumer-grade PC communications, not long-haul telco comms, and I stand behind my original argument in that context.
Re:ActiveWire USB kit, USB reference page (Score:2)
USB has a couple of standards already, and none of them can go the distance.
As for speed/distance tradeoff... It's more like a throughput/latency/distance tradeoff. And I want low latency.
I was speaking of RS485, and although it's not standard on PCs, that's not the point anyway. The point is manufacturing costs.
Re:ActiveWire USB kit, USB reference page (Score:2)
I didn't feel the company who makes this thing was very customer oriented, but the part itself is really cool, and highly recommended.
Try these: (Score:5, Informative)
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
Re:Try these: (Score:1)
the USB specifications... (Score:5, Informative)
USB in a nutshell (Score:3, Insightful)
-BigT
Re:*cringe* (Score:1)
What the hell... (Score:1)
Youre simply asking for a USB cont. chip datasheet (Score:2, Interesting)
I know USB devices at least have a simple usb interface chip that has a parallel like interface to other devices. Try the semiconductor menufacturers and get their datasheets, then see if they have packaging for you (you couldnt work with BGA), then look for a distributer.
Look for USB microcontrollers (Score:4, Informative)
With new standards coming out... (Score:1)
Cypress (Score:2, Informative)
Many ICs are available to do this (Score:1)
They have very good sections on interfacing to a PC using USB.
I have used several USB ICs from Philips, and all are simple to use.
Points to consider
1) If you only want to support the slow USB 1.1 devices (1.5Mbps) then look at USB enabled Microchip PICs
2) Must of the ICs available are in packages that need to be surface mounted. Try buying a development board or evaluation kit, unless you are really good with a soldering iron.
3) USB devices have the idea of a class. e.g. if your project supports the "serial" class then you can use the USB serial driver in linux.
If you need more flexibility you will have to write a new driver to support yor custom device class.
The USB linux drivers are fairly mature and there is documentation on writing new USB device drivers.
4) There are four different USB transfer types.
Control (mandatory) / Interrupt / Bulk / Isochronous (regular transfer with reserved bandwidth)
Ensure the ICs you look at support the transfer types you need and have enough endpoints (channels) for your needs.
USB device programming is easy (Score:4, Informative)
It took several months of head-scratching to get this to work. I used Motorola's MC68HC908JB8 [motorola.com] 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 [mailto].
Have fun!
IC solution (Score:1)
EZ-USB by far! (Score:2, Informative)
There's a book released by Intel called "USB Design by Example" [intel.com] 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
DriverX USB (Score:1)
If just need to wiggle some bits I'd suggest using DriverX or its ilk to access the paralell port, but if you really want to play with USB it should be able to help you too.
Buy don't build!
Javax-USB (Score:1)