Electronic – What type of USB Protocol for Datalogger

picprogrammingusbusb device

I am attempting to create a USB datalogger and would like to first start with creating a program that transmits Hello World over USB not using some kind of CDC communication. I am trying to figure out what device class I should use. Am I right for trying to set it up as an HID device? FYI, I plan on using the PIC32 USB Starter kit for this.

Best Answer

As already discussed, the Communications Device Class (CDC) is probably a better fit than Human Interface Device (HID) class for a data logging application. That being said, there may be some reasons for using a HID based protocol rather than CDC such as availability of host operating system drivers.

Windows provides a generic programming interface for HID devices which allow you to access any device using the HID class without any special drivers. If this is a commercial product, using a HID avoids the needs to have a signed driver such as would be required if CDC were used. Since a HID device does not require a driver to distributed with your product, the end user experience may also be simpler.

There are some drawbacks with using a HID based driver though. HID is not stream based, meaning the host OS will poll for data (reports) and will happily drop incoming report packets if the application does not read the incoming data fast enough. This then requires that you implement your own protocol on top of the provided HID reports at the application layer to provide a reliable transport using the output and input report fixed length packets for data transfer. Data throughput using this method will be significantly slower than a stream based protocol such as CDC.

Some useful data on USB HID can be found at http://www.lvr.com/hidpage.htm