Xmega -- How to detect USB

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A design is going onto paper, with an Xmega384-C3.  It will not be USB powered as the Xplained is, so we didn't get any hints there.

 

The question is what is the usual/best way to sense USB plugged in or not?  Simply circuitry from the USB 5V pin, dropped down to the Xmega Vcc level, and then into a port pin with a weak pulldown?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Simplest would be 2 resistors as a voltage divider from the USB 5V.

Add a skottky diode to the AVR power supply if you want to retain the ability to power from the USB bus.

 

Or you can even do it with less hardware.

Put the Skottky in the GND to the USB bus.

Connect the GND of the USB bus to an Input pin with internal pullup.

 

If you do not want to tolerate the voltage drop over the Skottky, you can replace it with a small MOSfet.

This should give you some ideas:

https://duckduckgo.com/html?q=schematic+mosfet+reverse+polarity+protection

Paul van der Hoeven.
Bunch of old projects with AVR's:
http://www.hoevendesign.com

Last Edited: Fri. Jun 1, 2018 - 01:55 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just to clarify:  Just run the detect to any old Xmega port pin?  The USB doesn't have any specific "USB power detect" or similar?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes.  Use any pin.  There is no specific pin.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A bit trickier may be the USB ground wire connection.  My Xmega is powered by USB only.  I have 2 grounds between my Xmega and my PC.  I connect the USB ground directly to my board ground.  I connect my RS232 ground through a 1000 ohm resistor bypassed by a 1 uF cap.  

 

I won't even mention the USB cable shield.  Well okay, I think everyone agrees it shouldn't be connected directly to the AVR board.  Not connecting it to anything works for me.  

Last Edited: Fri. Jun 1, 2018 - 07:40 PM