4

I am building an ESP32 custom board (project link and full schematics/layout.) I want to add USB to it for programming only.

Power Supply:

enter image description here

USB to serial:
enter image description here

During normal operation, the board will be powered from mains.

When programming the ESP32, I will disconnect the board from mains for safety. The ESP should be powered from USB.

Note: I don't know anybody that make more mistakes-per-day than I do, so I would also like to have some protection against accidentally connecting it to mains and USB at the same time. Since this is not a "supported scenario" the protection does not necessarily mean the board has to work, it could be a blown fuse or something that makes sure that nothing catches fire.

I have read that USB only allows 10 uF capacitors and 100 mA during the first 100 ms (link.) My PCB has more than 200 uF.

I am quite constrained in space, so I am looking for the smallest and safest possible solution to limit the inrush current. For that I was planning to add a series resistor.

I am not sure if this is the best way, and how to calculate the resistor.

I did a simulation (link) and it seems that with a 50 Ω resistor I would get under 100 mA and it would take about 50 ms to reach 5 V.

Is this a correct/the best way of doing this?

enter image description here

JRE
  • 67,678
  • 8
  • 104
  • 179
Carlos Garcia
  • 1,116
  • 1
  • 7
  • 25
  • 1
    F2 makes little sense and may even create a dangerous situation. – Kartman Jan 25 '22 at 12:11
  • Thanks @Kartman. F2 is probably another stackexchange question soon :) - I am not sure how to solve that, since what I am trying to do is to protect the sensing part. My concern is that if it breaks, a lot of things end up at mains potentials. Not sure how to solve it. I wanted to add a fuse per channel, but i have no space for that – Carlos Garcia Jan 25 '22 at 15:49
  • related: https://electronics.stackexchange.com/questions/38361/usb-powered-device-with-multiple-decoupling-capacitors – davidcary May 05 '22 at 17:52

4 Answers4

4

I want to add USB to it for programming only.

I have read that USB only allows 10 uF capacitors and 100 mA during the first 100 ms (link.) My PCB has more than 200 uF.

Then use separate rails with different decoupling capacitors and OR them:

schematic

simulate this circuit – Schematic created using CircuitLab

When you supply the ESP from mains, the 5V rail (input of the linear regulator) will see higher capacitance. When you supply the ESP from USB, the 5V rail will see 4.7uF.

Of course, you should select D1 and D2 according to maximum allowed voltage drop and current consumption requirements/specs.

Rohat Kılıç
  • 26,954
  • 3
  • 25
  • 67
  • The problem is that C3 is the larger capacitor. I could make it smaller, maybe 10uF, but the sum will still be more than 10uF limit. Here the datasheet: https://www.st.com/resource/en/datasheet/cd00002116.pdf – Carlos Garcia Jan 25 '22 at 15:57
  • @CarlosGarcia if you really worry about the capacitive load then use a separate regulator. The idea is the same as above. Plus, for any linear regulator, you don't always have to use large output cap as it may lead to instability. – Rohat Kılıç Jan 25 '22 at 16:47
  • I don't have anough space for a second linear regulator. In the other hand the 3.3v are used only for the ESP32 and one or two sensors, so smaller caps could do the job. I read somewhere that bigger was better, but maybe I can get alone with a 4.7uF one – Carlos Garcia Jan 25 '22 at 18:31
  • 1
    @CarlosGarcia `I read somewhere that bigger was better` not always. There are countless regulators that go unstable with high output capacitor. Anyway, always stick to what the datasheet recommends. – Rohat Kılıç Jan 25 '22 at 20:31
1

Though USB 2.0 restricts decoupling capacitance and current, it still works fine with bigger capacitances.

  • I tried to use up to 47-470uF capacitors in many prototypes, and it worked with all USB2.0 and USB 3.0/3.1 ports well.
  • If you really want to limit the maximum current to 100mA, 50ohm is enough. $$ V_C = V_{BUS} \times e^{- \tau / RC} $$ $$ V_R = V_{BUS} \times ( 1 - e^{- \tau / RC} ) $$ $$ I_{MAX} = V_{BUS} / R $$ $$ R = \frac{V_{BUS}}{I_{MAX}} = \frac{5V}{1000mA} = 5 \Omega $$
  • A better solution is to use an inductor instead of resistor.
  • Note that the standard USB 2.0 max Vbus current is 500mA, so the resistor value can be 10ohm with the above calculation.

Here I attach a schematics with 200uF capacitor. The prototype worked fine.

enter image description here

enter image description here

JRE
  • 67,678
  • 8
  • 104
  • 179
1

When a large capacitor is used at the input and and it is possible to connect the device while the power is ON, an inrush current limiter is an easy solution. In your case with USB, 50 ohm is sufficient at start up.

If the current in your application won't exceed 2A, an NTC in series with the input will just do that, 50 ohm when cold, 0.7 ohm when hot. One of the devices that meet those requirement and would comply with the USB specification is the P/N: N10SP050M from Yageo.

JRE
  • 67,678
  • 8
  • 104
  • 179
Louis
  • 114
  • 6
1

As stated in previous answers, you can try with initial diagram, or you can simply reduce capacitor to fit specifications. Proposed NTC inrush limiter will not work well in 5 V. To reduce resistance value down to 0.723 Ohm, temperature has to reach 170ºC, and that will happen only if current is 2 A. In datasheet V-I characteristics curves, you can see voltage drop for a stable current. From 0 to 30 mA, it will be like a constant resistor of 50 Ohm. From 50 mA to 900 mA, voltage drop will be > 2 V, that could be issue for the PSU. Anyhow, if you get 2 A, voltage drop will be about 1.5 V. enter image description here A FET based inrush limiter will have a very low drop after some delay. See example diagram, not very fine arragement, but simple for space issues. D1 is to discharge C2 through R1 to quickly prepare for next inrush; D2 is to reduce the delay to activate M1. I used 44 Ohm load as suggests your link. enter image description here enter image description here

Bravale
  • 1,237
  • 4
  • 7
  • Thanks a lot @Bravale! I think I don't have enough space to place all that circuit :S... but thanks so much for explaining it! – Carlos Garcia Jan 28 '22 at 18:41