USB, Abstracted

Modern technology builds on abstractions. Most application programmers today don’t know what a non-maskable interrupt is, nor should they have to. Even fewer understand register coloring or reservation stations for instruction scheduling, and fewer still can explain the physics behind the transistors in the CPU. Sometimes tech starts out where you need to know everything (programming a bare-metal microprocessor, for example) and then evolves to abstraction. That’s where [WerWolv] wants to get you for writing USB code using the recent post USB for Software Developers.

Many USB tutorials assume you want to know about the intricacies of protocol negotiation, information about the hardware layer, and that you are willing to write a Linux kernel module to provide a driver. But thanks to abstraction, none of this has been absolutely necessary for many use cases for a long time.

While the post focuses on Linux, there is libusb for Windows. We presume the same principles would apply, more or less.

Continue reading “USB, Abstracted”

Drawing Tablet Controls Laser In Real-Time

Some projects need no complicated use case to justify their development, and so it was with [Janne]’s BeamInk, which mashes a Wacom pen tablet with an xTool F1 laser engraver with the help of a little digital glue. For what purpose? So one can use a digital pen to draw with a laser in real time, of course!

Pen events from the drawing tablet get translated into a stream of G-code that controls laser state and power.

Here’s how it works: a Python script grabs events from a USB drawing tablet via evdev (the Linux kernel’s event device, which allows user programs to read raw device events), scales the tablet size to the laser’s working area, and turns pen events into a stream of laser power and movement G-code. The result? Draw on tablet, receive laser engraving.

It’s a playful project, but it also exists as a highly modular concept that can be adapted to different uses. If you’re looking at this and sensing a visit from the Good Ideas Fairy, check out the GitHub repository for more technical details plus tips for adapting it to other hardware.

We’re reminded of past projects like a laser cutter with Etch-a-Sketch controls as well as an attempt to turn pen marks into laser cuts, but something about using a drawing tablet for real-time laser control makes this stand on its own.

Powering USB Devices With A Bench Supply Adapter Board

Sometimes you wanna test a piece of USB hardware, but you don’t just want to plug it into a random old phone charger. [KS-Elektronikdesign] has whipped up a useful tool for just that case, allowing one to easily power USB hardware from a common bench supply.

It would have been simple enough to whip up an adapter board to connect banana jacks to the power pins of a regular USB port. Easing the hookup process was indeed a part of the motivation for this project, in making it easy to power hardware that hooks up via USB-A and USB-C. However, it also goes a little further. It includes TUSB319 chip to handle the all-important power negotiation, without which many USB devices will not feel confident drawing their required amount of current.

There is also polarity protection and over-voltage protection to stop you from blowing stuff up if you hook the board up wrong, which might save you a smartphone or three in the lab. The board will allow negotiated output power up to 10 W via USB-A and 15 W via USB-C, which isn’t heaps, but will be fine for lots of smaller devices. You can up that to 25 W and 35 W respectively if the board is switched to pass-through mode. We particularly like the physical design—the board will plug straight into the banana plugs on any supply with a jack spacing of 19 to 23 mm.

Overall, this is a useful tool to have in the lab if you want to run USB hardware with the flexibility of the voltage and current limits available on your bench supply. There are other ways to power modern USB devices, too, and you can do all kinds of wild stuff if you learn about USB PD and USB PPS. If you’re working up your own nifty lab tools for similar purposes, we’d love to know about it on the tipsline.

Linux Hotplug Events Explained

There was a time when Linux was much simpler. You’d load a driver, it would find your device at boot up, or it wouldn’t. That was it. Now, though, people plug and unplug USB devices all the time and expect the system to react appropriately. [Arcanenibble] explains all “the gory details” about what really happens when you plug or unplug a device.

You might think, “Oh, libusb handles that.” But, of course, it doesn’t do the actual work. In fact, there are two possible backends: netlink or udev. However, the libusb developers strongly recommend udev. Turns out, udev also depends on netlink underneath, so if you use udev, you are sort of using netlink anyway.

If netlink sounds familiar, it is a generic BSD-socket-like API the kernel can use to send notifications to userspace. The post shows example code for listening to kernel event messages via netlink, just like udev does.

When udev sees a device add message from netlink, it resends a related udev message using… netlink! Turns out, netlink can send messages between two userspace programs, not just between the kernel and userspace. That means that the code to read udev events isn’t much different from the netlink example.

The next hoop is the udev event format. It uses a version number, but it seems stable at version 0xfeedcafe. Part of the structure contains a hash code that allows a bloom filter to quickly weed out uninteresting events, at least most of the time.

The post documents much of the obscure inner workings of USB hotplug events. However, there are some security nuances that aren’t clear. If you can explain them, we bet [Arcanenibble] would like to hear from you.

If you like digging into the Linux kernel and its friends, you might want to try creating kernel modules. If you get overwhelmed trying to read the kernel source, maybe go back a few versions.

Easily Replaceable USB-C Port Spawned By EU Laws

The USB-C port has become a defacto connectivity standard for modern devices, largely supplanting the ugly mess of barrel jacks and micro USB connectors that once cursed us. While their reliability is good, they don’t last forever, and can be a pain to replace in most devices if they do fail. However, a new part from JAE Electronics could change that.

The problem with replacing USB connectors in most hardware is that they’re soldered in place. To swap them out, you have to master both desoldering and soldering leads of a rather fine pitch. It’s all rather messy. In the interest of satisfying the EU’s new Ecodesign for Sustainable Products Regulation (ESPR), JAE Electronics has developed a USB-C connector that’s easier to replace. Rather than being soldered in, the part is simply clamped down on to a printed circuit board with small screws. As the part is torqued down, small gold-plated contacts are compressed into pads on the PCB to make the necessary contact.

The connector is fully compatible with USB 4 version 2.0. (Don’t ask us how they number these things anymore.) It comes in single and dual connector versions, and is capable of USB PD EPR at up to 240 W (5A/48V). The part does have some drawbacks—namely, the footprint of the metal-shelled part is somewhat larger than most soldered USB C connectors. Whether this precludes its use is very much an application-specific matter for product engineers to decide.

In any case, if you find yourself designing hardware with heavily-used USB C ports, you might find this part useful. It’s not widely available yet, but some parts should be landing at Mouser in coming months. We’ve explored some of the ways USB-C connectors can be fouled and damaged before, too. Sound off with your opinions on this new part in the comments.

Continue reading “Easily Replaceable USB-C Port Spawned By EU Laws”

The Best USB To VGA Converter For The Job

There are many adapters, dongles, and cables designed for interfacing display standards, and no doubt some of you have them in the glue of your entertainment system or work space. They’re great for standards, but what about something that’s not quite standard? [Stephen] has an arcade cabinet with a CRT that runs at an unusual 336 by 262 pixel resolution. It can be driven as 320 by 240 but doesn’t look great, and even that “standard” resolution isn’t supported by many dongles. He’s shared the story of his path to a unique USB to VGA converter which may have application far beyond this arcade machine.

We follow him on a path of discovery, through RP2040 PIOs, simple resistor ladder DACs, and home-made kernel modules, before he arrives at GUD, a USB display protocol with its own upstreamed Linux kernel driver. It’s designed to be used with a Raspberry PI deriving an LCD or HDMI display, but for his task he implemented the protocol on one of the more expensive STM32 series microcontrollers. The result after several false starts and some fiendish PCB routing is a standalone GUD-based USB-to-VGA converter that delivers perfect 34-bit colour at this unusual resolution, and also presumably others if required. It’s a worthwhile read for the many hints it gives on the subject of driving displays, even if you’re not driving an odd cabinet monitor.

USB Video Capture Devices: Wow! They’re All Bad!!

[VWestlife] purchased all kinds of USB video capture devices — many of them from the early 2000s — and put them through their paces in trying to digitize VHS classics like Instant Fireplace and Buying an Auxiliary Sailboat. The results were actually quite varied, but almost universally bad. They all worked, but they also brought unpleasant artifacts and side effects when it came to the final results. Sure, the analog source isn’t always the highest quality, but could it really be this hard to digitize a VHS tape?

Continue reading “USB Video Capture Devices: Wow! They’re All Bad!!”