Absolute Encoder Teardown

According to [Lee Teschler], the classic representation of encoders showing code rings is out of date. His post says that most industrial absolute encoders use a special magnetic sensor known as a Wiegand wire to control costs. To demonstrate he does a teardown of an encoder made by Nidec Avtron Automation, and if you’ve ever wondered what’s inside something like this, you enjoy the post.

This is a large industrial unit and when you open it up, you’ll get a surprise. Most of the inside is empty! There is a very small encoder inside. The main body protects the inside and holds the large bearings. The real encoder looks more like a toy car motor than anything else.

The inner can is nearly empty, too. But it does have the part we are interested in. There’s a Melexis Hall effect sensor The Weigand wire is a special magnetic wire with an outer sheath that is resistant to having its magnetic field reversed and an inner core that isn’t. Until an applied magnetic field reaches a certain strength, the wire will stay magnetized in one direction. When the field crosses the threshold, the entire wire changes magnetic polarity rapidly. The effect is independent of the rate of change of the applied magnetic field.

In other words, like old core memory, the wire has strong magnetic hysteresis. Between pulses from the Weigand wire and information from the Hall effect sensor, you can accurately determine the position of the shaft.

It is always amazing to us how many modern pieces of gear are now mostly empty with the size of the device being driven by physical constraints and not the electronics within.

A Rotary Encoder: How Hard Can It Be?

As you may have noticed, I’ve been working with an STM32 ARM CPU using Mbed. There was a time when Mbed was pretty simple, but a lot has changed since it has morphed into Mbed OS. Unfortunately, that means that a lot of libraries and examples you can find don’t work with the newer system.

I needed a rotary encoder — I pulled a cheap one out of one of those “49 boards for Arduino” kits you see around. Not the finest encoder in the land, I’m sure, but it should do the job. Unfortunately, Mbed OS doesn’t have a driver for an encoder and the first few third-party libraries I found either worked via polling or wouldn’t compile with the latest Mbed. Of course, reading an encoder isn’t a mysterious process. How hard can it be to write the code yourself? How hard, indeed. I thought I’d share my code and the process of how I got there.

There are many ways you can read a rotary encoder. Some are probably better than my method. Also, these cheap mechanical encoders are terrible. If you were trying to do precision work, you should probably be looking at a different technology like an optical encoder. I mention this because it is nearly impossible to read one of these flawlessly.

So my goal was simple: I wanted something interrupt driven. Most of what I found required you to periodically call some function or set up a timer interrupt. Then they built a state machine to track the encoder. That’s fine, but it means you eat up a lot of processor just to check in on the encoder even if it isn’t moving. The STM32 CPU can easily interrupt with a pin changes, so that’s what I wanted.

The Catch

The problem is, of course, that mechanical switches bounce. So you have to filter that bounce either in hardware or software. I really didn’t want to put in any extra hardware more than a capacitor, so the software would have to handle it.

I also didn’t want to use any more interrupts than absolutely necessary. The Mbed system makes it easy to handle interrupts, but there is a bit of latency. Actually, after it was all over, I measured the latency and it isn’t that bad — I’ll talk about that a little later. Regardless, I had decided to try to use only a pair of interrupts.

Continue reading “A Rotary Encoder: How Hard Can It Be?”

Electronic leadscrew

Electronic Lead Screws – Not Just For Threading Anymore

An electronic leadscrew is an increasingly popular project for small and mid-sized lathes. They do away with the need to swap gears in and out to achieve the proper ratio between spindle speed and tool carriage translation, and that makes threading a snap. But well-designed electronic leadscrews, like this one from [Hobby Machinist], offer so much more than just easy threading.

The first thing that struck us about this build was the polished, professional look of it. The enclosure for the Nucleo-64 dev board sports a nice TFT display and an IP65-rated keyboard, as well as a beefy-looking jog wheel. The spindle speed is monitored by a 600 pulses-per-revolution optical encoder, and the lathe’s leadscrew is powered by a closed-loop NEMA 24 stepper. This combination allows for the basic threading operations, but the addition of a powered cross slide opens up a ton more functionality. Internal and external tapers are a few keypresses away, as are boring and turning and radius operations, both on the right and on the left. The video below shows radius-cutting operations combined to turn a sphere.

From [Hobby Machinist]’s to-do list, it looks like filleting and grooving will be added someday, as will a G-code parser and controller to make this into a bolt-on CNC controller. Inspiration for the build is said to have come in part from [Clough42]’s electronic leadscrew project from a few years back. Continue reading “Electronic Lead Screws – Not Just For Threading Anymore”

Slick Keyboard Built With PCB Magic

Sometimes a chance conversation leads you to discover something cool you’ve not seen before, and before you know it, you’re ordering parts for yet another hardware build. That’s what happened to this scribe the other day when chatting on some random discord, to QMK maintainer [Nick Brassel aka tzarc] about Djinn, a gorgeous 64-key split mechanical keyboard testbed. It’s a testbed because it uses the newest STM32G4x microcontroller family, and QMK currently does not have support for this in the mainline release. For the time being, [Nick] maintains a custom release, until it gets merged.

Hardware-wise, the design is fabulous, with a lot of attention to detail. We have individual per-key RGB LEDs, RGB underglow, a rotary encoder, a five-way tactile thumb switch, and a 240×320 LCD per half. The keyboard is based on a three PCB stack, two of which are there purely for structure. This slick design has enough features to keep a fair few of us happy.

Interestingly, when you look at the design files (KiCAD, naturally) [Nick] has chosen to take a mirrored approach to the PCB. That means the left and right sides are actually the same PCB layout. The components are populated on different sides of the PCB depending on which half you’re looking at! By mirroring footprints on both PCB sides, and hooking everything up in parallel, it’s possible to do it all with a single master layout.

This is a simple but genius idea that this scribe hadn’t come across before (the shame!) Secondarily it keeps costs down, as your typical Chinese prototyping house will not deal in PCB quantities below five, so you can make two complete keyboards on one order, rather than needing two orders to make five. (Yes, there are actually three unique PCBs, but we’re simplifying the situation, ok?)

Now, if only this pesky electronics shortage could abate a bit, and we could get the parts to build this beauty!

Obviously, we’ve covered many, many keyboards over the years. Here’s our own [Kristina’s] column all about the things. If you need a little help with your typing skills, this shocking example may be the one for you. If your taste is proper old-school clackers, there’s something for everyone.

Magnetic Angle Sensor Mods Make Encoder Better For Blasting

Most of the hacks we see around these parts have to do with taking existing components and cobbling them together in interesting new ways. It’s less often that we see existing components gutted and repurposed, but when it happens, like with this reimagined rotary encoder, it certainly grabs our attention.

You may recall [Chris G] from his recent laser-based Asteroids game. If not you should really check it out — the build was pretty sweet. One small problem with the build was in the controls, where the off-the-shelf rotary encoder he was using didn’t have nearly enough resolution for the job. Rather than choosing a commodity replacement part, [Chris] rolled his own from the mechanical parts of the original encoder, like the shaft and panel bushing, and an AS5048A sensor board. The magnetic angle sensor has 14 bits of resolution, and with a small neodymium ring magnet glued to the bottom of the original shaft, the modified encoder offers far greater resolution than the original contact-based encoder.

The sensor breakout board is just the right size for this job; all that [Chris] needed to do to get the two pieces together was to 3D-print a small adapter. We have to admit that when we first saw this on Hackaday.io, we failed to see what the hack was — the modified part looks pretty much like a run-of-the-mill encoder. The video below shows the design and build process with a little precision rock blasting.

Continue reading “Magnetic Angle Sensor Mods Make Encoder Better For Blasting”

Uncommon Bárány Chair Gets Fixed Up

Ever heard of a Bárány chair? Neither had [Troy Denton] before he was asked to repair one, but that didn’t stop him from rolling up his sleeves and tying to get the non-functional device back in working order. As it didn’t come with a user guide, manual, schematic or any other information, he had to rely on his experience and acumen gathered over years of practical work. Luckily for us, he decided to document the whole process.

While it’s not well known outside of aviation circles, the Bárány chair is an important piece of equipment in training pilots to get used to spatial disorientation. The device is essentially a motorized revolving chair, the idea being to spin the subject to induce disorientation. Rotation speed and direction can be controlled via a handheld wireless remote terminal.

When [Troy] first powered it up, the error code on the remote indicated “no power to base unit”. That turned out to be a quick fix – he simply had to move the power connection from a switched socket that had been turned off to a different outlet. But while that cleared the error message, the chair still wouldn’t rotate for any of the knob settings.

Manually rotating the chair showed the RPM on the remote, so [Troy] narrowed down his search to the motor related sections. The motor was being driven by a servo type signal, but changing the speed and direction knob on the remote didn’t seem to alter the control signal when he checked it with his scope. Opening up the hand held remote immediately uncovered the failed part – the rotary encoder for setting the speed and direction had physically split in to two pieces.

Since there was a clean split in the encoder, he was able to temporarily hold it back together to confirm that the chair could spin up. The cause was most likely “User Error” – the last person to conduct the test probably turned the knob rather enthusiastically. A new part is on the way, and the chair should be getting back to making prospective pilots dizzy in no time.

We love a good repair story here at Hackaday. Whether it’s patiently rebuilding a snapped PCB with bodge wires or coming up with replacement parts that may well be better than the originals, we never get tired of seeing a broken piece of gear put back together.

Continue reading “Uncommon Bárány Chair Gets Fixed Up”

Decoding The Netflix Announcement: Explaining Optimized Shot-Based Encoding For 4K

Netflix has recently announced that they now stream optimized shot-based encoding content for 4K. When I read that news title I though to myself: “Well, that’s great! Sounds good but… what exactly does that mean? And what’s shot-based encoding anyway?”

These questions were basically how I ended up in the rabbit hole of the permanent encoding optimization history, in an effort to thoroughly dissect the above sentences and properly understand it, so I can share it with you. Before I get into it, lets take a trip down memory lane. Continue reading “Decoding The Netflix Announcement: Explaining Optimized Shot-Based Encoding For 4K”