Here’s How To Build A Tiny Compiler From Scratch

Believe it or not, building a tiny compiler from scratch can be as fun as it is accessible. [James Smith] demonstrates by making a tiny compiler for an extremely simple programming language, and showing off a hello world.

Here’s what happens with a compiler: human-written code gets compiled into low-level machine code, creating a natively-executable result for a particular processor. [James]’ compiler — created from scratch — makes native x64 Linux ELF binary executables with no dependencies, an experience [James] found both educational and enjoyable. The GitHub repository linked below has everything one needs, but [James] also wrote a book, From Source Code to Machine Code, which he offers for sale to anyone who wants to step through the nitty-gritty.

The (very tiny) compiler is on GitHub as The Pretty Laughable Programming Language. It’s tiny, the only data types are integers and pointers, and all it can do is make Linux syscalls — but it’s sufficient to make a program with. Here’s what the code for “Hello world!” looks like before being fed into the compiler:

; the write() syscall:
; ssize_t write(int fd, const void *buf, size_t count);
(syscall 1 1 "Hello world!\n" 13)
0

Working at such a low level can be rewarding, but back in the day the first computers actually relied on humans to be compilers. Operators would work with pencil and paper to convert programs into machine code, and you can get a taste of that with a project that re-creates what it was like to program a computer using just a few buttons as inputs.

Learn How Impossibly Close-fitting Parts Are Actually Made

Most of us have seen those demonstrations of metal parts that mate together so finely that, once together, they have no visible seam at all. But how, exactly, is this done? [Steve Mould] has a video that shows and explains all, and we’ve never seen the process explained quite like he does.

The secret ingredient is wire EDM, or Electrical Discharge Machining, but that’s only one part of the whole. Wire EDM works a bit like a hot-wire cutter slicing through foam, but all by itself that’s not enough to produce those impossibly close-fitting parts we love to see.

EDM is capable of astounding precision in part because — unlike a cutting tool — nothing physically contacts the material. Also, there isn’t a lot of friction and heat causing small distortions of the material during the machining process. EDM is as a result capable of fantastically-precise cuts, but not invisible ones.

It’s pretty neat to see a water jet used to thread the fine wire through the workpiece.

In all good manufacturing, the capabilities (and limitations) of the tool are taken into account, and this is also true for making those close-fitting pieces. The hole and plug are actually made in two separate stages.

The hole is cut separately from the plug, and because EDM is capable of such finesse, the cuts can be made in such a way that they complement one another with near-perfection. After that, grinding and polishing takes care of the surface finish. The result is the fantastically-smooth and apparently seamless fitment we like so much.

The video is embedded below, and there are some great details about EDM and how it actually works in there. For example, we see how a wire EDM machine can use a jet of water to help thread the wire through a hole in the part to start a job, and we learn that the wire is constantly moving during the process.

As cool as wire EDM is, it is not magic and we’ve seen some pretty remarkable efforts at bringing the technology into the home workshop.
Continue reading “Learn How Impossibly Close-fitting Parts Are Actually Made”

MIDI Interface For NeXTcube Plugs Into The Past

[Joren] recently did some work as part of an electronic music heritage project, and restored an 80s-era NeXTcube workstation complete with vintage sound card, setting it up with a copy of MAX, a graphical music programming environment. But there was one piece missing: MIDI. [Joren] didn’t let that stop him, and successfully created hardware to allow MIDI input and output.

The new panel provides all the connectors necessary to interface with either classic MIDI devices, or MIDI over USB (where it appears as a USB MIDI device to any modern OS.)

Interestingly, the soundcard for the NeXTcube has an RS-422 serial port and some 8-pin mini DIN connectors. They are not compatible with standard MIDI signals, but they’re not far off, either.

To solve this, [Joren] used a Teensy developer board to act as an interface between classic MIDI devices like keyboards or synthesizers (or even not-so-common ones like this strange instrument) while also being able to accommodate modern MIDI over USB connections thanks to the Teensy’s USB MIDI functionality.

A metal enclosure with a 3D-printed panel rounds out the device, restoring a critical piece of functionality to the electronic music-oriented workstation.

MIDI as a protocol isn’t technically limited to musical applications, though that’s one place it shines. And just in case it comes in handy someday, you can send MIDI over I2C if you really need to.

DIY Programmable Guitar Pedal Rocks The Studio & Stage

Ever wondered how to approach making your own digital guitar effects pedal? [Steven Hazel] and a friend have done exactly that, using an Adafruit Feather M4 Express board and a Teensy Audio Adapter board together to create a DIY programmable digital unit that looks ready to drop into an enclosure and get put right to work in the studio or on the stage.

The bulk of the work is done with two parts, and can be prototyped easily on a breadboard.

[Steven] also made a custom PCB to mount everything, including all the right connectors, but the device can be up and running with not much more than the two main parts and a breadboard.

On the inside, the Adafruit Feather M4 Express board works with the audio board over I2S, a standard for sending serial digital audio between chips. Working with the audio itself is done with the Teensy Audio Library, providing a fantastic array of easy-to-use functions for processing and manipulating digital audio streams.

Together, all the right pieces are in place and [Steven] provides the code for a simple tremolo effect as a glimpse of what’s possible with the unit. Interested in going a bit further? [Steven] shares additional details about what’s involved in writing a custom effect from scratch using the Teensy Audio Library.

As mentioned, I2S is where it’s at when it comes to working with digital audio at the chip level, and our own Jenny List can tell you everything you need to know about I2S, a useful protocol that has actually been around since 1982!

Remembering Virginia Norwood, Mother Of NASA’s Landsat Success

Virginia T. Norwood passed away earlier this year at the age of 96, and NASA’s farewell to this influential pioneer is a worth a read. Virginia was a brilliant physicist and engineer, and among her other accomplishments, we have her to thank for the ongoing success of the Landsat program, which continues to this day.

The goal of the program was to image land from space for the purpose of resource management. Landsat 1 launched with a Multispectral Scanner System (MSS) that Norwood designed to fulfill this task. Multispectral imaging was being done from aircraft at the time, but capturing this data from space — not to mention deciding which wavelengths to capture — and getting it back down to Earth required solving a whole lot of new and difficult problems.

Continue reading “Remembering Virginia Norwood, Mother Of NASA’s Landsat Success”

Passively Generating Power Day And Night Takes The Right Parts

A thermoelectric generator (TEG) can turn a temperature difference into electricity, and while temperature differentials abound in our environment, it’s been difficult to harness them into practical and stable sources of power. But researchers in China have succeeded in creating a TEG that can passively and continuously generate power, even across shifting environmental conditions. It’s not a lot of power, but that it’s continuous is significant, and it could be enough for remote sensors or similar devices.

Historically, passive TEGs have used ambient air as the “hot” side and some form of high-emissivity heat sink — usually involving exotic materials and processes — as the “cold” side. These devices work, but fail to reliably produce uninterrupted voltage because shifting environmental conditions have too great of an effect on how well the radiative cooling emitter (RCE) can function.

The black disk (UBSA) heats the bottom while the grey square (RCE) radiates heat away, ensuring a workable temperature differential across a variety of conditions.

Here is what has changed: since a TEG works on temperature difference between the hot and cold sides, researchers improved performance by attaching an ultra-broadband solar absorber (UBSA) to the hot side, and an RCE to the cold side. The UBSA is very good at absorbing radiation (like sunlight) and turning it into heat, and the RCE is very good at radiating heat away. Together, this ensures enough of temperature difference for the TEG to function in bright sunlight, cloudy sunlight, clear nighttime, and everything in between.

As mentioned, it’s not a lot of power (we’re talking millivolts) but the ability to passively and constantly produce across shifting environmental conditions is something new. And as a bonus, the researchers even found a novel way to create both UBSA and RCE using non-exotic materials and processes. The research paper with additional details is available here.

The ability to deliver uninterrupted power — even in tiny amounts — is a compelling goal. A few years ago we encountered a (much larger) device from a team at MIT that also aimed to turn environmental temperature fluctuations into a trickle of constant power. Their “Thermal Resonator” worked by storing heat in phase-change materials that would slowly move heat across a TEG, effectively generating continuously by stretching temperature changes out over time.

Launching Paper Planes From Way, Waaaaaay Up

Every now and again we stumble across something a bit unexpected, and today that’s the fact that there have been quite a few efforts at launching paper planes from as close to space as possible. The current record for the highest paper plane launch is a whopping altitude of 35,043 meters.

That altitude is considerably short of what would be called “space”, but it’s still an awfully long way up and the air there is very thin compared to on the surface. Space is generally (but not universally) considered to be beyond 100 km above sea level, a human-chosen boundary known as the Kármán line. 35 km is a long ways into the stratosphere, but still within Earth’s atmosphere.

Even so, that doesn’t mean there haven’t been efforts to go considerably higher. There was a Japanese proposal to drop airplanes made from special heat-resistant paper from the International Space Station, roughly 400 km above Earth. Success would show that low-speed, low-friction atmospheric reentry is feasible — for pieces of paper, anyway. But one of the challenges is the fact that there is no practical way to track such objects on their way down, and therefore no way to determine where or when they would eventually land.

There have been many other high-altitude paper plane launches, but the current record of 35,043 meters was accomplished by David Green in the United Kingdom as part of a school project. Such altitudes are in the realm of things like weather balloons, and therefore certainly within the reach of hobbyists.

As for the airplanes themselves, the basic design pictured here probably won’t cut it, so why not brush up on designs with the Paper Airplane Design Database? Even if you don’t send them into the stratosphere (or higher), you might find something worth putting through a DIY wind tunnel to see how they perform.