Slashdot Mirror


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?"

46 comments

  1. but i am :-) by Anonymous Coward · · Score: 0

    no text

  2. USB to Serial by moosesocks · · Score: 4, Informative

    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
    1. Re:USB to Serial by rtmfm · · Score: 1

      Well that piqued my interest.... Can you point me toward some info on the SCSI keyboard? Maybe a model number??

    2. Re:USB to Serial by IntlHarvester · · Score: 1

      If your CPQ is like my CPQ keyboard, it isn't SCSI, it just uses a similar connector to a Mac PowerBook SCSI plug. It's plain ol PS/2 with the audio wires running out to a speaker and some plugs on the keyboard.

      (Apologies if you do actually have a SCSI keyboard!)

      --
      Business. Numbers. Money. People. Computer World.
    3. Re:USB to Serial by Nonesuch · · Score: 1
      IntlHarvester wrote:
      If your CPQ is like my CPQ keyboard, it isn't SCSI, it just uses a similar connector to a Mac PowerBook SCSI plug. It's plain ol PS/2 with the audio wires running out to a speaker and some plugs on the keyboard.

      (Apologies if you do actually have a SCSI keyboard!)

      As far as I know, there is no such thing. Too bad, now I want one.

      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?

    4. Re:USB to Serial by Rick+the+Red · · Score: 2
      Yes, the simple answer is to use the serial/parallel ports, but many new computers don't have them, they only have USB.

      --
      If all this should have a reason, we would be the last to know.
    5. Re:USB to Serial by mitheral · · Score: 1

      I think he was infering to use something like this USB to Serial Adapter

  3. USB Specs by ObviousGuy · · Score: 2, Informative
    --
    I have been pwned because my /. password was too easy to guess.
  4. USB-to-Parallel is an option by Gudlyf · · Score: 4, Informative

    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.
    1. Re:USB-to-Parallel is an option by bic2k · · Score: 1

      USB-to-Parallel works for linux 2.4 as well

      --
      --- its to bad about the monkey, I kinda liked them
  5. ActiveWire USB kit, USB reference page by tburke · · Score: 5, Informative

    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.

    1. Re:ActiveWire USB kit, USB reference page by zenyu · · Score: 5, Interesting

      Active Wire is probably best for someone that doesn't have access to a parallel port, but if you just a few on/off switches the cheapest solution is a dissected usb mouse. You can just wire into one the buttons for the switch. Plus you probably have bunch of non-ergonomic mice around, they are almost as common as mousepads...

    2. Re:ActiveWire USB kit, USB reference page by Domini · · Score: 2

      Apart 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.

      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.

    3. Re:ActiveWire USB kit, USB reference page by tzanger · · 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.

    4. Re:ActiveWire USB kit, USB reference page by UberLame · · Score: 1

      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.

      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).

      --
      I'm a loser baby, so why don't you kill me.
    5. Re:ActiveWire USB kit, USB reference page by kevin42 · · Score: 2

      I've got one of these, it's based on a cypress USB chip, which includes an internal 8051 cpu. Full datasheets are available for this chip. The source to the linux driver for the USB controller is also available. The device gets it's firmware from the driver on the host CPU, so it's really easy to write 8051 code and try it out on the device. I've got mine wired up to access onboard memory on my FPGA development kit, which makes for really fast IO between the FPGA and the host PC.

      I didn't feel the company who makes this thing was very customer oriented, but the part itself is really cool, and highly recommended.

    6. Re:ActiveWire USB kit, USB reference page by tzanger · · 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.

    7. Re:ActiveWire USB kit, USB reference page by Domini · · Score: 2

      Never mentioned RS232 as *the* serial standard.
      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.

    8. Re:ActiveWire USB kit, USB reference page by Anonymous Coward · · Score: 0
      Apart 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.

      USB was designed to replace the mess of different cables (keyboard, mouse, printer, audio, joystick) that hang off the back of most PCs with one universal serial bus (hence USB). It was designed to go "mere meters".


      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.


      /me scratching head. It's already replacing pre-USB keyboards, mice, and joysticks (not that conventional keyboards, mice, and joysticks are obsolete... yet). I'm not even sure what you mean by "you don't need throughput, but quick turnaround times."

  6. Try these: by stienman · · Score: 5, Informative

    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

    1. Re:Try these: by |<amikaze · · Score: 1

      Dontronics is definately cool. I was their 100,000th visitor, and I took a screenshot and sent it to him. In return, he gave me plans and the PCBs for the SIMMStick projects (unsure if he still sells them). Definately a cool project.

  7. How the fuck did you get your +2 back? by Anonymous Coward · · Score: 0

    I would have thought you'd be banned from that by now...

    1. Re:How the fuck did you get your +2 back? by Lee+Cremeans · · Score: 0, Troll

      Learn the ways of the Karma, young Jedi. You will soon be able to wh0re and burn with the best of them.

      -lee

  8. Re:What the fuck is a "simply interface"? by Anonymous Coward · · Score: 0

    heh heh, good one.

  9. the USB specifications... by invictus · · Score: 5, Informative

    can be found here for both USB v1 and v2

    --
    --Ks9
  10. USB in a nutshell by BigT · · Score: 3, Insightful
    Here is a good description of USB that sort of digests the spec for you. It has lots of info about the device software and hardware.

    -BigT

    --
    Is it weird in here, or is it just me?
  11. *cringe* by wizbit · · Score: 0, Troll
    ...easy to whip up a simply parallel port device of some sort...
    ...start with a simply interface box
    ...a number of simplysimply on/off out/input channels

    DUDE.

    the word is SIMPLE!

    :)

    1. Re:*cringe* by Anonymous Coward · · Score: 0

      maybe he simply wanted to ask the question? ;-)

    2. Re:*cringe* by datenwolf · · Score: 1

      Cypres Semicon has a Intel 8051 compatible Microcontroller AN2131 that also provides a complete Full Speed USB interface.

  12. What the hell... by DEBEDb · · Score: 1

    make it JINI-compliant: )

    --

    Considered harmful.
  13. Youre simply asking for a USB cont. chip datasheet by mnmn · · 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.

    --
    "Give orange me give eat orange me eat orange give me eat orange give me you." -Nim Chimpsky
  14. Look for USB microcontrollers by Emil+Brink · · Score: 4, Informative

    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);}
  15. With new standards coming out... by fok · · Score: 1

    I think the Linux Cofee How-To needs some updates!

    --
    \m/
  16. Cypress by GreenKiwi · · Score: 2, Informative

    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.

  17. Many ICs are available to do this by rjs397 · · Score: 1

    Have a look at http://www.beyondlogic.org
    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.

  18. USB device programming is easy by Anonymous Coward · · Score: 4, Informative

    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!

  19. IC solution by billcopc · · Score: 1

    Microchip (the company) has a PIC that natively handles USB comms, I believe it is an enhanced 16F84-type chip. I haven't had any personal experience with this device but you might want to look into it. PICs are excellent for multiplexing simple i/o lines into a ready-to-interface stream.

    --
    -Billco, Fnarg.com
  20. EZ-USB by far! by GTstapler · · Score: 2, Informative

    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

  21. Re:didn't answer question by Anonymous Coward · · Score: 0

    Unfortunately like so many other snide answers, you failed to answer the question. You just pulled up related but irrelavant information.

    If the submitter was capable of building a device to the USB specs, he wouldn't have asked the question.

    A more relevant answer would be to suggest one of the many USB interface chips available, some of which come with reference drivers for basic USB tasks. Unfortunately it is probably easier to buy a usb to parralel adapter. Though your compatibility may vary, many of these adapters aren't 100% accurate, and should be thought of as more of an emulator..

  22. Re:didn't answer question by Anonymous Coward · · Score: 0

    If you had read the question, he was looking for information on how to build his own interface, which he had done with parallel ports.

    If he can build a parallel port from specs, it makes sense that he can build a USB port from specs (transitive).

  23. DriverX USB by RiBread · · Score: 1

    I've used DriverX many times for PCI and paralell port access. They have a new product "DriverX USB" that I'm just starting to check out for an upcoming USB project. It sounds like just what you're looking for.

    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!

    1. Re:DriverX USB by Anonymous Coward · · Score: 0

      "Buy don't build" kind of defeats the idea of needing bit-level I/O in the first place. When hobbyists can no longer stay reasonably close to modern technology, the "open-source" hardware enthusiasts will die out and everyone will be restricted to what the major corporations decide will sell the most.

  24. Javax-USB by bcarlson · · Score: 1

    Here is a Java API for USB: javax-usb @ ibm devworks. Good luck, and have fun!

    --

    "...I'll need guns" --Chow Yun-Fat in 'Replacement Killers'