• AVR Freaks

Is there any way to detect USB pluggin?

Author
ras123
Super Member
  • Total Posts : 261
  • Reward points : 0
  • Joined: 2005/07/28 07:33:36
  • Status: offline
2009/04/24 19:41:09 (permalink)
0

Is there any way to detect USB pluggin?

Hi,
Can I detect a USB plug in without using a I/O line? I need to reduce power consumption for a PIC18F2550 project, by disabling the USB if not connected.

Also please let me know, which OSC mode will reduce power consumption:-
1. 4MHz crystal with a PLL prescaler 1:1 (XTPLL)
2. 20MHz crystal with a PLL prescaler 1:5 (HSPLL)
post edited by ras123 - 2009/04/24 23:08:46
#1

7 Replies Related Threads

    RISC
    Super Member
    • Total Posts : 5591
    • Reward points : 0
    • Status: offline
    RE: Is there any way to detect USB pluggin? 2009/04/25 02:27:53 (permalink)
    0
    Hi,

    Can you better explain your power supply system ?
    Is it :
    a/ self powered
    b/ powered BOTH by USB (while connected) and self powered ?

    Regarding power consumption, I think it does not have any influence whether you use PLL or not (assuming of course similar Fcy) as far as the datasheet electrical data are concerned BUT you should consider the following tips :
    a/ the fastest restart from sleep mode is done using internal RC oscillator
    b/ the slowest start/restart is the PLL configuration because you must consider the PLL lock time
    c/ the best solution (when possible) is to actually restart from internal RC and then switch over to the main XTAL oscillator (if necessary) by checking the bit which tells you that the main oscillator is stable. Doing this you can optimize your power budget

    Another tip is to run the main clock as low as possible (depends upon your application). The USB and the CPU clock can be programmed separately using the prescalers which gives a lot of possibilities on this micro.

    Can you also explain which Fosc / Fcy you're using ?

    I see no possibility other than using an I/O to detect connection/disconnection if you are self powered...

    regards
    post edited by RISC - 2009/04/25 02:29:03
    #2
    TimBox
    Junior Member
    • Total Posts : 98
    • Reward points : 0
    • Joined: 2003/11/07 12:48:15
    • Status: offline
    RE: Is there any way to detect USB pluggin? 2009/04/26 02:25:44 (permalink)
    0

    If your detecting a connection on power up then you can wire in a pull up of say 150k to the D+ line. The do  level check on the D+ pic line

    If its low then your connected if its high then your not. It all depends of cause if you can make an D+ a digital input




    #3
    ras123
    Super Member
    • Total Posts : 261
    • Reward points : 0
    • Joined: 2005/07/28 07:33:36
    • Status: offline
    RE: Is there any way to detect USB pluggin? 2009/04/26 03:43:49 (permalink)
    0
    Hi,
    My system is both bus powered and self powered.

    Since I need to run USB, I always need a 96MHz clock for USB modules. But I can run the CPU as low as 8MHz(or 4MHz). I already think an option to use internal RC osc for CPU and other peripherals and PLL for USB. But I thought it may increase the power consumption.

    ORIGINAL: TimBox

    If your detecting a connection on power up then you can wire in a pull up of say 150k to the D+ line. The do  level check on the D+ pic line

    If its low then your connected if its high then your not. It all depends of cause if you can make an D+ a digital input


    I will try this option, I hope this will not violate USB specs
    #4
    Kiwi Mike AZ
    Super Member
    • Total Posts : 2056
    • Reward points : 0
    • Status: offline
    RE: Is there any way to detect USB pluggin? 2009/04/26 08:15:55 (permalink)
    0

    Still the best way is to use the 5V from the USB cable to detect if you are connected or not.
    You can isolate from your power supply by using a FET, Diode or other scheme, and having a pull down resistor on this pin is recommended  to ensure you get a 0V when the cable is not plugged in (e.g 100K)

    Detecting this line on a digital input allows you to power up the USB section only when you actually need to.

    Also, in hte future, if you are using a PIC24 or PIC32 with USB this is a special pin and actually powers up part of the internal circuitry so is required to make the USB work.

    Playing with pull ups etc on the D+/D- line is NOT recommended.

    Mike
    #5
    TimBox
    Junior Member
    • Total Posts : 98
    • Reward points : 0
    • Joined: 2003/11/07 12:48:15
    • Status: offline
    RE: Is there any way to detect USB pluggin? 2009/04/26 10:03:50 (permalink)
    0
    Playing with pull ups etc on the D+/D- line is NOT recommended.


    So you want to take Microchip to task!!!!!

    It standard on the low pin count USB board

    Or you know better than them?


    #6
    Kiwi Mike AZ
    Super Member
    • Total Posts : 2056
    • Reward points : 0
    • Status: offline
    RE: Is there any way to detect USB pluggin? 2009/04/26 19:24:23 (permalink)
    0

    Yes...
    Figure 22-1 of the Data sheet Does show "OPTIONAL EXTERNAL PULL UPS" to indicate is Low speed or Full Speed.

    Normally with Microchip Parts you do this internally so you can control it using the SIE.

    But if you start messing with the D+ and D- lines without KNOWING EXACTLY WHAT YOU ARE DOING then you are in for trouble.

    #7
    chinzei
    Super Member
    • Total Posts : 2250
    • Reward points : 0
    • Joined: 2003/11/07 12:39:02
    • Location: Tokyo, Japan
    • Status: offline
    RE: Is there any way to detect USB pluggin? 2009/04/27 01:19:29 (permalink)
    0
    TimBox:

    It standard on the low pin count USB board

    Microchip has made many wrong designs around USB, not only its USB engine design. This is another wrong one.

    a) The extra pull-up for D+/D- line may be able to detect plug-in of USB connector. But the detection of unplug is unreliable.

    b) By USB spec, self-powered device should not apply voltage to D+/D- line, unless USB VBUS is supplied by the host.

    For example, this Apple Technote describes about a trouble caused by current inflow from D+ line pull-up of self-powered external devices.

    "SDRAM Problems With Self-Powered USB Devices" by Apple
    http://developer.apple.com/qa/hw/hw82.html

    Tsuneo
    #8
    Jump to:
    © 2020 APG vNext Commercial Version 4.5