USB I/O
About
USB I/O is an I/O device which communicates via lowspeed USB. The computer see the device as a HID (Human Interface Device) like mouses, joysticks etc. It has 8 channels which can be set to output or input independent of each other. The used microcontroller is PIC16C745 with a built-in lowspeed USB controller.

Communicate
In MS Windows you can use win32 API functions with hid.dll to tell the device what to do, but it's rather difficult. Instead you can implement an interface to useHid.dll and use it's functions to communicate with hid.dll and the device. Both syncronous and asyncronous (overlapped) communication are allowed through useHid.dll.
Click here to receive the asyncronous example below.

For more information regarding useHid.dll, click here.
Commands
To control the device you can send the following commands, 2 bytes each:
Get Port, read from inputs
Byte 1 to send = 0x01
Byte 2 to send = 0xXX
Byte 1 to receive = 0x01
Byte 2 to receive = 0x00-0xFF (status of input channels)
Set Port, write to outputs
Byte 1 to send = 0x02
Byte 2 to send = 0x00-0xFF (status of output channels)
Set Pins High, set output channels high
Byte 1 to send = 0x03
Byte 2 to send = 0x00-0xFF (high bits = high output channels, low bits = no change)
Set Pins Low, set output channels low
Byte 1 to send = 0x04
Byte 2 to send = 0x00-0xFF (high bits = no change, low bits = low output channels)
Set Pins I/O direction, choose channels as input/output
Byte 1 to send = 0x05
Byte 2 to send = 0x00-0xFF (high bits = input, low bits = output)
Set LED on/off, switch off and on the LED
Byte 1 to send = 0x06
Byte 2 to send = 0x00-0x01 (0x00 = on, 0x01 = off)
Design
Click here to see the circuit diagram.
Click here to receive the code for the PIC microcontroller.
Updates to do
- Acknowledge of incoming commands
- Timer capabilities of output channels
- Interrupt on incoming signals