usb – Hackaday https://hackaday.com Fresh hacks every day Tue, 29 Oct 2024 19:14:48 +0000 en-US hourly 1 https://wordpress.org/?v=6.6.2 156670177 Custom Fan Controller For Otherwise Fanless PCs https://hackaday.com/2024/10/29/custom-fan-controller-for-otherwise-fanless-pcs/ https://hackaday.com/2024/10/29/custom-fan-controller-for-otherwise-fanless-pcs/#respond Tue, 29 Oct 2024 20:00:29 +0000 https://hackaday.com/?p=729952 Most of us using desktop computers, and plenty of us on laptops, have some sort of fan or pump installed in our computer to remove heat and keep our machines …read more]]>

Most of us using desktop computers, and plenty of us on laptops, have some sort of fan or pump installed in our computer to remove heat and keep our machines running at the most optimum temperature. That’s generally a good thing for performance, but comes with a noise pollution cost. It’s possible to build fanless computers, though, which are passively cooled by using larger heat sinks with greater thermal mass, or by building more efficient computers, or both. But sometimes even fanless designs can benefit from some forced air, so [Sasa] built this system for cooling fanless systems with fans.

The main advantage of a system like this is that the fans on an otherwise fanless system remain off when not absolutely necessary, keeping ambient noise levels to a minimum. [Sasa] does have a few computers with fans, and this system helps there as well. Each fan module is WiFi-enabled, allowing for control of each fan on the system to be set up and controlled from a web page. It also can control 5V and 12V fans automatically with no user input, and can run from any USB power source, so it’s not necessary to find a USB-PD-compatible source just to run a small fan.

Like his previous project, this version is built to easily integrate with scripting and other third-party software, making it fairly straightforward to configure in a home automation setup or with any other system that is monitoring a temperature. It doesn’t have to be limited to a computer, either; [Sasa] runs one inside a server cabinet that monitors the ambient temperature in the cabinet, but it could be put to use anywhere else a fan is needed. Perhaps even a hydroponic setup.

]]>
https://hackaday.com/2024/10/29/custom-fan-controller-for-otherwise-fanless-pcs/feed/ 0 729952 fan-control-main
Ubiquitous Successful Bus: Version 2 https://hackaday.com/2024/10/17/ubiquitous-successful-bus-version-2/ https://hackaday.com/2024/10/17/ubiquitous-successful-bus-version-2/#comments Thu, 17 Oct 2024 17:00:54 +0000 https://hackaday.com/?p=705217 I’ve talked a fair bit about USB-C before, explaining how it all works, from many different angles. That said, USB-C is just the physical connector standard, plus the PD part …read more]]>

I’ve talked a fair bit about USB-C before, explaining how it all works, from many different angles. That said, USB-C is just the physical connector standard, plus the PD part that takes care of voltages and altmodes – things like data transfer are still delegated to the two interfaces you invariably end up using on USB-C ports, USB 2, and USB 3.

You might think USB 2 and USB 3 are tightly related, but in many crucial ways, they couldn’t be more different. I have experience working with both, and, as you might guess, I want to share it all with you. You might be surprised to hear there’s plenty to learn about USB 2 in particular – after all, we’ve had it hang around for 30 years now. Well, let’s make sure you’re fully caught up!

The Ingredients

USB 2 is a point-to-point link – one side is “host” and another is “device”, with the host typically being a PC chipset or a single-board computer. USB 2 relies on a single pseudodifferential pair. It’s “pseudodifferential” because the wires don’t just do differential signaling – they also use digital logic levels and pullup/pulldown resistors to signal device presence, especially in the beginning when the USB link is still getting established. Indeed, you can imitate a USB device’s presence with just a resistor.

This differential pair is half-duplex – it’s used for communications back and forth, but only one direction of data transfer at a time. Just like I2C, USB 2 requires the host to initiate all communications. The host has to poll the devices on a regular basis to receive data, a point that regularly gets brought up by defenders of PS/2 keyboards.

You know that USB ports come with a a 5 V power rail, but there are plenty of 3.3 V USB devices, too – in fact, most USB devices operate on 3.3 V internally. At its core, USB 2 requires 3.3 V-based signaling – which is why, when powering your RP2040 from 1.8 V, you must still provide 3.3 V if you want the USB peripheral to work.

An old flash drive, with a 12MHz crystal front and center. By [Tod Kurt], CC BY 2.0
You need reasonably accurate clocks to talk USB 2, which is why everyone ends up adding a 12 MHz crystal to their USB projects even when they have an internal RC oscillator. Some devices like cheap USB hub ICs boast an internal RC oscillator that supposedly works for USB transfers, but if you want to use it, you should test it well before you try and rely on it – it could be a path towards USB data transfer errors. Thankfully, 12 MHz crystals are more than abundant, and more than cheap enough.

In short – if you plan to put USB devices on your board, get some 12 MHz crystals and you’ll likely be well-prepared. Why the 12 MHz specifically? It’s directly related to a common USB 2 device speed, of which there are three.

The Three Generations

You might have heard of USB 1.1 and USB 2.0 standards, supposedly, being entirely different beasts – that’s true, but nowadays this distinction can be misleading. In practice, there are three versions of USB 2 you should actually distinguish.

These three versions are: low-speed at 1.5 Mbps, full-speed at 12 Mbps, and high-speed at 480 Mbps. The USB 1.1 standard only described the 1.5 Mbps “low-speed” and 12 Mbps “full-speed” devices. The USB 2.0 standard covers both of these modes, too, but also adds the 480 Mbps “high-speed” mode, which operates quite differently on the hardware level, and a number of other improvements.  Modern devices are most often USB 2.0, even if they’re 1.5 Mbps or 12 Mbps, which is why I don’t use USB 1 to refer to these kinds of devices – it’s rarely true.

Which speed is this “USB 2.0” hub? Well, it could be any of the three – plug it in and find out. In my experience, this particular hub is unlikely to be well-built. By [メイド理世], CC BY-SA 4.0
In fact, I’ve just checked, and all of my 12 Mbps USB devices report compatibility with USB 2.0 standard – my Logitech Unifying receiver, the internal Bluetooth adapter of my Intel WiFI card, and a USB-C 3.5 mm jack DAC from Apple. By the way, you can learn about your plugged-in USB devices and their speeds on Linux using lsusb -t and lsusb -v, and on Windows, you can use something like HWInfo. Bottom line is – the device speed is what matters, and the standard version doesn’t matter as much, whether it’s 1.0, 1.1, 2.0, or a secret fourth thing.

Flash drives and Ethernet or WiFi adapters are bound to be 480 Mbps, whereas devices like mice, keyboards, fingerprint readers, or USB-UART adapters are typically 12 Mbps. The three speed standards are expected to be compatible between each other – for instance, 480 Mbps devices are expected to be able to fall back to lower speeds if needed, and 480 Mbps hosts are designed to support 12 Mbps and 1.5 Mbps devices. The USB guarantee is that you can plug anything into anything, and generally, it works out.

Microcontrollers, sadly, rarely reach 480 Mbps on their USB peripherals, as much as that would make all our Pi Pico logic analyzers shine. There’s some fundamental reasons for this – 480 Mbps signaling is entirely different from 12 Mbps and 1.5 Mbps, with the 480 Mbps signal looking much more like a modern day differential pair, and 12 Mbps signal being firmly 3.3 V-referenced, in effect, a logic level signal a la UART. This is why you can easily capture lower-speed USB with a logic analyzer or a Pi Pico, but you can’t do that for 480 Mbps anymore.

Of course, some hosts don’t handle the inter-speed compatibility aspect well. This is generally a matter of driver support – famously, the Raspberry Pi 1 Model A, without the onboard USB hub and Ethernet chip, initially didn’t work well with mice and keyboards and other low-speed devices on its sole USB port. Specifically, its only USB port that was connected directly to the SoC. On the far more popular Model B, the onboard USB hub acted as a “proxy” of sorts, handling the lower-speed USB devices internally while keeping a full-speed link to the SoC, so the SoC on the Model B only actually talked to a single full-speed device and the driver issues never surfaced. The driver quality has come a long way, and the Pi Zero no longer experiences this problem, however, but other devices of yours might – if that’s the case, remember that you can always add a hub in between.

On the other hand, over a dozen years ago, when high-speed 480Mbps devices became more popular, PC front panel cabling was often designed for the somewhat more lax physical requirements of lower-speed USB, and even stretching those requirements. Remember the advice to plug your USB device directly into the motherboard port if it’s not working well? Often, the shoddily built front panel cable was the reason for that. Not to mention that most front panel boards never had any capacitors on them, something that dramatically helps your USB device stability when you’re adding a host port.

Oh, and the usual reminder, these data rate numbers are megabits (Mb) per second. If you want megabytes (MB) per second, you want to divide by 8, and then some more because of the data transfer overhead. In practice, if you have a 480 Mbps flash drive, expect transfer speeds of 30 MB per second or so; same goes for USB2 WiFi and Ethernet adapters, of course. This was another well-known problem with Raspberry Pi boards before Pi 4 – lowered transfer speeds when using Ethernet and USB devices at the same time, since all of them had to go through a single 480 Mbps link to the SoC. Then, with the Pi 4, the SoC acquired a PCIe link and a separate GMII link for Ethernet, and nowadays this complaint is history.

Conventions, Pinouts, Colours

Follow these colours and pinout as much as possible. Based on drawing by [Fred the Oyster], CC BY-SA 4.0
USB2 has a well defined standard for wire colours and connector pinout. You shall try and preserve both the colours and the pinout as much as possible, because such conventions help everyone involved. Debugging a device for hours because you confused ground with data, or burning up devices because you mixed up power wires – these scenarios are disastrous and entirely preventable if you stick to the colors that everyone uses!

Red and black are 5 V power and ground – a good ground connection is required for USB to work. Wondering just how much current you get? The answer is, 500 mA is guaranteed, and 1 A to 2 A is exceptionally likely; I’ve talked about it in more detail in this article.

Green and white are D+ and D-, the two pins in the diffpair. Again, preserve these colours where possible! Cables are very likely to follow these specifications, and if you memorize the colours, you can easily wire up your own tech in no time. You can remember the colours through a mnemonic – green is summer (life, +), and white is winter (death, -). The standard pinout for USB-A and MicroUSB/MiniUSB connectors is VCCD-D+GND, and it’s easy to remember too – you sit next to a fireplace (power) in winter, you go to the beach (ground) in the summer.

A USB standard, or a warcrime? Who’s to say. Though, maybe it’s my anti-HDMI bias speaking. By [C0nanPayne], CC BY-SA 4.0
MicroUSB (and MiniUSB) has an ID pin right next to GND, a pin originally intended for indicating whether your phone’s MicroUSB socket should switch into host mode, and later growing into a proprietary mess of a pin. In those dark times, it was used for video over MicroUSB standards like MHL, debug port summoning using bespoke resistor values, and even combined charging and host modes – none of it documented or prominent in any reasonable way. You rarely ever need to bother with the ID pin – nowadays, USB-C does that the ID pin ever could and way more, and it’s clear the primitive proprietary ID pin signaling standards have inspired the well-structured standard that is USB PD.

Unlike some nice standards like PCIe and USB 2, you have to connect + to + and - to -, no crossing wires. It won’t hurt anything electrically if you flip them, though, so if you’re reverse-engineering a device with USB 2 on a custom connector, feel free to connect it one way, plug it in, check dmesg or Device Manager. If you see enumeration faults, just unplug, flip the wires, and plug it in again. One warning, don’t solder on the data wires of a device plugged in, that can easily kill your device! A flipped connection where both wires still make contact is guaranteed to still result in enumeration, just that it will error out – you can use that as a way to check your connections, too.

Which connector do you use for USB2 on your own devices? Without a doubt, USB-C is the best and most universal choice; don’t be like Raspberry Pi Foundation with Pi Pico boards, forcing us to tap into our ever so dwindling supply of microUSB cables. Remember, you only need two 5.1 kΩ resistors (or 4.7 kΩ, or two pairs of 10 kΩ in parallel) to properly implement a USB-C device port, or two 51 kΩ resistors to implement a host port. Don’t be a fool, USB-C your tools.

What if you want an embedded USB port, in a low footprint? My advice: you should put USB on JST-SH sockets, just like QWIIC, which is an I2C-on-JST-SH connector and pinout standard that you should also use. I used to put USB on the JST-SH pins in a way that mimicks the USB-A pinout, but now, I use a riff on the QWIIC pinout – GNDVCCD+D-. Yes, I told you to use a pinout, but this one is for a good cause – it avoids killing devices if you accidentally plug a QWIIC device into a USB JST-SH port, or vice-versa.

Bringing USB2 Places

You can pull a USB 2 link for up to five meters, in theory, though three or four meters is way more likely. Two meters is the longest that you usually see in USB2 cables on the market. You’ll want seriously proper cables for five meters, of course, because that’s where things start to get touchy. When it comes to link quality, USB 2 can take a beating – until it can’t.

You might have seen USB 2 operate in some pretty bad conditions – dirt cheap USB hubs routed on a single-layer cardboard-backed PCBs, no impedance matching whatsoever. Indeed, you can get away with this more often than not. However, if you’re pushing USB 2 to its 480 Mbps limit, maybe you’re just putting a hub on your board and exposing some ports, beware – you might just get an unpleasant surprise in the shape of USB errors in your OS logs. By the way, on Linux, you can check for these errors by looking in dmesg – run dmesg -Hw to get a view on what’s happening with your kernel, including any USB errors that might occur.

The RP2040 with its 12 Mbps max speed might not have to impedance match, though the Pi Pico does, but if you’re designing a hub and you want stable 480 Mbps, you should certainly remove length differences between tracks in the USB 2 differential pair, and at least attempt to impedance match your tracks – again, treat your diffpairs with respect. Off the board, same goes for making sure your D+ and D- wires are a twisted pair.

That’s enough for today – next time, let’s talk about ESD diodes, USB2 hubs, connectors, debug tools, bitbanging, descriptors, and a fair bit more. At the same time, let’s explore USB3 – USB2’s younger sibling, so alike yet very different.

]]>
https://hackaday.com/2024/10/17/ubiquitous-successful-bus-version-2/feed/ 51 705217 usb-featured
Mechanical Switch Sci-Calc is Also a Macropad https://hackaday.com/2024/10/04/mechanical-switch-sci-calc-is-also-a-macropad/ https://hackaday.com/2024/10/04/mechanical-switch-sci-calc-is-also-a-macropad/#comments Sat, 05 Oct 2024 05:00:21 +0000 https://hackaday.com/?p=725591 A black OLED screen with a happy face displayed upon it is situated at the top of a squarish calculator with a 5x6 grid of white calculator keys. It floats above a graphing calculator, Nintendo Switch, aigo numpad, and an Arduino Mega on a white table. A handful of differently-colored kalih choc switches are in various places around the table.Smartphones have replaced a desktop calculator for most folks these days, but sometimes that tactility is just what you need to get the mathematical juices flowing. Why not spruce up …read more]]> A black OLED screen with a happy face displayed upon it is situated at the top of a squarish calculator with a 5x6 grid of white calculator keys. It floats above a graphing calculator, Nintendo Switch, aigo numpad, and an Arduino Mega on a white table. A handful of differently-colored kalih choc switches are in various places around the table.

Smartphones have replaced a desktop calculator for most folks these days, but sometimes that tactility is just what you need to get the mathematical juices flowing. Why not spruce up the scientific calculator of yore with the wonders of modern microcontrollers?

While you won’t be able to use Sci-Calc on a standardized test, this classy calculator will let you do some pretty cool things while clacking on its mechanical choc switches. Is it a calculator? Obviously. Is it an Arduboy-compatible device that can play simple games like your TI-84? Yes. Is it also a macropad and ESP32 dev board? Why not? If that isn’t enough, it’s also takes both standard and RPN inputs.

[Shao Duan] has really made this device clean and the menu system that rewrites main.bin based on the program selection is very clever. Escape writes main.bin back into the ROM from the SD card so you can select another application. A few classic games have already been ported, and the process looks fairly straightforward for any of your own favorites.

If you’re hankering for more mathy inputs, checkout the Mathboard or the MCM/70 from 1974.

]]>
https://hackaday.com/2024/10/04/mechanical-switch-sci-calc-is-also-a-macropad/feed/ 6 725591 sci-calc
Where Do You Connect The Shield? https://hackaday.com/2024/09/13/where-do-you-connect-the-shield/ https://hackaday.com/2024/09/13/where-do-you-connect-the-shield/#comments Fri, 13 Sep 2024 17:00:29 +0000 https://hackaday.com/?p=705264 When it comes to polarizing and confusing questions in electronics, wiring up shields is on the top-10 list when sorted by popularity. It’s a question most of us need to …read more]]>

When it comes to polarizing and confusing questions in electronics, wiring up shields is on the top-10 list when sorted by popularity. It’s a question most of us need to figure out at some point – when you place a USB socket symbol on your schematic, where do you wire up the SHIELD and MP pins?

Once you look it up, you will find Eevblog forum threads with dozens of conflicting replies, Stackexchange posts with seven different responses plus a few downvoted ones, none of them accepted, and if you try to consult the literature, the answer will invariably be “it depends”.

I’m not a connector-ground expert, I just do a fair bit of both reading and hacking. Still, I’ve been trying to figure out this debate, for a couple years now, re-reading the forum posts each time I started a new schematic with a yet-unfamiliar connector. Now, of course, coming to this question with my own bias, here’s a summary you can fall back on.

Consumer Ports

Putting HDMI on your board? First of all, good luck. Then, consider – do you have a reason to avoid connecting the shield? If not, certainly connect the shield to ground, use jumpers if that’s what makes you comfortable, though there’s a good argument that you should just connect directly, too. The reason is simple: a fair few HDMI cables omit GND pin connections, fully relying on the shield for return currents. When your HDMI connection misfires, you don’t want to be debugging your HDMI transmitter settings when the actual No Signal problem, as unintuitive as it sounds, will be simply your shield not being grounded – like BeagleBone and Odroid didn’t in the early days. By the way, is a DVI-D to HDMI adapter not working for you? Well, it might just be that it’s built in a cheap way and doesn’t connect the shields of the two sockets together – which is fixable.

Putting an Ethernet port on your board? This is the case where you should probably watch out, to make sure you understand what’s happening. Ethernet doesn’t use or need ground as such — it’s a galvanically isolated interface — but if you ground the shield and then use a shielded cable, your ground will go run along the shield. Do you need it? Likely not. Do you want it? I’d say it’s inconclusive. This only applies if your cable has a shield and metal-plated jacks that connect to it: while that’s not the norm, it’s the case for CAT6 and CAT7 cables, which are now pretty common because they’re pretty much required for 2.5 Gbps and above interfaces. Same goes for magjack shields, though watch out, they have a separate ground pin for the internal transformers and circuitry, you do need to wire that up, it won’t propagate any further than it might need to.

Every coaxial port that has a shield contact, but there’s only two contacts in total? This goes from RCA to BNC – the “shield” is actually often a ground pin, though not everyone might realize this. If it is used as a ground pin, passing the return current through, it has to stay grounded at both ends.

USB Ports

There are a fair few different USB port connectors and roles you could be putting on your board – here’s a quick answer for a somewhat common case. USB-A port that’s a host and therefore a power source? Connect the shield to ground. This is what you are universally expected to do, and something that indeed is done basically everywhere you look, bar devices that are being a bit bizarre.

What about a device port, like microUSB, or USB-B, or, hell, miniUSB? Well, the recommendation is leaving two footprints connected to the shield, so you can stuff them with 0-ohm resistors later, or put, say, a resistor-and-capacitor combo there if you’re having noise issues. Honestly, it is unlikely to hurt you if you ground it, doubly so if it’s a power only port – USB is a seriously sensitive interface when it comes to common mode shifts.

Using USB-C? Just wire the shield to ground. Do not pass go, do not collect 200, just wire it up to ground. Why? The specification requires you to, so that’s an easy call. It’s definitely true that, with dual-role ports being abundant, you can no longer really differentiate between host or device, so figuring out shield grounding based on already shaky roles would be a problem. By the way, this is a gift for all of us reverse-engineers out there – finally, a connector with a shield that is guaranteed to be ground-connected!

Not everyone realizes that the specification explicitly mandates it, and people still think separating shield from ground could be meaningful, including myself as recently as a few months ago. If anyone needs a pointer, tell them to check the USB-C cable and connector specification, revision 2.2. For sockets (receptacles), open page 44 and refer to the note 11, for plugs, open page 78 and refer to the note 6.

Other Concerns

There is some mechanical helpfulness to hard-wiring shield to ground, especially if you’re using copper fills without thermals. In my experience, it’s harder for connectors to break off when they have a plane of solid uninterrupted copper they adhere to! Now, thermals do help soldering a whole bunch, so I don’t want to be gung-ho about it, but if you’re dealing with a fully surface-mount connector that can get torn off, you might as well go thermal-less just this once. Worked for me on a larger-scale product of mine, to the point I completely stopped getting the problem where microUSB shield pads would get torn off the board. Of course, remember, microUSB with through-hole mounting pins is superiour mechanically – in case you do make the very situational decision to use microUSB.

The debate about grounding shields might never end, but if you want a summary, this is what I can say surefire, and I hope it helps. What’s your take?

]]>
https://hackaday.com/2024/09/13/where-do-you-connect-the-shield/feed/ 24 705264 PCBdesign
Rescuing High-Res Displays from Older Macs https://hackaday.com/2024/09/10/rescuing-high-res-displays-from-older-macs/ https://hackaday.com/2024/09/10/rescuing-high-res-displays-from-older-macs/#comments Tue, 10 Sep 2024 15:30:08 +0000 https://hackaday.com/?p=706631 When Apple started rolling out its Retina displays, it multiplied the amount of pixels compared to their standard, non-Retina displays by four. This increased pixel density while keeping the standard …read more]]>

When Apple started rolling out its Retina displays, it multiplied the amount of pixels compared to their standard, non-Retina displays by four. This increased pixel density while keeping the standard screen size — idea for those needing a lot of detail for their work. But, as is common with Apple, using these displays outside of the Apple ecosystem can be quite a challenge. Retina displays have been around for about a decade now, though, with some third-party hardware able to break them free of their cage. This post details how [Kevin] liberated the 5K display from a 2017 iMac for more general use with support for USB-C.

The first step was to find a used iMac for the right price, and then sell off most of its parts to recoup most of the initial cost. That brought the cost of the panel itself to about $250. The key to getting the display working without all of the Apple hardware is the R1811 driver board, which can be had for around $300. A new 156 watt power supply was added to the mix, and [Kevin] also put in a few extras like a USB cable extension and a latching push-button which kills the display’s power. Additionally, he attempted to get the original iMac speakers working with this setup too, but none of his attempts resulted in anything close to quality sound so he’s mostly abandoned that extra feature for now.

With that all buttoned up, he has a 27″ 5K display with USB-C input for around $650 which is quite a deal. The MacRumors thread that [Kevin] added his project to currently has around 1,700 posts about similar builds too, so it can be a wealth of information for all kinds of models. As Apple drops support for their older machines, these displays will become more and more common and projects like these can keep a lot of e-waste out of the landfill while also providing decent hardware at a bargain price. Don’t just look for iMacs and MacBooks though; there’s a similar process to use various iPad displays for other things as well.

]]>
https://hackaday.com/2024/09/10/rescuing-high-res-displays-from-older-macs/feed/ 26 706631 CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 85
Universal Power Bank Customized To Your Liking https://hackaday.com/2024/08/31/universal-power-bank-customized-to-your-liking/ https://hackaday.com/2024/08/31/universal-power-bank-customized-to-your-liking/#comments Sat, 31 Aug 2024 11:00:00 +0000 https://hackaday.com/?p=704942 One of the most troubling trends of almost every modern consumer product that uses electricity is that the software that controls the product is likely to be proprietary and closed-source, …read more]]>

One of the most troubling trends of almost every modern consumer product that uses electricity is that the software that controls the product is likely to be proprietary and closed-source, which could be doing (or not doing) any number of things that its owner has no control over. Whether it’s a computer, kitchen appliance, or even a device that handles the electricity directly, it’s fairly rare to find something with software that’s open and customizable. That’s why [Traditional-Code9728] is working on a power bank with an open-source firmware.

From a hardware perspective the power bank is fairly open as well, with a number of options for connecting this device to anything else that might need power. It sports a bidirectional USB-C port as well as a DC barrel plug, either of which can either charge other devices or receive energy to charge its own battery. These ports can also accept energy from a solar panel and have MPPT built in. There’s also dual USB-A ports which can provide anywhere from five to 12 volts at 25 watts, and a color screen which shows the current status of the device.

While this is a prototype device, it’s still actively being worked on. Some future planned upgrades to the power bank include a slimmer design, charge limiting features to improve battery life, and more fine-tuned control of the output voltage and current on the USB-C port. With all of the software being open-source, as well as the circuit diagram and 3D printing files, it could find itself in plenty of applications as well. This power bank also stays under the energy limits for flying on most commercial airlines as well, but if you don’t plan on taking your power bank on an airplane then you might want to try out this 2000-watt monster instead.

]]>
https://hackaday.com/2024/08/31/universal-power-bank-customized-to-your-liking/feed/ 10 704942 power-bank-main
USB And The Myth Of 500 Milliamps https://hackaday.com/2024/07/03/usb-and-the-myth-of-500-milliamps/ https://hackaday.com/2024/07/03/usb-and-the-myth-of-500-milliamps/#comments Wed, 03 Jul 2024 17:00:01 +0000 https://hackaday.com/?p=693576 If you’re designing a universal port, you will be expected to provide power. This was a lesson learned in the times of LPT and COM ports, where factory-made peripherals and …read more]]>

If you’re designing a universal port, you will be expected to provide power. This was a lesson learned in the times of LPT and COM ports, where factory-made peripherals and DIY boards alike had to pull peculiar tricks to get a few milliamps, often tapping data lines. Do it wrong, and a port will burn up – in the best case, it’ll be your port, in worst case, ports of a number of your customers.

Want a single-cable device on a COM port? You might end up doing something like this.

Having a dedicated power rail on your connector simply solves this problem. We might’ve never gotten DB-11 and DB-27, but we did eventually get USB, with one of its four pins dedicated to a 5 V power rail. I vividly remember seeing my first USB port, on the side of a Thinkpad 390E that my dad bought in 2000s – I was eight years old at the time. It was merely USB 1.0, and yet, while I never got to properly make use of that port, it definitely marked the beginning of my USB adventures.

About six years later, I was sitting at my desk, trying to build a USB docking station for my EEE PC, as I was hoping, with tons of peripherals inside. Shorting out the USB port due to faulty connections or too many devices connected at once was a regular occurrence; thankfully, the laptop persevered as much as I did. Trying to do some research, one thing I kept stumbling upon was the 500 mA limit. That didn’t really help, since none of the devices I used even attempted to indicate their power consumption on the package – you would get a USB hub saying “100 mA” or a mouse saying “500 mA” with nary an elaboration.

Fifteen more years have passed, and I am here, having gone through hundreds of laptop schematics, investigated and learned from design decisions, harvested laptops for both parts and even ICs on their motherboards, designed and built laptop mods, nowadays I’m even designing my own laptop motherboards! If you ever read about the 500 mA limit and thought of it as a constraint for your project, worry not – it’s not as cut and dried as the specification might have you believe.

Who Really Sets The Current Limit?

The specification originally stated – you aren’t supposed to consume more than 500mA from a USB port. At some points, you’re not even supposed to consume more than 100mA! It talked unit loads, current consumption rates, and a good few other restrictions you would want to apply to a power rail. Naturally, that meant enforcement of some kind, and you would see this limit enforced – occasionally.

On the host side, current limiting had to be resettable, of course, and, at the time, that meant either PTC fuses or digital current limiting – both with their flaws, and a notable price increase – per port. Some bothered (mostly, laptops), but many didn’t, either ganging groups of ports together onto a single limited 5 V rail, or just expecting the board’s entire 5 V regulator to take the fall.

Current limiting a port is this simple

Even today, hackers skimp on current limiting, as much as it can be useful for malfunctioning tech we all so often hack on. Here’s a tip from a budding motherboard designer: buy a good few dozen SY6280’s, they’re 10 cents apiece, and here’s a tiny breakout PCB for them, too. They’re good for up to 2 A, and you get an EN pin for free. Plus, it works for both 3.3 V, 5 V, and anything in between, say, a single LiIon cell’s output. Naturally, other suggestions in comments are appreciated – SY6280 isn’t stocked by Western suppliers much, so you’ll want LCSC or Aliexpress.

Another side of the equation – devices. Remember the USB cup warmer turned hotplate that required 30 paralleled USB ports to cook food? It diligently used these to stay under 500 mA. Mass-manufactured devices, sadly, didn’t.

Portable HDDs wanted just a little more than 2.5 W to spin-up, 3G modem USB sticks wanted an 2 A peak when connecting to a network, phones wanted more than 500 mA to charge, and coffee warmers, well, you don’t want to sell a 2.5 W coffee warmer when your competitor boasts 7.5 W. This led to Y-cables, but it also led to hosts effectively not being compatible with users’ devices, and customer dissatisfaction. And who wants complaints when a fix is simple?

It was also the complexity. Let’s say you’re designing a USB hub with four ports. At its core, there’s a USB hub IC. Do you add current consumption measurement and switching on your outputs to make sure you don’t drain too much from the input? Will your users like having their devices randomly shut down, something that cheaper hubs won’t have a problem with? Will you be limiting yourself to way below what the upstream port can actually offer? Most importantly, do users care enough to buy an overly compliant hub, as opposed to one that costs way less and works just as well save for some edge cases?

Stretching The Limit

500 mA current monitoring might have been the case originally, but there was no real need to keep it in, and whatever safety 500 mA provided, came with bothersome implementation and maintenance. The USB standard didn’t expect the 2.5 W requirement to budge, so they initially had no provisions for increasing, apart from “self-powering” aka having your device grab power from somewhere else other than the USB port. As a result, both devices and manufacturers pushed the upper boundary to something more reasonable, without an agreed-upon mechanism on how to do it.

USB ports, purely mechanically, could very well handle more than 0.5 A all throughout, and soon, having an allowance of 1 A or even 1.5 A became the norm. Manufacturers would have some current limits of their own in mind, but 500 mA was long gone – and forget about the 100 mA figure. Perhaps the only place where you could commonly encounter 500 mA was step-ups inside mobile phones, simply because there’s neither much space on a motherboard nor a lot of power budget to spend.

Smartphone manufacturers were in a bind – how do you distinguish a port able to provide 500 mA from a port able to provide 1000 mA, or even 2 A outright? That’s how D+/D- shenanigans on phone chargers came to be – that, and manufacturers’ greed. For Android, you were expected to short data lines with a 200 Ohm resistor, for Apple, you had to put 2.2 V or 2.7 V on the data pins, and if you tried hard enough, you could sometimes use three resistors to do both at once.

Bringing The Standard In Line

The USB standard group tried to catch up with the USB BC (Battery Charging standard), and adopted the Android scheme. Their idea was – if you wanted to do a 1.5 A-capable charger, you would short D+ and D-, and a device could test for a short to check whether it may consume this much. Of course, many devices never checked, but it was a nice mode for smartphones specifically.

When you’re making a device with a LiIon that aims to consume over an amp and be produced in quantity of hundreds of thousands, safety and charger compatibility is pretty crucial. A less common but nifty charging mode from the BC standard, CDP (Charging Downstream Port), would even allow you to do USB2 *and* 1.5 A. Support for it was added to some laptops using special ICs or chipset-level detection – you might have had a yellow port on your laptop, dedicated for charging a smartphone and able to put your phone’s port detection logic at ease.

Further on, USB3 took the chance to raise the 500 mA limit to 90 0mA. The idea was simple – if you’re connected over USB2, you may consume 500 mA, but if you’re a USB3 device, you may take 900 mA, an increased power budget that is indeed useful for higher-speed USB3 devices more likely to try and do a lot of computation at once. In practice, I’ve never seen any laptop implement the USB2 vs USB3 current limit checking part, however, as more and more devices adopted USB3, it did certainly raise the bar on what you could be guaranteed to expect from any port.

As we’ve all seen, external standards decided to increase the power limit by increasing voltage instead. By playing with analog levels on D+ and D- pins in a certain way, the Quick Charge (QC) standard lets you get 9 V, 12 V, 15 V or even 20 V out of a port; sadly, without an ability to signal the current limit. These standards have mostly been limited to phones, thankfully.

USB-C-lean Slate

USB-C PD (Power Delivery) has completely, utterly demolished this complexity, as you might notice if you’ve followed my USB-C series. That’s because a device can check the port’s current capability with an ADC connected to each of the two CC pins on the USB-C connector. Three current levels are defined – 3 A, 1.5 A and “Default” (500 mA for USB2 devices and 900 mA for USB3). Your phone likely signals the Default level, your charger signals 3 A, and your laptop either signals 3 A or 1.5 A. Want to get higher voltages? You can do pretty simple digital communications to get that.

Want to consume 3 A from a port? Check the CC lines with an ADC, use something like a WUSB3801, or just do the same “check the PSU label” thing. Want to consume less than 500 mA? Don’t even need to bother checking the CCs, if you’ve got 5 V, it will work. And because 5 V / 3 A is a defined option in the standard, myriad laptops will effortlessly give you 15 W of power from a single port.

On USB-C ports, BC can still be supported for backwards compatibility, but it doesn’t make as much sense to support it anymore. Proprietary smartphone charger standards, raising VBUS on their own, are completely outlawed in USB-C. As device designers have been provided with an easy mechanism to consume a good amount of power, compliance has become significantly more likely than before – not that a few manufacturers aren’t trying to make their proprietary schemes, but they are a minority.

]]>
https://hackaday.com/2024/07/03/usb-and-the-myth-of-500-milliamps/feed/ 91 693576 usb-featured