A devboard with the CH32V003, with a few resistors and bodges, with a USB-C cable plugged into it, and a programmer plus an extra probe attached.

USB PD On CH32V003 Teaches You Everything

How do you talk USB Power Delivery (PD)? Grab a PHY? Use a MCU with one built-in? Well, if you’re hardcore enough, you can do it with just a few resistors and GPIOs. [eeucalyptus] shows you their implementation of USB-PD on a CH32V003, which has no PD peripheral. This includes building a PD trigger, completely open source, and walking you through the entire low-level PD basics, too!

It helps that CH32V003 is a 32-bit MCU with a good few resources and peripherals, for instance, an internal comparator. Other than that, you don’t need much in terms of hardware resources, but you do need a steady hand — parts of the firmware had to be written in assembly to keep up with PD timing. Want to tinker with the fruit of this research, perhaps, further build upon the code? There’s an example board on GitHub, too!

Want to try your own luck with this method? There’s a schematic, and logic analyzer captures, and a board to refer to. Again, more than enough information on every single low-level detail! Otherwise, grab an MCU pre-programmed to talk PD, maybe a trigger board chip, or maybe even a PD PHY and implement PD communications with it directly – it’s pretty easy!

We thank [Julianna] for sharing this with us!

The splitter with a 3D-printed case and three yellow cables coming out of it, powering two phones and one powerbank at the same time

Split A USB-C PD Port Into Three Port-ions

There’s no shortage of USB-C chargers in all sorts of configurations, but sometimes, you simply need a few more charging ports on the go, and you got a single one. Well then, check out [bluepylons]’s USB-C splitter, which takes a single USB-C 5V/3A port and splits it into three 5V/1A plugs, wonderful for charging a good few devices on the go!

This adapter does things right – it actually checks that 3A is provided, with just a comparator, and uses that to switch power to the three outputs, correctly signalling to the consumer devices that they may consume about 1A from the plugs. This hack’s documentation is super considerate – you get detailed instructions on how to reproduce it, every nuance you might want to keep in mind, and even different case options depending on whether you want to pot the case or instead use a thermal pad for a specific component which might have to dissipate some heat during operation!

This hack has been documented with notable care for whoever might want to walk the journey of building one for themselves, so if you ever need a splitter, this one is a wonderful weekend project you are sure to complete. Wonder what kind of project would be a polar opposite, but in all the best ways? Why, this 2kW USB-PD PSU, most certainly.

All About USB-C: Example Circuits

In the six months that have passed after the last USB-C article has been released, I have thought up a bunch of ways that these articles could have been improved. It’s, of course, normal to have such a feeling — expected, even. I now believe that there’s a few gaps that I could bridge. For instance, I have not provided enough example circuits, and sometimes one schematic can convey things better than a thousand words.

Let’s fix that! I’ll give you schematics for the kinds of USB-C devices you’re actually likely to want to build. I’ll also share a bunch of IC part numbers in this article, but I don’t have an exhaustive collection, of course – if you find more cool ICs that work for USB-C purposes and aren’t mentioned here, please do let us all know in the comments!

Continue reading “All About USB-C: Example Circuits”

All About USB-C: Replying Low-Level PD

Last time, we configured the FUSB302 to receive USB PD messages, and successfully received a “capability advertisement” message from a USB-C PSU. Now we crack the PD specification open, parse the message, and then craft a reply that makes the PSU give us the highest voltage available.

How did the buffer contents look, again?

>>> b
b'\xe0\xa1a,\x91\x01\x08,\xd1\x02\x00\x13\xc1\x03\x00\xdc\xb0\x04\x00\xa5@\x06\x00<!\xdc\xc0H\xc6\xe7\xc6\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

The zeroes at the end might look non-significant, and they indeed are not with 99.99% certainty – that said, don’t just discard the entire tail end; one of the bytes in the beginning encodes the length of the message. We’ll read those bytes first, and then read only exactly as much as we need, making sure we aren’t reading two messages and interpreting it as one, and that we’re not discarding zeroes that are part of the message.

Today, we will write code that parses messages right after reading them from the FIFO buffer – however, keep this message handy for reference, still; and if you don’t have the hardware, you can use it to try your hand at decoding nevertheless. If you wanna jump in, you can find today’s full code here!

Continue reading “All About USB-C: Replying Low-Level PD”

All About USB-C: Talking Low-Level PD

In this USB-C series, we’ve covered quite a bit of USB-C – things that are well known, things that should beĀ  better known, and a couple things that just appeared online for the first time. We’ve covered almost everything in some depth except USB Power Delivery. I’ve described the process a bit in the “Power” article, but that was mostly about how to use PD by simply buying the right solution. However, that’s not enough for a hacker. Let’s see if we can make our own PD trigger board. Continue reading “All About USB-C: Talking Low-Level PD”

All About USB-C: Manufacturer Sins

People experience a variety of problems with USB-C. I’ve asked people online about their negative experiences with USB-C, and got a wide variety of responses, both on Twitter and on Mastodon. In addition to that, communities like r/UsbCHardware keep a lore of things that make some people’s experience with USB-C subpar.

In engineering and hacking, there’s unspoken things we used to quietly consider as unviable. Having bidirectional power and high-speed data on a single port with thousands of peripherals, using nothing but a single data pin – if you’ve ever looked at a schematic for a proprietary docking connector attempting such a feat, you know that you’d find horrors beyond comprehension. For instance, MicroUSB’s ID pin quickly grew into a trove of incompatible resistor values for anything beyond “power or be powered”. Laptop makers had to routinely resort to resistor and one-wire schemes to make sure their chargers aren’t overloaded by a laptop assuming more juice than the charger can give, which introduced a ton of failure modes on its own.

When USB-C was being designed, the group looked through chargers, OTG adapters, display outputs, docking stations, docking stations with charging functions, and display outputs, and united them into a specification that can account for basically everything – over a single cable. What could go wrong?

Of course, device manufacturers found a number of ways to take everything that USB-C provides, and wipe the floor with it. Some of the USB-C sins are noticeable trends. Most of them, I’ve found, are manufacturers’ faults, whether by inattention or by malice; things like cable labelling are squarely in the USB-C standard domain, and there’s plenty of random wear and tear failures.

I don’t know if the USB-C standard could’ve been simpler. I can tell for sure that plenty of mistakes are due to device and cable manufacturers not paying attention. Let’s go through the notorious sins of USB-C, and see what we can learn. Continue reading “All About USB-C: Manufacturer Sins”

All About USB-C: Pinecil Soldering Iron

As many people have pointed out, what matters with USB-C isn’t just the standard, it’s the implementations. After all, it’s the implementations that we actually have to deal with, and it’s where most of the problems with USB-C arise. There is some fault to the standard, like lack of cable markings from the get-go, but at this point, I’m convinced that the USB-C standard is a lot better than some people think.

I’d like to walk you through a few USB-C implementations in real, open-source, adjacent, and just interesting products. They’re all imperfect in some way – it can’t be otherwise, as they have to deal with the messy real world, where perfection is a rarity.

Today, let’s check out the Pinecil. A soldering iron by Pine64, released a few years ago, keeping the price low and quality high. It sports both a barrel jack and a USB-C port for its power input – a welcome departure from the Miniware iron strategy, where neither the barrel-jack-only TS100 nor the low-power proprietary-tip TS80 irons quite did it. And, given its design around TS100 T12-style tips, it’s no wonder Pinecil took a well-deserved spot in hobbyist world.

Can’t Just Pull The Trigger

Now, you might be thinking that Pinecil ought to be a simple device. The usual way to get high power out of a USB-C port is a Power Delivery (PD) trigger IC, and you could merely use that. However, if you’ve read the USB-C power article, you might remember the 45 W vs 60 W charger scenario, where such an arrangement would fail immediately. Overall, the configurability of trigger ICs is quite low, and when encountering a PD compatibility problem with some PSU, you can’t do anything about it except replace the IC with a slightly-different-logic IC- if a replacement even exists, and it usually does not. This is costly and limiting for a real-world use product. Continue reading “All About USB-C: Pinecil Soldering Iron”