PC Is Not Seeing My PIC 18F2550 [USB Connection]

Discussion in 'Embedded Systems and Microcontrollers' started by ajm113, Oct 6, 2011.

  1. ajm113

    Thread Starter Member

    Feb 19, 2011
    176
    5
    Hello all I'm trying to get a basic PIC such as the PIC 18F2550 to be read as a USB device on my Windows 7, but so far no matter what I do, my PC can't seem to see it.

    I have the data+ and Data- pins connected to a USB cable that goes to my PC and of course have the positive and negative connected to the PIC, my programmer isn't having any issues programming the PIC. I've build and ran this gentlemen's code on my PIC. I've also attached the outputting hex file I've used and even ran he's program that's supposed to talk to the PIC, but it can't even see it.

    http://www.waitingforfriday.com/index.php/Building_a_PIC18F_USB_device

    The only thing I'm doing differently with that guys work is that I'm not using a crystal for the OSC pins. Don't PICs have a internal cystal they use for timing? Is the external crystal needed for USB communication?

    Of course I have the VUSB pin connected to a .1 uF capacitor that goes to ground, so I'm not sure what I'm doing wrong.
     
  2. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    If you aren't using the crystal you need to set the configuration of the PIC so that it uses the internal one instead and make sure the change in speed doesn't affect the operation. Much easier just to get a crystal.
     
  3. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,392
    1,605
    That crystal is vital to run the USB module at the correct speed.

    Sorry mate, you have to get the same crystal as he used for his code to work.

    I've used a resonator there of same frequency, cheaper and saves the 2 caps, but in a worst case analysis they will violate the USB timing spec. So that's OK to breadboard but don't use it in a product.
     
  4. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    I you change the code it may be that you can do without a crystal. I see in the code that the 20 MHz clock is pumped up to 48 MHz using the internal PLL. And I think you may also be able to generate 48 MHz using the internal oscillator and the PLL. Not 100% sure. So you must confer with the data sheet about this. If you use the code as is. You must use a 20 MHz crystal.
     
  5. CraigHB

    Member

    Aug 12, 2011
    127
    15
    The internal oscillator for a PIC is the RC type. These can suffer from fairly wide fluctuations due to external conditions and manufacturing tolerances. For many applications it's not an issue, but for some it is.

    Some PICs have an oscillator tuning function that can compensate for variances in the internal oscillator. The oscillator can be calibrated initially then a temperature sensor can be utilized to compensate the RC oscillator on the fly. However, that's a lot of trouble to go through just to use the internal oscillator.

    For precise timing, an external crystal or resonator is typcially employed. Crystals are somewhat less sensitive to variation, but resonators are cheaper and usually can provide the required tolerance.

    For PICs, the maximum operating frequency is going to be an absolute limitation. Unlike a micro-processor, PICs are intolerant to over-clocking. For example a PIC with a max clock speed of 40MHz would not run properly with a crystal over 10MHz when using PLL.
     
  6. ajm113

    Thread Starter Member

    Feb 19, 2011
    176
    5
    Thank you all for your swift replies! All very helpful, I had a feeling that was the problem. I don't suppose you all know where I can maybe find a crystal 20mhz for a good deal? Or perhaps a few in a grab bag?
     
    Last edited: Oct 6, 2011
  7. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Crystals are quite cheap. And 20 MHz should be available in hobby stores selling electronics components
     
  8. ajm113

    Thread Starter Member

    Feb 19, 2011
    176
    5
    What hobby stores have you been going to that sell crystals? 0.o I've been to a lot of them in my life and I haven't seen one store that even sells LEDs, but then again that was in Arizona, so idk what the hobby stores are like here.
     
  9. nickelflipper

    Active Member

    Jun 2, 2010
    280
    35
  10. ajm113

    Thread Starter Member

    Feb 19, 2011
    176
    5
    Hey thank you very much! :) I'll defiantly order it sometime next week or so. I kinda started up a second project at the moment.

    I'm playing around to get my PIC to interact with my synthesizer so it has brains. ;)
     
  11. nickelflipper

    Active Member

    Jun 2, 2010
    280
    35
    I have looked at the waitingforfriday site before, it has some interesting projects like the FFT synthesizer. I took a short cut and used the MSGEQ7 chip, for a seven channel analyser.
     
  12. nigelwright7557

    Senior Member

    May 10, 2008
    487
    71
    Your project requires 20MHz crystal with two 15pf capacitors.
    The PIC then PLL's the frequency up to 48MHz.
     
  13. ajm113

    Thread Starter Member

    Feb 19, 2011
    176
    5
    Well after sometime and finally getting back to this thing I have it so it's using a 20 mhz crystal and it's connected ground using 2 22pf capacitors. (I'm not sure if thats a big difference for the chip or not) but I've seen some people using 22 instead of 15 and of course I'm getting the same results. Is it necessarily best to use 15? Or maybe I do have this correct and just to make my life easier I should install a boot loader in this pic?
     
    Last edited: Nov 26, 2011
  14. nigelwright7557

    Senior Member

    May 10, 2008
    487
    71
    You can get 6 for £2 on ebay.
     
  15. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    They can be overclocked to about 10%, roughly the same as PCs, but that 10% isn't much when you are starting with 20MHz. :(
     
  16. ajm113

    Thread Starter Member

    Feb 19, 2011
    176
    5
    Okay so if I'm not overclocking it too much, should I test my PIC with a USB bootloader or something to make sure it's working?

    Any recommendations for bootloaders?
     
  17. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    I'd suggest a PICKit 2 or 3 (PICKit 2 if you aren't going to be using the 16/32 bit or DSP PICs).

    You need to get the bootloader onto the pic somehow anyway, so it's easier just to dump the program on whenever you like using a PICKit
     
  18. ajm113

    Thread Starter Member

    Feb 19, 2011
    176
    5
    Sorry I didn't explain it properly what I'm trying to accomplish. What I mean was are there programs already compiled for the PIC18F that tell the pic to use the USB connection to program it or to manipulate the PIC or to read values on a desktop computer such as Windows.

    Such as turning a pin high or low or reading the state of a button from software running on a desktop computer?

    My first program all I want to do is turn a LED on or off for starters using C++ on Windows.
     
  19. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
  20. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,887
    1,012

    Maybe I don't understand what you are trying to do but.....

    You still need to be able to program the PIC somehow. That can be down two ways that I know of.

    First a programmer such as the PICKit2 or PICKit3 as ThatOneGuy mentioned. And I would only buy a PicKit leaning toward the PICKit3. Don't even waste your time on 3rd party programmers.

    The second method is without a programmer via RS232 and I would assume USB. But this is going to require a special reprogrammed PIC with something called a bootloader. The PICAxe is one type of PIC that will do this.

    There are no C++ compilers for PIC as far as I know. You need to use C. You can also program in assembler, BASIC and there are even a couple of RAD type compilers I have seen.
     
Loading...