Vusb capacitor for USB comms with 18f2550


Closed Thread
Results 1 to 13 of 13
  1. #1
    Join Date
    Sep 2007
    Posts
    26

    Default Vusb capacitor for USB comms with 18f2550

    Hi guys,

    I have an intermittent problem with USB comms. I had it working, then it broke for no reason (no code changes) and the Pic drops off the bus at will and then may or may not reappear. When it fails to come on or drops off, the light on my USB hub also is not on. When it is working the light is on.

    I just noticed that if I touch Pic pins (seems like any) and the Vusb cap with the same hand the device comes back on the bus. I have used this circuit for so many things I am sure MCLR etc are all good. Apart from USB it is reliable. I am using a yellow rectagular 470nj 63 cap. I am not sure what type it is or if it is the right type. I replaced it just in case it might be faulty but to no avail.

    I tried replacing it with a 270nj, a 390nj and also parallelling the 470 with a 270 and then a 390 to see if it needed to go smaller or larger. I can only think it is the size. I have 25pfs on my 20Mhz crystal as I didn't have any 22pf. I also DON'T have a 1m resistor between crystal pins as I saw in the EasyHID schematic.

    I'm using EasyHID code by the way.

    Any ideas anyone.

    Thanks again

    Rich
    PS. I'm learning a lot very quickly, I might even be able to help YOU soon!

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    It could be few things here. If you have any, use 10-15 pF instead. If your setup is on a breadboard, you may try to remove those capacitor around your crystal and see what happen.

    All wires, leads in the crystal/cap section have to be as short as possible. If you have any picture of your current setup, just post them here.

    Few other things,
    1. LVP fuse must be set to OFF
    2. 0.1uF Capacitor + 10-47uF capacitor have to be installed as close as possible of your PIC Vdd & Vss rails
    3. make sure there's no loose connection
    4. make sure the Vdd rail is neat.
    HTH
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Sep 2007
    Posts
    26


    Did you find this post helpful? Yes | No

    Default

    Hi Steve,

    I tried everything and all I have achieved is no USB connectivity at all now. Could it be that the osc really requires exactly 22pf. I have got a 15 and a 10 in parallel on both sides. of osc. It's pretty tidy and the leads on caps are not more than 10mm. The osc leads are shorter still. I can't get any 22pf caps for a few days as I live on a boat in the middle of nowhere!

    Is it possible to configure to use internal osc to drive USB at full speed. My understanding from datasheet is that it isn't but hey, I am only learning this stuff so might be wrong.

    It's a real shame I can't get it going anymore as I was making great progress on code whilst the Pic was on the USB bus!

    The whole circuit is on a proto board. It is getting a bit full with 2 Pics, an FPU, Max232 and associated wiring. When you said a tidy Vcc rail I might have crossed that boundary. With all the changes I have made to the board so far it might be getting a bit messy. I can't take a picture as I don't have a camera with me.

    I guess if I can't configure it to use internal osc as a test, I will probably have to go back to basics and breadboard it till I prove the details.

    If you have an opinion on using internal oscillator I would love to know otherwise I think it is down to the breadboard approach.

    Thanks mate

    Rich

  4. #4
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Hi Rich,

    You can use the internal oscillator for pretty much everything except the USB
    peripheral. This requires XT, HS or EC type external crystals/oscillators.

    If you have a breadboard, I would drop the USB PIC on it, and wire up the minimum parts
    needed to get a USB connection up & going. If it works, then you have it narrowed down
    to a problem on the other board.

    Also, if you had USB working before, and it stopped working after you added a few other
    components to the board, you might try removing some of the other ICs to see if it starts
    working again.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  5. #5
    Join Date
    Sep 2007
    Posts
    26


    Did you find this post helpful? Yes | No

    Default

    Thanks Bruce,

    It was working but intermittently. I have just made it worse (doesn't work at all!) by removing and refitting crystal and caps.

    I will do breadboard I think. I have a low profile metal case 20mhz crystal. Do you have an opinion on cap value? Is it better to go higher or lower if I don't have correct values with me. Also, is it necessary to ground the case of the crystal? Also, EasyHID schematic has a 1m resistor in between OSC1 and OSC2. Do you know if this is a good idea?

    Cheers

    Rich

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Some Crystal may need that resistor, somes not. Maybe yours need it. Look at the datashet for capacitor range. It's not as this critical... but sometime the breadboard may add much capacitance than you might think. Hence why it may work erratic.

    Loose contact... pain to find sometimes. It remind me a broken pin under a DIP socket
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7
    Join Date
    Sep 2007
    Posts
    26


    Did you find this post helpful? Yes | No

    Default

    Thanks again Steve,

    The only reference to capacitance on the tiny datasheet for the crystal says:

    Load Capacitance: 32pf
    Shunt Capacitance: 7pf maximum

    What does that mean!

    Like I said on some other thread I started, the amount I am learning on this project, I will be able to answer questions myself soon! It's amazing how much you can learn at 18 hours a day!

    Cheers

    Rich

  8. #8
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    I would suggest you try a SerialCommunication test, let's say @19200 bauds, then 115200 baud. If this work, then look at the USB code.

    Refer to table 2-2, they recommend 15 pF. But yeah... depending the precision of your capacitor 22pF might be too high. If you have any scope handy, use a 10X probe and looks at OSC2 pin.

    4MHz work also just fine.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  9. #9
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Hi Rich,

    I will do breadboard I think. I have a low profile metal case 20mhz crystal. Do you have an opinion on cap value?
    22pF has worked for me for years with just about every frequency crystal I've ever used with
    a PIC. Never had a single oscillator problem yet (knock on wood)..;o}

    Is it better to go higher or lower if I don't have correct values with me.
    On average higher is better, but it does increase the oscillator start-up time. I would err
    on the side of whatever I had that was closest to the mfg recommended cap value.

    Also, is it necessary to ground the case of the crystal?
    No.

    Also, EasyHID schematic has a 1m resistor in between OSC1 and OSC2. Do you know if this is a good idea?
    That totally depends on the crystal you have. I rarely add this resistor, but I've been using
    the same crystals with PICs for a LONG time. Digi-Key part #X439 for 20MHz.

    On the same board, with the same crystal setup, how does it run with things like serial
    communications between your PC, blinking a few LEDs, etc?
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  10. #10
    Join Date
    Sep 2007
    Posts
    26


    Did you find this post helpful? Yes | No

    Default

    Thanks for all that. I decided just prior to breadboard I would try something else.

    I had timed a 30 second pause (LED on then off) to make sure the osc wasn't completely out. It was as near as 30 seconds as I could detect. I was also using the EUSART at 9600 successfully for debugging.

    I should have done the crystal / cap serial test first but didn't get Steve's post in time. I had a 16mhz resonator lying there so I put that in instead as it shouldn't need caps right? First I changed the prescaler to /4 to still get 48mhz for USB. Then I timed a 60 second pause and sure enough, all good. So I tried Steves suggestion of serial test. It gives garbage on all bauds and yes, I am using PicMultiCalc (wonderful tool Steve!) so I know the settings are correct.

    I do at least get Device Not Recognised. I wasn't even getting that sometimes with 20mhz setup. Arhhhh. It sucks of a dodgy connection to me but the holder is new and I checked / resoldered them all. The board has too many wires under it so it could still be a stuff up somewhere.

    Only one question out of this I suppose. Are resonators less accurate than crystal/ cap combos. Does 60 second pause test validate clock accuracy to any degree at all? OK, that's 2 questions!

    Off to the breadboard. I will see if I can do it tonight (1.30AM already) as I am desperate to know!

    Oh and one final point. When the code works it works great. I also tried the MOUSETEST.BAS and that works when it works but doesn't when it doesn't. Says it's not a code issue to me for what my opinion is worth!

    Cheers guys

    Rich

  11. #11
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    To me serial test, Timer AND/OR PWM test is a nice start point to check a crystal accuracy, so configuration fuses setting too. PAUSE is not a safe test to me. OK OK, let's say your PAUSE 1000 take twice or half the time... you obviously see something is bad. But 1/4,1/10,1/100 second off on a 10 second delay... is hard to see. Serial comm on a high baudrate such as 115200 baud, would be a nice reference, even 19200 is still not bad.

    Ceramic resonator are nice, but might shift with temperature, less than the internal OSC that's for sure, but not as accurate as Crystal. Some resonator have built-in cap, some not.

    Good pcb, usb connector/cable debugging
    Last edited by mister_e; - 3rd October 2007 at 18:26.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  12. #12
    Join Date
    Sep 2007
    Posts
    26


    Did you find this post helpful? Yes | No

    Default

    OK you guys,

    I am a very very happy man!! I can teach you something now. I doubt you will ever need to know it as you are probably not as careless as me but just in case you are as tired as me one day and stuff up!!

    I built the circuit on breadboard with ICSP, LEDs, MAX232, USB and all the bits necessary to debug. I copied the wiring for the USB connections from the prototype board. Guess what, it didn't work. I used the luxury of breadboarding to swap cap values and crystals etc but all to no avail.

    I decided I had to check my breadboard wiring. I got the EasyHID schematic out and checked the breadboard and then had to check the proto board to see if it could be true. Here comes the lesson:

    If you get D+ and D- the wrong way round it might work sometimes!!!!

    I definitely don't recommend it as it took me 3 days (incredibly long ones as well!!) to find it. If it weren't intermittent it would have been so much easier. I used to be a TV engineer 25 years ago and this whole thing takes me back a long way. Intermittent faults are a nightmare!

    I just want to thank you guys for holding my hand through this trauma and I just want to add:

    "There's no problem. Only learning opportunities"

    Now where have I heard that before. I'm elated with how much I have learned!

    The other person I would like to quote is Alain, AKA Altronics. "If there is the word Problem in the question, the answer is almost certainly RTFM". He is so right but I need one piece of info to make him right for me..... Does anyone know of any good books on how to understand a Microchip Datasheet? PBP books just don't cut it.

    Cheers a very lot, back to the wonderful world of coding!

    Rich

  13. #13
    tromop's Avatar
    tromop Guest


    Did you find this post helpful? Yes | No

    Default Vusb problems

    I had the same type of problems with a 18F2550. Sometimes it functioned, sometimes it didn't!
    After searching and reading the 18F2550 manual i found the chapter
    "17.2.2.4 External Pull-up Resistors
    External pull-up may also be used. The VUSB pin may be
    used to pull up D+ or D-. The pull-up resistor must be
    1.5 kΩ (±5%) as required by the USB specifications.
    Figure 17-3 shows an example." and soldered both the resistor and C and happiness it functions. The pullup resistor for D+ to Vusb (1.5K) did the job for me.

    Best regards,
    Onno Tromop

Similar Threads

  1. i cant get 18f2550 work as HID
    By Ahmadabuomar in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 13th October 2009, 16:39
  2. 18F2550 timing
    By sstt1976 in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 22nd August 2008, 00:30
  3. 18f2550 + 24lc512
    By mpardinho in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 20th December 2007, 22:02
  4. DS1820 and 18f2550
    By rjones2102 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 2nd October 2007, 18:11
  5. 18F4550 to 18F2550
    By mpardinho in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th September 2007, 23:13

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts