Electronics > Projects, Designs, and Technical Stuff

Simple USB on PIC application: which driver is best?

(1/5) > >>

scrat:
Hi all,
These days I'll start making a simple PC-based data logger, through a USB enabled PIC (18F4550).
At the moment it has to sample analogue values at at least 100Hz, and a minimum of 10s acquisition time is required. However, since capabilities of the PIC are much higher than this, it will be nice to do something more.

I'd like to have the possibility to both see the waveform displayed into a VC++ app and to import data into Matlab.

I see at least 2 possibilities:
- using a VC++ app that will write to a file, the file can be imported into Matlab. Since I have already written some code (based on the Microchip examples), in this case I probably will only have to solve some timing issues, to be sure not to loose any samples. As a drawback, the exchanging by file is a little unsatisfying.
- using a serial COM or other USB driver easily interfaceable with Matlab (and VC++, of course).

Which driver will you choose? WinUSB, CDC (serial emulation), HID, ... Which speeds can I achieve, is transmitting samples in real-time?
Which is the most versatile? Is there a portable solution (for example, to use into Matlab on a non-Windows platform)?

Thanks.

migsantiago:
Hello

If you want to write your code very fast and easily, use CDC and just use the SerialPort Class on the .NET Framework. The downside is that every CDC device requires a driver for the OS.

If you want a driverless device, use HID (my favorite USB Class). True plug&play. You have to use an HID library to read your PIC, but there are plenty of freeware libraries out there.

http://www.lvr.com/hidpage.htm#MyExampleCode

Oh and about the speeds...

CDC is kinda slow on a PIC18. I remember I ran some tests and speed is not constant, this may be a problem if you're looking for real-time sampling.
HID can achieve 64kB/s per interface (512kbps). If you add more HID's to one single PIC, speed can be improved.

scrat:
Thanks Santiago! I admit I was looking especially for your advice, since I've read some of your previous posts on this subject.

If the CDC serial emulation is enough for my present purpose (maximum 1kB/s), then I will use it, since Matlab supports serial ports too.

I'll ask some more questions, not necessarily related to the project:
-If I was now leaving the idea of cross-platform implementation, which would be the fastest class in absolute, for real-time?
-Are the HID Custom Demos from Microchip a good starting point? Does anyone only need the .NET Framework to run them on a Windows PC? Is it possible (and easy) to use them with other libraries?

Thanks once more,
Sandro



alm:

--- Quote from: migsantiago on November 10, 2010, 02:04:23 pm ---If you want to write your code very fast and easily, use CDC and just use the SerialPort Class on the .NET Framework. The downside is that every CDC device requires a driver for the OS.

--- End quote ---
This is only on Windows as far as I know. Most modern OS's support CDC out of the box, just like HID and mass-storage.


--- Quote from: migsantiago on November 10, 2010, 02:04:23 pm ---If you want a driverless device, use HID (my favorite USB Class). True plug&play. You have to use an HID library to read your PIC, but there are plenty of freeware libraries out there.

--- End quote ---
Don't you need at least an .inf file with the correct product/vendor ID's for Windows to even power up the device?

migsantiago:
You're welcome.

If you're planning to run at 1kB/s (8kbps), CDC is the perfect choice. In my tests I was trying to achieve 128kB/s with CDC, and the not constant speed of the PIC18 implementation made me stop using it.

About cross-platform, I guess you're talking about a migration from OS to OS (Win, Linux, Mac, etc.). Well, I have tried to run a CDC pic device on Linux, and I did not have luck. It's kinda annoying because you have to write a driver for each OS, as far as I know. I'm not a Linux expert.

HID is truly plug & play and OS independent. All OSes should include native HID drivers.

About the fastest class... that does not depend on the OS, it depends on the horsepower of the microcontroller that is running the USB connection. For example, an HID device can be implemented on an AVR via software (no hardware modules involved), but the actual speed can't go higher than Low Speed. A PIC18 USB enabled device can actually run at Full Speed.

Yes, HID Demos from Microchip are good. I've not tested them since I've worked with CCS compiler HID Demos.

Reading an HID device from a PC requires using some DLLs from Windows. You can use and invoke them however you want... via .NET Framework, via Borland, via Labview, etc. The easiest and most available method is to use the .NET precompiled libraries.


--- Quote from: alm on November 10, 2010, 04:26:47 pm ---This is only on Windows as far as I know. Most modern OS's support CDC out of the box, just like HID and mass-storage.

Don't you need at least an .inf file with the correct product/vendor ID's for Windows to even power up the device?

--- End quote ---

Hi Alm

As I was saying before, I tested a CDC pic device on Linux and it couldn't be enumerated. The native drivers did not recognize it. The CDC device worked fine in WinXP using a .INF file.

About HIDs, they don't require any driver under Windows. Have you ever installed a new keyboard and Windows has asked for a driver?  ;)

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod