A board with two USB ports

73 views
Skip to first unread message

Gavin

unread,
Jun 1, 2021, 10:06:54 AM6/1/21
to reading-...@googlegroups.com
Hi

I am designing a board with two USB ports. One will be used for programming the microcontroller on the board, the other will be a USB C power connector, with resistors added so that it can draw 3A from a supply.

When a laptop is connected to the programming port, it will power just the MCU via a regulator. I am going to put a diode in place to prevent the mass of LEDs (powered via the USB C port), which will be controlled by the MCU, from trying to draw current from the laptop’s USB port as the load will be too high.

When a power supply is connected to USB C port, it will power the LEDs and the MCU via the regulator - this will be possible because the diode will only let the current through in one direction, right?

However, another scenario has just struck me - what happens when both are connected? The 5V net feeding the MCU’s regulator will have power from both USB ports - is this ok? Might there be a ground loop problem?

Gavin

Jeremy Poulter

unread,
Jun 1, 2021, 10:16:21 AM6/1/21
to rLab List
Look at the circuits on the Feather boards, they use a MOSFET to give priority to the USB port rather than the battery, you could do something similar for the two USB ports.

That being said why not just use the same port for programming and power? Or are you expecting both to be connected normally?

Jeremy

--
You received this message because you are subscribed to the Google Groups "rLab / Reading's Hackspace" group.
To unsubscribe from this group and stop receiving emails from it, send an email to reading-hacksp...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/reading-hackspace/C20BDE91-F07F-4BDC-BEF1-3A3D17395DA9%40gmail.com.

Gavin

unread,
Jun 1, 2021, 10:24:24 AM6/1/21
to reading-...@googlegroups.com
Thanks Jeremy. I am drawing much of the MCU circuit design from the ESP32 feather schematic. When you say MOSFET, are you referring to the DMG3415U part in the Power and Filtering part of the schematic? If I reproduced this with the pin that is currently connected to VBAT in the Adafruit schematic connected to the USB C power line, then if both were present, would the MOSFET choose the programming port (VBUS) in preference?



The reason I am thinking two ports is that if the MCU gets programmed in a way that all immediately light up a load of the LEDs, then as soon as I connect it to the laptop for programming it will draw too much current and blow the fuse on the laptop’s USB port. So I wanted to design it so that the laptop will never be powering more than the MCU

Gavin

Nigel Worsley

unread,
Jun 1, 2021, 10:41:00 AM6/1/21
to reading-hackspace
The MOSFET in the battery line is to prevent the battery from being connected to the USB power and thus being overcharged, R12 makes sure that it is turned on when the USB port is disconnected.

Having two sources of power should be fine, as long as at least one of those is floating WRT earth (and laptop supplies are always floating). If they aren't then some of the LED return current will flow through the USB cable and back to the main power supply via the computer and mains earth, which could be a bad thing if the current gets high enough. Many years ago I had the outer braid of a serial cable fuse because an idiot had got the live and neutral connections the wrong way round in the plug of the peripheral device, creating an earth to neutral short via the computer!

Nigle

Richard Ibbotson

unread,
Jun 1, 2021, 10:59:07 AM6/1/21
to reading-...@googlegroups.com
My thoughts would be to use the diode plus MOSFET circuit to allow either supply to power the processor and any associated low power stuff. The USB supply via the diode will take priority. The components are not rated for 3A, so I would add a separate 3A regulator (switching ?) for the LEDs powered by the 3A power supply alone. This avoids beefing up the MOSFET. Note that in this configuration the P channel MOSFET is actually swapped drain and source which works fine due to symmetry and the body diode faces the right direction.
Richard


Sent via Richard's Phone

On 1 Jun 2021, at 15:41, 'Nigel Worsley' via rLab / Reading's Hackspace <reading-...@googlegroups.com> wrote:


The MOSFET in the battery line is to prevent the battery from being connected to the USB power and thus being overcharged, R12 makes sure that it is turned on when the USB port is disconnected.

Having two sources of power should be fine, as long as at least one of those is floating WRT earth (and laptop supplies are always floating). If they aren't then some of the LED return current will flow through the USB cable and back to the main power supply via the computer and mains earth, which could be a bad thing if the current gets high enough. Many years ago I had the outer braid of a serial cable fuse because an idiot had got the live and neutral connections the wrong way round in the plug of the peripheral device, creating an earth to neutral short via the computer!

Nigle

--
You received this message because you are subscribed to the Google Groups "rLab / Reading's Hackspace" group.
To unsubscribe from this group and stop receiving emails from it, send an email to reading-hacksp...@googlegroups.com.

Gavin

unread,
Jun 1, 2021, 1:13:15 PM6/1/21
to reading-...@googlegroups.com
Thanks all

Richard - This might be the way I described the issue, so apologies if I have caused confusion.

I am thinking of the circuit as being in two parts, divided by the MOSFET and diode.

On the MCU side, there is:
- A 3v3 MCU
- an AP2112K-3.3 regulator, drawing from either a micro USB port connected to a computer, or a USB C port supplying higher current (on the other side)
- A CP2104 to handle serial communications for the MCU via the micro USB port
- some level shifters connected to GPIOs on the MCU as the display driving chips that they are connected to on the other side of the circuit have 5v logic

On the ‘blinking' side, there is:
- a USB C port with the CC1 and CC2 pulled low with 5k1 resistors to enable up to 3A supply
- some MAX7219 display drivers connected to many LEDs - this is the bit that is potentially ‘high' current
Essentially I am relying on the USB supply to regulate to 5v….


Given that, does it matter if the MOSFET and diode, and parts on the MCU side, are not rated to 3A as the parts on the MCU side are never going to draw that much current through the MOSFET and diode? Or are you thinking that I should add a 5v 3A regulator on the blinking side to guard against the wrong voltage being delivered via the USB C port?

Gavin

Gavin

unread,
Jun 1, 2021, 1:51:33 PM6/1/21
to reading-...@googlegroups.com
Here’s the current schematic:

Richard Ibbotson

unread,
Jun 1, 2021, 1:52:43 PM6/1/21
to reading-...@googlegroups.com
If the high current devices are driven direct from the high current supply and the low current devices are driven from an or-ing of the two supplies then you are OK. The use of a MOSFET as an ideal diode is to give a low voltage drop from the battery. Since you have two good 5V supplies you could just use two diodes for the or-ing instead of diode plus MOSFET. The or-ing will just select the highest voltage for the low current part. High current part will only operate with high current supply.
Richard

Richard
Sent via Richard's Phone

> On 1 Jun 2021, at 18:13, Gavin <gavi...@gmail.com> wrote:
>
> Thanks all
> --
> You received this message because you are subscribed to the Google Groups "rLab / Reading's Hackspace" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to reading-hacksp...@googlegroups.com.
> To view this discussion on the web, visit https://groups.google.com/d/msgid/reading-hackspace/6EBC2AF8-A56D-4C39-92E7-0848B3F56C0B%40gmail.com.

Gavin

unread,
Jun 1, 2021, 4:53:58 PM6/1/21
to reading-...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages