News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

USB Help/Hardware Info

Started by Brett Kuntz, February 24, 2008, 05:00:06 PM

Previous topic - Next topic

Brett Kuntz

Hello, I am looking to do a small project, and after banging away at Yahoo/Google for a few days looking for help, I haven't really found what I'm looking for. To simplify things, I'm looking to run a USB cable from 1 computer to another, and have a few questions:

-Is it safe? I understand USB cable carries power, and am fairly certain I would need to modify a cable for this to work.
-As a simple test project, I am going to emulate a mouse or keyboard device using my laptop. My laptop will plug into my computer (using that USB cable), and I want to be able to type on my laptop keyboard, or plug a mouse into my laptop, and have that data emulated/sent to the computer, so the computer thinks it has a mouse.
-In the end, this project is to help me learn USB for the PIC programming/hardware I'm going to be working on (another project).

I have found this site (http://www.microsoft.com/whdc/system/bus/USB/default.mspx) and it seems I may be able to get away with not having to program device driver's for the two computers, as an API called WinUSB was recently invented for usermode USB interaction. Anyone have experience with this? Or know of a great resource site for USB hardware and programming?

Thanks for any help.

zooba

USB is extremely dissimilar to RS232/serial/parallel ports and I don't think you'll gain very much from that plan. Apart from the power issue you mentioned, USB is a master/slave protocol, hence different plugs at either end (no legitimate USB cables have the same shape plug at both ends).

Most USB communications are done by the driver, rather than the application. So an application will send a single command and maybe some data to the driver, which then handles the actual transmission/reception required. This is different to serial/parallel which simply reproduce the bit/bytestreams on the data pins.

I have done quite a bit of work with user-mode and kernel-mode drivers for USB and strongly recommend avoiding them as much as you can! :bg Chances are if you have a device with firmware supplied it will have a driver that can already do everything the device is capable of. WinUSB looks great but I couldn't use it for some reason (I think you require Vista).

The best resource for driver development is the Microsoft stuff, especially the samples that come with the Windows Driver Kit. The best resource for firmware is the USB controller's datasheet (look at the manufacturer's website).

I can probably help with any questions you have, though I am far from an expert in the area. I think you're better off going straight to the actual hardware - it isn't easy to damage anything by programming it :wink

Cheers,

Zooba :U

MrBogus

Here are some ebooks that might help.

USB Complete: Everything You Need to Develop Custom USB Peripherals 3rd edition by Jan Axelson
http://mihd.net/3z7npg

Usb Complete: Everything You Need to Develop Custom Usb Peripherals, Second Edition by Jan Axelson 
http://mihd.net/dop9hc

Developing USB PC Peripherals by Wooi Ming Tan
http://mihd.net/4bs7ul

USB Design by Example: A Practical Guide to Building I/O Devices by John Hyde 
http://mihd.net/t5imc9


Brett Kuntz

Hmm, I think this might be one of those things I might want to buy a book on haha.

Thanks for the help.

edit-Thanks again MrBogus, I'll read those this week and see how it goes.

sinsi

http://www.usb.org/developers - documentation and some tools
http://www.dosusb.net/ - this one includes a DOS driver and some .BAS examples
Light travels faster than sound, that's why some people seem bright until you hear them.

zooba

Good luck getting through those books in a week :bg I had a glance at the first and last ones and they both look pretty good (and thick), but you're up for a lot of work if you want to build your own USB device (even more so than I suggested in my first post).

Depending on how complex your device will be, there's a very good chance that you can get a (free) driver and firmware by using an example from a development kit (not the Microsoft one, from a USB transceiver manufacturer, Cypress Semiconductor for example). That's the hardest part. Interfacing with the driver on the PC and receiving simple transmitted data on your PIC is relatively simple.

Best of luck.

Cheers,

Zooba :U

MrBogus

I am also planning for a project like this but it requires a lot of patience and time for me to learn many things; just starting up to learn for now.  :P Good luck kunt0r. 


:thumbu
regards,
edward