The USB Protocol, Explained

If you can explain what a USB PID, a J state, a K state, and an SOF are, you can probably stop reading now. But if you don’t know or you want a refresher, you can spend 15 minutes watching [Sine Lab’s] straightforward explanation of the USB protocol details. You can find the video below.

The motivation for this is he wants to add USB to his projects using an ATMega with a hardware USB implementation. Honestly, most of the time, you’ll just consume some premade library and get it working that way. However, understanding the terminology can help you, especially if things don’t go as planned.

Continue reading “The USB Protocol, Explained”

A Hackaday.io page screenshot, showing all the numerous CH552 projects from [Stefan].

All The USB You Can Do With A CH552

Recently, you might have noticed a flurry of CH552 projects on Hackaday.io – all of them with professionally taken photos of neatly assembled PCBs, typically with a USB connector or two. You might also have noticed that they’re all built by one person, [Stefan “wagiminator” Wagner], who is a prolific hacker – his Hackaday.io page lists over a hundred projects, most of them proudly marked “Completed”. Today, with all these CH552 mentions in the Hackaday.io’s “Newest” category, we’ve decided to take a peek.

The CH552 is an 8-bit MCU with a USB peripheral, with a CH554 sibling that supports USB host, and [Stefan] seriously puts this microcontroller to the test. There’s a nRF24L01+ transceiver turned USB dongle, a rotary encoder peripheral with a 3D-printed case and knob, a mouse wiggler, an interface for our beloved I2C OLED displays, a general-purpose CH55x devboard, and a flurry of AVR programmers – regular AVRISP, an ISP+UPDI programmer, and a UPDI programmer with HV support. Plus, if USB host is your interest, there’s a CH554 USB host development board specifically. Every single one of these is open-source, with PCBs designed in EasyEDA, the firmware already written (!) and available on GitHub, and a lovingly crafted documentation page for each.

[Stefan]’s seriously put the CH552 to the test, and given that all of these projects got firmware, having these projects as examples is a serious incentive for more hackers to try these chips out, especially considering that the CH552 and CH554 go for about 50 cents a piece at websites like LCSC, and mostly in friendly packages. We did cover these two chips back in 2018, together with a programming guide, and we’ve seen things like badges built with its help, but having all these devices to follow is a step up in availability – plus, it’s undeniable that all the widgets built are quite useful by themselves!

Hobnobbing With The Knob

The scroll wheel might be the best thing that happened to the computer mouse since, well, the computer mouse. But sometimes you want something a little more tangible. For example, with a software-defined radio setup, it doesn’t feel right to scroll your mouse to change frequencies. That’s where [Wagiminator]’ USB knob would come in handy. Marrying a 3D printed case, some addressable LEDs, a rotary encoder, and a CH552E microcontroller, the knob appears to the host operating system as a normal USB keyboard. That means most programs can use it without any special drivers or software.

There’s honestly not much to the hardware. A custom PCB holds two WS2812’s, the tiny CPU, the encoder, and the USB plug. There are a few random discrete components, too, but not many. Everything you need is on the project page. The PCB layout, the software, the schematics, and the 3D print files. The code that does the main work is extremely simple. The USB code is a bit more complex (look in the include directory) but honestly, it isn’t as bad as most USB examples we’ve seen.

This project is ripe for hacking. The software is simple enough to modify easily. The 3D printed case wouldn’t be hard to spruce up or print in different colors. Following the example, this would make a reasonable core for a custom keyboard peripheral that used exotic keys instead of a rotary encoder.

Knobs can be simple or complex. If you want our take on the odd volume control, we used sonar.

DIY Macro Keyboard Wood Be Nice

Editing video tends to involve a lot of keyboard shortcuts, and while this might be fine for the occasional edit, those who regularly deal with video often reach for a macro pad to streamline their workflow. There are plenty of macro keyboards available specifically meant to meet the needs of those who edit a lot of video, but if you want something tailored for your personal workflow you may want to design your own keyboard like this wooden macro pad from [SS4H].

The keyboard itself is built around an STM32 microcontroller, which gives it plenty of power to drive and read the keyboard matrix. It also handles an encoder that is typically included on macro keyboards for video editing, but rather than using a potentiometer-type encoder this one uses a magnetic rotary encoder for accuracy and reliability. There’s a display built into the keyboard as well with its own on-board microcontroller that needs to be programmed separately, but with everything assembled it looks like a professional offering.

[SS4H] built a prototype using 3D printed parts, but for the final version he created one with a wooden case and laser etched keys to add a bit of uniqueness to the build. He also open-sourced all of the PCB schematics and other files needed to recreate this build so anyone can make it if they’d like. It’s not the only macro keyboard we’ve seen before, either, so if you’re looking for something even more esoteric take a look at this keyboard designed to be operated by foot.

Continue reading “DIY Macro Keyboard Wood Be Nice”

All About USB-C: Resistors And Emarkers

If you’ve been following along our USB-C saga, you know that the CC wire in the USB-C cables is used for communications and polarity detection. However, what’s not as widely known is that there are two protocols used in USB-C for communications – an analog one and a digital one. Today, let’s look at the analog signalling used in USB-C – in part, learn more about the fabled 5.1 kΩ resistors and how they work. We’ll also learn about emarkers and the mysterious entity that is VCONN!

USB-C power supply expects to sense a certain value pulldown on the CC line before it provides 5 V on VBUS, and any higher voltages have to be negotiated digitally. The PSU, be it your laptop’s port or a charger, can detect the pulldown (known as Rd) because it keeps a pullup (known as Rp) on the CC line – it then checks if a voltage divider has formed on CC, and whether the resulting voltage is within acceptable range.

If you plug a device that doesn’t make a pulldown accessible through the CC wire in the cable, your device will never get power from a USB-C port, and would only work with a USB-A to USB-C cable. Even the smarter devices that can talk the digital part of USB-C are expected to have pulldowns, it’s just that those pulldowns are internal to the USB-C communication IC used. A USB-C port that wants to receive power needs to have a pulldown.

This part is well-known by now, but we’ve seen lack-of-resistor failures in cheap devices aplenty, and the colloquial advice is “add 5.1 kΩ resistors”. You might be afraid to think it’s so simple, but you’d be surprised. Continue reading “All About USB-C: Resistors And Emarkers”

AIOC: The Ham Radio All-In-One Cable For Audio And APRS

The Ham Radio All-in-one cable (AIOC) is a small PCB attachment for a popular series of radio transceivers which adds a USB-attached audio interface and virtual TTY port for programming and the push-to-talk function. The STM32F373 microcontroller (which, sadly is still hard to find in the usual channels) is a perfect fit for this application, with all the needed hardware resources.

With USB-C connectivity, the AIOC enumerates as a sound card as well as a virtual serial device, so interfacing to practically any host computer should be plug-and-play. Connection to the radio uses 12mm separation 3.5mm and 2.5mm TRS connectors, so is compatible with at least the Baofeng UV-5R but likely many other cheap transceivers that have the same physical setup.

Instructions are provided to use the AIOC with Dire Wolf for easy access to APRS applications, which makes a nice out-of-the-box demo to get you going. APRS is not all about tracking things though since other applications can sit atop the APRS/AX.25 network, for example, HROT: the ham radio of things.

We’ve seen quite a few Baofeng (and related products) hacks, like this sketchy pile of wires allowing one to experiment with the guts of the radio for APRS. Of course, such cheap radio transceivers cut so many engineering corners that there are movements to ban their sale, so maybe a new batch of better radios from our friends in the East is on the horizon?

Thanks to [Hspil] for the tip!

All About USB-C: Illegal Adapters

Let’s be clear – it’s not enough to have USB-C to USB-C cables. There’s a lot of cables that we might want to acquire for our day-to-day use, perhaps, for a transition period while we still own some amount of devices not adorned with a USB-C connector. However, the USB-C specification only accounts for a limited amount of kinds of cables, explicitly or implicitly excluding a range of cables that you might want to buy or make.

It’s my firm belief that, as a hacker, you should be able to buy any USB-C contraption that you could ever need. Hackers don’t need restrictions driven by marketing – they need understanding of how a piece of tech can or cannot be used, based on how it operates internally. I would like you to provide with such understanding, so that you can make informed decisions.

On the other hand, USB-C is designed to be used by less-than-skilled people, even if it often fails at that. (Cable labelling, anyone?) Clear definitions of what complies to a standard can help enforce it. Here’s the notorious story of a USB-C cable that killed a Chromebook, and launched a career of explaining USB-C specifics online for [Benson Leung]. There’s many such failure stories, in fact. Today, we’ll go through USB-C contraptions which might or might not fail you, depending on how you use them. Continue reading “All About USB-C: Illegal Adapters”