ESP32 Hosts Functional Minecraft Server

If you haven’t heard of Minecraft, well, we hope you enjoyed your rip-van-winkle nap this past decade or so. For everyone else, you probably at least know that this is a multiplayer, open world game, you may have heard that running a Minecraft server is a good job for maxing out a spare a Raspberry Pi. Which is why we’re hugely impressed that [PortalRunner] managed to squeeze an open world onto an ESP32-C3.

Of course, the trick here is that the MCU isn’t actually running the game — it’s running bareiron, [PortalRunner]’s own C-based Minecraft server implementation. Rewriting the server code in C allows it to be optimized for the ESP32’s hardware, but it also let [PortalRunner] strip his server down to the bare essentials, and tweak everything for performance. For example, instead of the multiple octaves of perlin noise for terrain generation, with every chunk going into RAM, he’s using the x and z of the corners as seeds for the psudorandom rand() function, and interpolating between them. Instead of caves being generated by a separate algorithm (and stored in memory), in bareiron the underground is just a mirror-image of the world above. Biomes are just tiled, and sit separately from one another.

So yes, what you get from bareiron is simpler than a traditional Minecraft world — items are simplified, crafting is simplified, everything is simplified, but it’s also running on an ESP32, so you’ve got to give it a pass. With 200 ms to load each chunk, it’s playable, but the World’s Smallest Minecraft Server is a bit like a dancing bear: it’s not about how well it dances, but that it dances at all.

This isn’t the first time we’ve seen Minecraft’s server code re-written: some masochist did it in COBOL, but at least that ran on an actual computer, not a microcontroller. Speaking of low performance, you can’t play Minecraft on an SNES, but you can hide the game inside a cartridge, which is almost as good.

Thanks to [CodeAsm] for the tip. Please refer any other dancing bears spotted in the wild to our tips line.

Continue reading “ESP32 Hosts Functional Minecraft Server”

Keep Reading, Keep Watching

I’ve been flying quadcopters a fair bit lately, and trying to learn some new tricks also means crashing them, which inevitably means repairing them. Last weekend, I was working on some wiring that had gotten caught and ripped a pad off of the controller PCB. It wasn’t so bad, because there was a large SMT capacitor nearby, and I could just piggyback on that, but the problem was how to re-route the wires to avoid this happening again.

By luck, I had just watched a video where someone else was building up a new quad, and had elegantly solved the exact same routing problem. I was just watching the video because I was curious about the frame in question, and I had absolutely no idea that it would contain the solution to a problem that I was just about to encounter, but because I was paying attention, it make it all a walk in the park.

I can’t count the number of times that I’ve had this experience: the blind luck of having just read or seen something that solves a problem I’m about to encounter. It’s a great feeling, and it’s one of the reasons that I’ve always read Hackaday – you never know when one hacker’s neat trick is going to be just the one you need next week. Indeed, that’s one of the reasons that we try to feature not just the gonzo hacks that drill down deep on a particular feat, but also the little ones too, that solve something in particular in a neat way. Because reading up on the hacks is free, and particularly cheap insurance against tomorrow’s unexpected dilemmas.

Read more Hackaday!

A lathe is shown on a tabletop. Instead of a normal lathe workspace, there is an XY positioning platform in front of the chuck, with two toolposts mounted on the platform. Stepper motors are mounted on the platform to drive it. The lathe has no tailpiece.

Turning A Milling Machine Into A Lathe

If you’re planning to make a metalworking lathe out of a CNC milling machine, you probably don’t expect getting a position sensor to work to be your biggest challenge. Nevertheless, this was [Anthony Zhang]’s experience. Admittedly, the milling machine’s manufacturer sells a conversion kit, which greatly simplifies the more obviously difficult steps, but getting it to cut threads automatically took a few hacks.

The conversion started with a secondhand Taig MicroMill 2019DSL CNC mill, which was well-priced enough to be purchased specifically for conversion into a lathe. Taig’s conversion kit includes the spindle, tool posts, mounting hardware, and other necessary parts, and the modifications were simple enough to take only a few hours of disassembly and reassembly. The final lathe reuses the motors and control electronics from the CNC, and the milling motor drives the spindle through a set of pulleys. The Y-axis assembly isn’t used, but the X- and Z-axes hold the tool post in front of the spindle.

The biggest difficulty was in getting the spindle indexing sensor working, which was essential for cutting accurate threads. [Anthony] started with Taig’s sensor, but there was no guarantee that it would work with the mill’s motor controller, since it was designed for a lathe controller. Rather than plug it in and hope it worked, he ended up disassembling both the sensor and the controller to reverse-engineer the wiring.

He found that it was an inductive sensor which detected a steel insert in the spindle’s pulley, and that a slight modification to the controller would let the two work together. In the end, however, he decided against using it, since it would have taken up the controller’s entire I/O port. Instead, [Anthony] wired his own I/O connector, which interfaces with a commercial inductive sensor and the end-limit switches. A side benefit was that the new indexing sensor’s mounting didn’t block moving the pulley’s drive belt, as the original had.

The end result was a small, versatile CNC lathe with enough accuracy to cut useful threads with some care. If you aren’t lucky enough to get a Taig to convert, there are quite a few people who’ve built their own CNC lathes, ranging from relatively simple to the extremely advanced.

Design Scanimations In A Snap With The Right Math

Barrier-grid animations (also called scanimations) are a thing most people would recognize on sight, even if they didn’t know what they were called. Move a set of opaque strips over a pattern, and watch as different slices of that image are alternately hidden and revealed, resulting in a simple animation. The tricky part is designing the whole thing — but researchers at MIT designed FabObscura as a design tool capable not only of creating the patterned sheets, but doing so in a way that allows for complex designs.

The barrier grid need not consist of simple straight lines, and movement of the grid can just as easily be a rotation instead of a slide. The system simply takes in the desired frames, a mathematical function describing how the display should behave, and creates the necessary design automatically.

The paper (PDF) has more details, and while it is possible to make highly complex animations with this system, the more frames and the more complex the design, the more prominent the barrier grid and therefore the harder it is to see what’s going on. Still, there are some very nice results, such as the example in the image up top, which shows a coaster that can represent three different drink orders.

We recommend checking out the video (embedded below) which shows off other possibilities like a clock that looks like a hamster wheel, complete with running rodent. It’s reminiscent of this incredibly clever clock that uses a Moiré pattern (a kind of interference pattern between two elements) to reveal numerals as time passes.

We couldn’t find any online demo or repository for FabObscura, but if you know of one, please share it in the comments.

Continue reading “Design Scanimations In A Snap With The Right Math”

Musical Motors, BLDC Edition

This should count as a hack: making music from a thing that should not sing. In this case, [SIROJU] is tickling the ivories with a Brushless DC motor, or BLDC. 

To listen to a performance, jump to 6:27 in the embedded video. This BLDC has a distinctly chip-tune like sound, not entirely unlike other projects that make music with stepper motors. Unlike most stepper-based instruments we’ve seen [SIROJU]’s BLDC isn’t turning as it sings. He’s just got it vibrating by manipulating the space vector modulation that drives the motor — he gets a response of about 10 kHz that way. Not CD-quality, no, but plenty for electronic music. He can even play chords of up to 7 notes at a time.

There’s no obvious reason he couldn’t embed the music into a proper motor-drive signal, and thus allow a drone to hum it’s own theme song as it hovers along. He’s certainly got the chops for it; if you haven’t seen [SIROJU]’s videos on BLDC drivers on YouTube, you should check out his channel. He’s got a lot of deep content about running these ubiquitous motors. Sure, we could have just linked to him showing you how to do FOC on an STM32, but “making it sing” is an expression for mastery in English, and a lot more fun besides.

There are other ways to make music with motors. If you know of any others, don’t hesitate to send us a tip.

Continue reading “Musical Motors, BLDC Edition”

What Is The Fourier Transform?

Over at Quanta Magazine [Shalma Wegsman] asks What Is the Fourier Transform?

[Shalma] begins by telling you a little about Joseph Fourier, the French mathematician with an interest in heat propagation who founded the field of harmonic analysis in the early 1800s.

Fourier’s basic insight was that you can represent everything as a sum of very basic oscillations, where the basic oscillations are sine or cosine functions with certain parameters. [Shalma] explains that the biology of our ear can do a similar thing by picking the various notes out from a tune which is heard, but mathematicians and programmers work without the benefit of evolved resonant hairs and bone, they work with math and code.

[Shalma] explains how frequency components can be discovered by trial and error, multiplying candidate frequencies with the original function to see if there are large peaks, indicating the frequency is a component, or if the variations average to zero, indicating the frequency is not a component. [Shalma] tells how even square waves can be modeled with an infinite set of frequencies known as the Fourier series.

Taking a look at higher-dimensional problems [Shalma] mentions how Fourier transforms can be used for graphical compression by dropping the high frequency detail which our eyes can barely perceive anyway. [Shalma] gives us a fascinating look at the 64 graphical building blocks which can be combined to create any possible 8×8 image.

[Shalma] then mentions James Cooley and John Tukey and the development of the Fast Fourier Transform in the 1960s. This mathematical tool has been employed to study the tides, to detect gravitational waves, to develop radar and magnetic resonance imaging, and to support signal processing and data compression. Even quantum mechanics finds use for harmonic analysis, and [Shalma] explains how it relates to the uncertainty principle. The Fourier transform has spread through pure mathematics and into number theory, too.

[Shalma] closes with a quote from Charles Fefferman: “If people didn’t know about the Fourier transform, I don’t know what percent of math would then disappear, but it would be a big percent.”

If you’re interested in the Fourier transform and want to dive deeper we would encourage you to read The Fastest Fourier Transform In The West and Even Faster Fourier Transforms On The Raspbery Pi Zero.

Header image: Joseph Fourier, Attributed to Pierre-Claude Gautherot, Public domain.

Running Code On A PAX Credit Card Payment Machine

The PAX D177 PoS terminal helpfully tells you which tamper points got triggered. (Credit: Lucas Teske)
The PAX D177 PoS terminal helpfully tells you which tamper points got triggered. (Credit: Lucas Teske)

These days Points of Sale (PoS) usually include a digital payment terminal of some description, some of which are positively small, such as the Mini PoS terminals that PAX sells. Of course, since it has a CPU and a screen it must be hacked to run something else, and maybe discover something fun about the hardware in the process. Thus [Lucas Tuske] set out to do exactly this with a PAX D177 PoS, starting with purchasing three units: one to tear apart, one to bypass tamper protections on and one to keep as intact reference.

As expected, there are a few tamper protections in place, starting with pads that detect when the back cover is removed and a PCB that’s densely covered in fine traces to prevent sneaky drilling. Although tripping the tamper protections does not seem to affect the contents of the Flash, the firmware is signed. Furthermore the secrets like keys that are stored in NVRAM are purged, rendering the device effectively useless to any attacker.

The SoC that forms the brains of the whole operations is the relatively obscure MH1903, which is made by MegaHunt and comes in a dizzying number of variants that are found in applications like these PoS terminals. Fortunately the same SoC is also found on a development board with the AIR105 MCU that turns out to feature the same MH1903 core. These are ARM Cortex-M3 cores, which makes targeting them somewhat easier.

Rather than try to break the secure boot of the existing SoC, [Lucas] opted to replace the SoC package with a brand new one, which was its own adventure. Although one could say that this is cheating, it made getting a PoC of custom code running on one of these devices significantly easier. In a foll0w-up article [Lucas] expects to have Doom running on this device before long.