USB connector for serial communication ?

Started by Uncle Buzz, December 05, 2018, 10:29:18 AM

Uncle Buzz

Hi,
I want to use a µUSB connector to supply power to recharge a battery on a node, but without including an USB to serial converter IC like those from FTDI. But I would like to use an external USB to serial converter without exposing another connector for programming or debugging, so I would like to use the µUSB connector to connect TX and RX pin of an ATMEGA328P or 1284P.

I wonder what will happen to the ATMEGA if someone plugs a real USB to this connector, TX and RX pin will be connected to D+ and D- of USB... What if my node is unpowered and there're some 5V signals on TX and RX pins ? What if my node has some periphericals like the radio RFM69 running at 3.6V max if there're some 5V signals on TX and RX pins ?

Are 2 P-mosfets acting as a shift leveler sufficient to protect the ATMEGA and other parts?

Felix

That's quite creative and unconventional, but I think it should work with a few precautions.
Worst case is of course someone plugging real USB into it.

If the TX is an OUTPUT, and D+/- tries to also output into it, there will be current drain problems - so I would add a resistor there at the least to limit any damage to either side. Also since I havent tried or over analyzed this, take it with a grain of salt.

So the TX/RX would get 5V, so at the very least you'd need logic level conversion to bring that down to the AVR's VDD level. Hence if USB does meet serial TX/RX, there is no damage to the AVR.
I think 2 mosfets should do the job as you mentioned, but I would put this on paper and see if ohms law raises any red flags based on the possible scenarios.

Uncle Buzz

I was thinking about Perky's link on the thread about the leakage current inside the FTDI in the off state: https://www.nxp.com/docs/en/application-note/AN10441.pdf
It's not with P-channel mosfet as I said but with N-channel.
If I'm not mistaken, it would protect against USB 5V in all possible cases, right?

Felix

Quote from: Uncle Buzz on December 05, 2018, 10:29:18 AM
Are 2 P-mosfets acting as a shift leveler sufficient to protect the ATMEGA and other parts?
I thought you wanted to do voltage level shifting?

Uncle Buzz

Not really, level shifting is not the main goal, I just want to use an external FTDI but using the µUSB connector instead of some dedicated pins.
But, since it's a µUSB connector, it's quite certain than a real USB will be plugged at a moment, so I want to be protected against this scenario. So I need to block 5V signals on D+ and D- from a real USB connection to go through my ATMEGA and burns some components.
The link posted by Perky is about level shifting by using a Nchannel mosfet, and to my mind it's sufficient to protect my node :

  • in the case where my node is powered up, it's running at 3-3V3, so a level shifter between low voltage of my node and high voltage of USB is what I need
  • in case where my node is powered down, it's "running" at 0V, if the level shifter is able to avoid low voltage to be more than 0V, my node will be protected
So level shifting is not what I need, but if it works as low than 0V on one side, it's sufficient, and level shifting could be useful with a 5V FTDI.
Nchannel mosfet used like the NXP's note acts as a level shifter, and works even with 0V.
If anyone sees anything wrong with this solution, please show me where I'm wrong!