Although your application seems quite simple, doing it with USB
can be much more complexer than you think.
USB has several advantages compared to the classical bus types like RS232. It is fast, easy to configure (hot plug'n play), less cables etc.
However due to these benefits USB devices are quite sophisticated.
You can compare USB protocol architecture with TCP/IP. This
means that for every application regardless of the simplicity of the application:
- You will need a USB I/O controller for the device.
- You will need a microcontroller to drive the USB I/O controller
- You will need some firmware to do the actual communication with the host (PC).
- You will need a device driver on the PC to handle the USB comm.
- And of course your PC software which uses the button press information.
Before a devices begins actual data transfer, the device has to send
some information about itself. Your firmware running on the device has to
initialize the descriptors on the USB I/O controller when device is
powered on. When device is connected to a PC, PC tries to recognize
the device plugged in by requesting the descriptors from USB I/O chip.
If it recognizes (enumerates) the device it loads the appropriate device
driver to communicate with the device.
If the system doesn't find the suitable driver asks for the device driver
from the user. For a custom device you will a custom device driver, that's
for sure. This means that you have to develop a device driver!!!
If it's Windows system you will need to tap into the world of WDM...
I can assure you that writing WDM drivers is a quite complex and
serious task...
You can use USB I/O chips from National (USBN9602) or Philips (D12).
Those two are the simplest ones. You can drive it with an 8051 micro controller. You can use Keil C compiler for writing your firmware.
And it seems that you can fake an HID (keyboard/joystick) device with
the firmware. So the operating system will think that your device is a
keyboard or a joystick and use the HID device driver. You can report the button press as keypress or joystick button press. Then your PC software
has to use the HID library to access the features of your HID device.
Or you can forget all the things above and implement your device with
the parallel port. Just put your button between any of the error reporting
pins and a positivie source. And drive the error pin to high when button is pressed. On PC side just open the parallel port and check if error flag is set.
Regards,
Nihat Karaoglu
USB Consultant
Centrillium IT Consulting
http://www.centrillium-it.com