I am trying build a prototype similar to that of Dave's uSupply. But instead of High Power I will be using it to power Breadboard Circuits. Currently the limitation is that I only have the 10W of a USB-A port. The reason to go with this instead of type C -PD is that, I would take it to my university where they have those very old Dell Workstations which I probably think would only have USB 2.0 or USB 3.0. However I am not only planning to have a power supply but also a inbuilt current meter (INA219 as the sensor but it wont work with separate grounds) and a few GPIOs.
USB 2.0 is limited to 500mA = 0.5A at 4.5V–5.5V, or about 2.5W.
If you don't mind being limited to Chrome, Chromium, Edge, and Opera browsers, you could use
WebUSB. All it requires is that your microcontroller has native USB, and not a USB-Serial bridge like FTDI chips as used on most Arduinos.
Some microcontrollers, like dirt-cheap
WCH CH32X035 RISC-V MCU, do have USB-C PD support, so you could make a device capable of USB-C, falling back to USB 2.0. You could also use an ADuM3160 USB isolator, and one or more isolated DC-DC converters, to isolate the microcontroller from the computer and any supplies. One possibility would be to use multiple power-only USB A connectors, via isolated DC-DC converters, to exceed the 2.5W power limit of one port. (Then, if you have access to mains, you could use an USB wall wart to provide an additional typical 2.1A maximum, for the 10W power budget. The trick is to keep track of the grounds, and not assume the wall warts' GND/0V is at the same potential as the computer/USB GND is.)
Metering is simple, since you basically only need an instrumentation amplifier and a suitable shunt resistor, and an ADC input. INA219 integrates all of these, providing an I²C interface. For power control, use a high-side switch: P-channel high-side MOSFET with gate pulled to supply via a high-value resistor, say 100k, and a logic-level MOSFET like BSS138 or NX138AKR to pull the gate to ground to enable the switch, its own gate connected to an I/O pin via a suitable peak current limiting resistor, say 1kΩ (or maybe 220Ω if you want to do PWM up to 100kHz or so).
The interesting part is the filtering and noise reduction of the supplies. USB can be surprisingly noisy. (My own laptop audio circuits' bypass capacitors have aged so badly, that in a very quiet room I can now
hear whenever my touch registers on the touchpads, as the related USB data transfers cause a regular
ticking or droning sound.) Dave has a nice video about capacitance multipliers; that and CLC filter should do very well, if you use low-noise linear regulators for each of the output voltages. Note that you can then put the current measurement
before the regulator.
The power supply side of things is just 3 Individual channels (Non - Isolated) wont be a fully variable but instead have common preset voltages such as Ex. 1.8V, 3V3, 5V, 9V and 12V.
You could use an adjustable linear regulator, and a DAC to adjust the precise voltage. You can find many interesting threads here if you use the Search (keywords:
DAC "linear regulator")
Currently I have a ESP32-WROOM 32D with 4MB Flash. The Idea of having a webpage is very good but there's a problem, I'll be using it in my Uni where they don't have WiFi Cards in their workstations.
WiFi? No, I meant you program the ESP32 to look like an USB WiFi dongle, except that it provides only a simple IPv4 stack. No WiFi needed.
However, with a cheap USB WiFi dongle you could power the ESP32 from an USB wall wart, or better yet something like a laptop 19V supply (these tend to be properly grounded) with ample current. The ESP32 would not be directly connected to any computer at all – which kinda-sorta also reduces your liability if you're anything like I am, a butterfinger who occasionally shorts things that do not like to be shorted.
For ESP32, take a look at
EspressIf ESP-IDF Programming Guide, and especially their
esp-protocols GitHub repository, which includes even a WebSocket example (if you decide to go with an externally powered ESP32, and an USB WiFi dongle to connect to it from any computer).
The ESP32 Wroom32D does not have USB support, so cannot support RNDIS/NCM/etc., and even WebUSB support will be, uh, questionable. (I'm not sure if WebUSB allows connection to an USB serial port.) The dev boards use an USB to serial bridge, so their USB connection is not native and will always look like a serial port to any host OS.
I warmly recommend you don't take too large bites at once. Advance step by step.
Even when writing code, that applies: make local changes, then recompile, check, test, and don't add any new code until everything you've written thus far works.
Never, ever leave error checking for later. Document things as you go. Even a plain text file is okay; it doesn't need to be pretty. You will not remember any of the details half a year later, so writing them down is paramount for anything complex.
What I'd do, is connect a couple of the GPIO pins of your Wroom32D module to LED cathodes, and their anodes to current-limiting resistors (say, 1k, 2.2k, 4.7k) connected to +3.3V or +5V supply. Then, get a cheap USB WiFi dongle –– my local store has a dozen different models to choose from in the below 15€ price range. Next, create a simple firmware for the Wroom32D to blink those LEDs, and make sure it works, when the Wroom32D is powered from a wall wart, and is not connected to any computer. After that, start looking at the EspressIf documentation, to implement a single-file web server and a WebSocket server. Create a simple page that allows you to click buttons to turn each LED on and off. I would also add a button to the Wroom32D (pulling a GPIO input pin to ground when pressed), so that you work out how to ensure interesting happenings on the Wroom32D cause stuff to happen on the page using WebSockets. Use WebSockets properly, with each end able to send events/messages at any point, instead of the web page actively polling for events: that polling generates LOTS of extra traffic, and just slows EVERYTHING down.
When you get that working, that alone is something you can add to your portfolio/CV: it is very worthwhile experience in IoT land.
Only after you get that working, should you advance towards controlling a complex power supply. Of course, you can –– and I definitely would –– develop the adjustable supply circuits in parallel, at the same time, but in a completely separate isolated project!
I personally test everything I'm interested in separately, before attempting to combine them. That way, I can work in units I can completely understand, document,
and test. The integration of the various parts is the final step, and at that point, I already know (have verified!) that the individual parts work. (I archive these tests, each one in their own directory, with a README file, any related documentation, some test cases, and the source code. I've got
thousands of these by now. Some say I'm wasting my time; I love it, because not only do I have actual experience with some quite esoteric stuff, but it also helps me hone my problem-solving and design skills.) Pure win-win, in my opinion.