1
\$\begingroup\$

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.

\$\endgroup\$
  • 8
    \$\begingroup\$ I don't think HID, Human Interface Device, will be the right choice. CDC serial-out seems like a decent choice why do you discount that? Another option could just be a disk device. \$\endgroup\$ – kenny Oct 11 '11 at 21:02
  • 1
    \$\begingroup\$ I'd also vote for a scheme functionally equivalent to a serial port - it's logically simple, easy to create alternate software for and thus support varied host operating systems, plausible to replace the USB with bluetooth or some mid-range wireless link, or even "real" serial in a legacy situation or if you need to opto-couple it in an industrial setting. \$\endgroup\$ – Chris Stratton Oct 12 '11 at 4:30
  • \$\begingroup\$ Another option for a data-logger system, if you only want to retrieve the data is the USB mass storage. But this will require a file-system (a small file-system is fine). You device can act like a thumb drive, simply plug into a PC and download the file with the data. You can also have special configuration files that the device can read and use for configuration. This removes the need to build your own command processing functions. \$\endgroup\$ – Christopher Felton Oct 12 '11 at 12:51
2
\$\begingroup\$

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

\$\endgroup\$
  • \$\begingroup\$ Very good answer. No room for improvement \$\endgroup\$ – Saneesh A T Oct 14 '11 at 10:17
1
\$\begingroup\$

I'd recommend using CDC as listed above. If that doesn't work for you the MSD class might. Last resort option would be to code your own, but that will require writing a device driver for the host operating system you plan on using your device with.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.