Author Topic: Beginner at USB  (Read 14476 times)

jom

  • Member
  • ***
  • Posts: 8
Beginner at USB
« on: March 21, 2012, 05:15:21 pm »
Hello

Although I've been in electronics about 25 years I really don't have any expertise in UBS or computer interfaces (I have an analog/RF background).  I do have some experience with PIC devices however...

What I need is to have a PIC to directly interface with a PC so as to gather data and plot/print/calculate using the PC.  I'd think this was a rather typical application.  Yet I haven't a clue how to deal with the PC interface.  It has to be a USB port (not an RS232).  So I guess I need to know:

1)  Do I need another IC in between the PIC and the USB connector?  And, no, I haven't chosen a specific PIC device yet
2)  Any "special" programming needed for the PIC?
3)  Will I need a special "driver" put on my PC?

I think I have a handle on the PC software (going to use MS Visual Basic) which allows the USB to be set up as a "COM" port.  I have done this before but I'm still baffled how it actually worked.  lol  In my case the PIC had already been programmed and I just used some VBA code to bring the data in but like I said I'm clueless as to HOW it actually worked...at least electronically.

Anyways, any help on how to get started would be greatly appreciated!   ;D

jom

rallysjd

  • Member
  • ***
  • Posts: 21
    • PiXCL Automation Technologies Inc
Re: Beginner at USB
« Reply #1 on: March 22, 2012, 10:44:45 am »
To answer your questions:
1. "another IC in between the PIC and the USB connector?" Maybe, it depends on the capability of the PIC. Look at offerings from FDDI and similar for Virtual COM Port (CDC Device) kits. Some do  a lot of the protocol handling in hardware, with the final control being the PIC or MCU.

2. Yes, one way or another the USB protocols have to be handled. The good news is that all the manufacturers provide sample code. Look for something that implements the Vitrual COM port already, and has hook functions that YOUR app firmware can send and received data strings.

3. You likely won't need a special driver. Windows has a generic CDC driver, and FDDI (for example) supplies CDC drivers for their kits.

SD

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Beginner at USB
« Reply #2 on: March 22, 2012, 12:54:44 pm »
As rallysjd suggested, an FT232R or FT232H from ftdichip.com is the quickest and easiest way to add USB to a project. The chip has an asynchronous serial port that would connect to a serial port on the PIC and a USB port that would connect to the PC. Both the PIC and the PC access the chip in the same way as if it were a conventional serial (COM) port. The controller chip handles all of the USB protocols. 

If you would like to use a PIC's on-chip USB port, see Microchip's USB Application Framework. Also see my host and device examples here:

www.Lvr.com/hidpage.htm

www.Lvr.com/winusb.htm

Jan

jom

  • Member
  • ***
  • Posts: 8
Re: Beginner at USB
« Reply #3 on: March 22, 2012, 04:02:58 pm »
Thanks for the responses!

What I'm trying to do is to see if I can get away with not using a chip between the USB port and the PIC....for cost reasons.  So it looks as if Microchip's USB app framework is where to start, no?

Thanks

jom

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Beginner at USB
« Reply #4 on: March 22, 2012, 04:24:51 pm »
yes

Jan

jom

  • Member
  • ***
  • Posts: 8
Re: Beginner at USB
« Reply #5 on: March 25, 2012, 05:19:44 pm »
Another thing I probably should have mentioned due to my lack of experience but how does UART fit into all of this?  I guess I'm a bit confused but some PICs have UART capability and some have USB.  With my potential project I probably only need some sort of simple (ie slow) interface.  Would this dictate whether I need full fledged USB or can I use UART.

I highly suspect this is a rather "dumb" question as I suspect this is an "apples and oranges" kind of issue. 

Thanks

jom

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Beginner at USB
« Reply #6 on: March 25, 2012, 09:00:01 pm »
The UART interface is simpler to program so use it if you can.

Jan

Pat Crowe

  • Member
  • ***
  • Posts: 39
Re: Beginner at USB
« Reply #7 on: March 26, 2012, 07:22:07 am »
Just be aware that not many PCs have a serial interface anymore.

jom

  • Member
  • ***
  • Posts: 8
Re: Beginner at USB
« Reply #8 on: March 26, 2012, 10:53:17 am »
Just be aware that not many PCs have a serial interface anymore.

You see?  That is my confusion.  Can't a USB port be used to send UART?  I apologize here but I'm frankly lost.  When I've programmed the PC side of things the software simply set up a COM port and received the data.  But like I said in the OP I was baffled on how it actually worked.  I did not program the actual PIC on the external board I was communicating with so that is what I'm trying to learn.

I made an effort to read through the Microchip USB Framework document and I found that I really was lost.  Completely.  I guess I need to go back and learn the "ABC's"...  ???

jom

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Beginner at USB
« Reply #9 on: March 26, 2012, 01:36:21 pm »
If you want to use serial-port emulation and the PC doesn't have a serial port, you need to either place a USB/serial converter hardware in your device or connect a separate USB/serial converter device between your device and the PC.

You can place a USB/serial converter in your device either by using at FT232x or similar converter chip or by using USB Communications Device Class (CDC) firmware in the device. I believe Microchip's USB Application Framework has a CDC example. If you use the CDC class, the firmware programming is more complex, but you don't need a second chip.

Jan