Ah, just thought of a problem. Its not that the USB device is connected or disconnected, as i have it powered by the USB port anyway. I believe that it is failing to work as it is expecting data during the DoUSBOut routine, but when the PC is off, there is no data.

With this previous suggestion, this will be only to detect whether or not the device is plugged in or not. As with this device it will always be plugged into a USB port, whether the machine is powered on or not. If the PC is off, 5v will still be on the USB ports to keep this device powered up as usual.

Hope this makes sense. Any other suggestion?

Steve