USB-C For Hackers: Build Your Own PSU

What if you wanted to build your own USB-C PSU? Good news – it’s easy enough! If you ever wanted to retrofit a decent DC PSU of yours to the USB-C standard, say, you got a Lenovo/HP/Dell 19V-20V charger brick and you’ve ever wished it were USB-C, today is the day when we do exactly that. To be fair, we will cheat a bit – but only a tiny bit, we won’t be deviating too much from the specification! And, to begin with, I’ll show you some exceptionally easy ways that you can turn your DC PSU into a USB-C compatible one, with a simple module or a few.

Turning a 20 V PSU into a USB-C PSU feels natural if you want to charge a laptop – those tend to request 20 V from a USB-C PSU anyway, so what’s the big deal? However, you can’t just put 20 V onto a USB-C connector – you have to add a fair bit of extra logic to make your newly christened USB-C PSU safe to use with 5 V devices, and this logic also requires you go through a few extra steps before 20 V appears on VBUS. Any USB-C PSU has to output 5 V first and foremost whenever a device is connected, up until a higher voltage is negotiated digitally, and the PSU may only switch to a higher voltage output when it’s requested to do so.

Now, for that, a PSU offers a list of profiles, and we looked into those profiles in the Replying PD article – each profile is four bytes that contain information about the profile voltage, maximum current that the device may draw at that voltage, and a few other details. For a PSU to be USB-C compliant, the USB-C specification says that, in addition to 5 V, you may also offer 9 V, 15 V, and 20 V.

Also, the specification says that if a PSU supports certain in-spec voltage like 15 V, it’s also required by the spec to offer all of the spec-defined voltages below the maximum one – for 15 V, that also requires supporting 9 V. Both of these are UX requirements, as opposed to technical requirements – it’s easier for device and PSU manufacturers to work with a small set of pre-defined voltages that majority of the chargers will support, but in reality, you can actually offer any voltage you want in the PSU advertisement; at worst, a device is going to refuse and contend with slowly charging from the 5 V output that you’re required to produce.

I’d like to walk you through how off-the-shelf USB-C PSUs work, all of the options you can use to to create one, and then, let’s build our own USB-C PSU from scratch! Continue reading “USB-C For Hackers: Build Your Own PSU”

Power Supplies Without Transformers

For one-off projects or prototyping, it’s not too hard to find a wall wart or power supply to send a few joules of energy from the wall outlet to your circuit. Most of these power supplies use a transformer to step down the voltage to a more usable level and also to provide some galvanic isolation to the low voltage circuit. But for circuits where weight, volume, or cost are a major concern, a transformer may be omitted in the circuit design in favor of some sort of transformerless power supply.

While power supplies with this design do have many advantages, some care needs to be taken with regard to safety. The guide outlines four designs of increasing complexity which first puts out a basic transformerless power supply, using a series capacitor to limit current. To bring the voltage to an acceptable level, a recognizable bridge rectifier is paired with a capacitor as well as a zener diode. The second circuit presented adds voltage stabilization using a transistor and 78XX regulator. From there, zero-crossing detection is added to limit inrush surge currents, and the final design uses the venerable 555 timer to build a switching power supply.

Although it is noted several times throughout the guide, we’ll still point out here that transformerless designs like these introduce several safety issues since a mistake or fault can lead to the circuit being exposed to the mains voltage. However, with proper care and design it’s possible to make use of these designs to build more effective power supplies that can be safe to use for powering whatever circuit might energy but might not require the cost or weight of a transformer. For more on the theory of these interesting circuits and a few examples of where they are often found, check out the shocking truth about transformerless power supplies.

Thanks to [Stephen] for the tip!

Buck Converter Takes 8V To 100V

For those living before the invention of the transistor, the modern world must appear almost magical. Computers are everywhere now and are much more reliable, but there are other less obvious changes as well. Someone from that time would have needed a huge clunky machine like a motor-generator set to convert DC voltages, but we can do it with ease using a few integrated circuits. This one can take a huge range of input voltages to output a constant 5V.

The buck converter was designed by [hesam.moshiri] using a MP9486 chip. While it is possible to use a multipurpose microcontroller like something from Atmel to perform the switching operation needed for DC-DC converters, using a purpose-built chip saves a lot of headache. The circuit was modified a little bit to support the higher input voltage ranges and improve its stability and reliability. The board is assembled in an incredibly tiny package with inputs and outputs readily accessible, so it would be fairly simple to add one into a project rather than designing it from scratch.

Even though buck converters, and other DC converters like boost and the mysterious buck-boost converter, seem like magic even to us, there is some interesting electrical theory going on if you’re willing to dive into the inner workings of high-frequency switching. Take a look at this explanation we featured a while back to see more about how buck converters, the more easily understood among them, work.

AC-DC Converter Is Reliable, Safe, And Efficient

When first starting an electronics project, it’s not uncommon to dive right in to getting the core parts of the project working. Breadboarding the project usually involves working with a benchtop power supply of some sort, but when it comes to finalizing the project the actual power supply is often glossed over. It’s not a glamorous part of a project or the part most of us want to be working with, but it’s critical to making sure projects don’t turn up with mysterious issues in the future. We can look to some others’ work to simplify this part of our projects, though, like this power supply from [hesam.moshiri].

The power supply is designed around a switch-mode topology known as a flyback converter. Flyback converters work by storing electrical energy in the magnetic field of a transformer when it is switched on, and then delivering that energy to the circuit when it is switched off. By manipulating the switching frequency and turns ratios of the transformer, the circuit can have an arbitrary output voltage. In this case, it is designed to take 220V AC and convert it to 8V DC. It uses a simplified controller chip to decrease complexity and parts count, maintains galvanic isolation for safety, and is built to be as stable as possible within its 24W power limitation to eliminate any potential issues downstream.

For anyone trying to track down electrical gremlins in a project, it’s not a bad idea to take a long look at the power supply first. Any noise or unwanted behavior here is likely to cause effects especially in projects involving sensors, ADC or DAC, or other low-voltage or sensitive components. The schematic and bill of materials are available for this one as well, so anyone’s next project could use this and even make slight adjustments to change the output voltage if needed. And, if this is your first introduction to switched-mode power supplies, check out this in-depth look at the similar buck converter circuit to better understand what’s going on behind the scenes on these devices.

Continue reading “AC-DC Converter Is Reliable, Safe, And Efficient”

Tearing Down And Improving A Professional Power Supply

[OZ2CPU] has an HP power supply that is about 30 years old. It looks brand new, though, and has three outputs and includes tracking for the adjustable positive and negative supply. After a quick demo of the unit’s features, he tears it all down so we can see inside. You can catch the video below.

Some similar supplies offer a 10-turn adjustment knob, but this one doesn’t. Inside is a beefy transformer and quite a few through-hole components. There was room to change the main adjusted pot to a 10-turn unit, so he made the mod.

Continue reading “Tearing Down And Improving A Professional Power Supply”

High Voltage Power Supply From USB

Those who work in different spaces may have different definitions of the term “high voltage”. For someone working on the GPIO pins of a Raspberry Pi it might be as little as 5 volts, someone working on a Tesla coil might consider that to be around 20 kV, and an electrical line worker might not reference something as HV until 115 kV. What we could perhaps all agree on, though, is that getting 300 volts out of a USB power supply is certainly a “high voltage” we wouldn’t normally expect to see in that kind of context, but [Aylo6061] needed just such a power supply and was eventually able to create one.

In this case, the high voltages will eventually be used for electrophoresis or electrowetting. But before getting there, [Aylo6061] has built one of the safest looking circuits we’ve seen in recent memory. Every high voltage part is hidden behind double insulation, and there is complete isolation between the high and low voltage sides thanks to a flyback converter. This has the benefit of a floating ground which reduces the risk of accidental shock. This does cause some challenges though, as voltage sensing on the high side is difficult while maintaining isolation, so some clever tricks were implemented to maintain the correct target output voltage.

The control circuitry is based around an RP2040 chip and is impressive in its own right, with USB isolation for the data lines as well. Additionally the project code can be found at its GitHub page. Thanks to a part shortage, [Aylo6061] dedicated an entire core of the microprocessor to decoding digital data from the high voltage sensor circuitry. For something with a little less refinement, less safety, and a much higher voltage output, though, take a look at this power supply which tops its output voltage around 30 kV.

LED Driver Circuit For Safety Hat Sucks Single AAA Cell Dry

[Petteri Aimonen] created an omnidirectional LED safety light to cling to his child’s winter hat in an effort to increase visibility during the dark winter months, but the design is also great example of how to use the Microchip MCP1640 — a regulated DC-DC step-up power supply that can run the LEDs off a single AAA cell. The chip also provides a few neat tricks, like single-button on/off functionality that fully disconnects the load, consuming only 1 µA in standby.

[Petteri]’s design delivers 3 mA to each of eight surface-mount LEDs (which he says is actually a bit too bright) for a total of about 20 hours from one alkaline AAA cell. The single-layer PCB is encased in a clear acrylic and polycarbonate enclosure to resist moisture. A transistor and a few passives allow a SPST switch to act as an on/off switch: a short press turns the unit on, and a long press of about a second turns it back off.

One side effect is that the “off” functionality will no longer work once the AAA cell drained too badly, but [Petteri] optimistically points out that this could be considered a feature: when the unit can no longer be turned off, it’s time to replace the battery!

The usual way to suck a battery dry is to use a Joule Thief, and while this design also lights LEDs, it offers more features and could be adapted for other uses easily. Interested? [Petteri] offers the schematic, KiCAD file for the PCB, and SVG drawing of the enclosure for download near the bottom of the project page.