ZX Spectrum Lands Spaceship Using 1982 Tech

A 1982 Sinclair ZX Spectrum computer has successfully guided a simulated spacecraft to a lunar landing. Using a combination of emulation, serial communication, and a Python intermediary, the vintage machine controlled a lander in Kerbal Space Program. The project highlights the capabilities of early hardware and the dramatic progress in computing power.

3 hours ago
5 min read

ZX Spectrum Lands Spaceship Using 1982 Tech

A Sinclair ZX Spectrum computer from 1982 has successfully guided a simulated spacecraft to a lunar landing. This remarkable feat was achieved by connecting the vintage computer to a modern simulation, proving that even humble early hardware can perform complex tasks with the right setup. The experiment highlights the ingenuity of early computing and the vast power of today’s technology.

Bridging Decades of Computing Power

The project used a ZX Spectrum 48K, a low-cost color computer that was a staple for many young programmers in 1980s Britain. For the experiment, the computer’s onboard processor, running at a modest 3.9 MHz, was tasked with controlling a simulated lander in the popular space game Kerbal Space Program. This was made possible through emulation software that allowed the ZX Spectrum to communicate with the modern simulation.

To connect the 1982 hardware to the 21st-century simulation, a crucial piece of add-on hardware was needed: the ZX Interface 1. Released shortly after the Spectrum, this interface provided an RS232 serial port, a standard way for computers to communicate. This port allowed the emulator to send and receive data, acting as a bridge between the old and the new.

The Intermediary: Python and Kerbal RPC

Since Kerbal Space Program does not natively support serial port connections, an intermediary program was developed. This program, written in Python, utilized the Kerbal Remote Procedure Call (RPC) mod.

This mod allows external programs to control the spacecraft and read its status. The Python script acted as the central hub, receiving data from the Kerbal simulation, processing it, and sending commands back to the ZX Spectrum emulator.

The ZX Spectrum, in turn, ran a program written in Sinclair BASIC. This program read data from the serial port, such as altitude, speed, and thrust-to-weight ratio.

It then calculated the necessary adjustments for attitude and throttle to manage the descent. The data was then sent back across the serial port to the Python script, completing the control loop.

Challenges of “Bit Banging”

The process was far from seamless due to the limitations of the ZX Spectrum’s hardware and its BASIC programming language. The computer’s CPU had to directly control the serial port’s data flow, a technique known as “bit banging.” This meant the CPU spent a significant amount of time simply sending and receiving individual bits of data. This intensive processing caused noticeable delays, or lag, between when data was sent and when the simulation responded.

The ZX Spectrum’s 3.9 MHz processor was busy waiting for data, spending thousands of instructions to read a single bit. This led to updates occurring only about once every second, with potential lags of up to two seconds. While this might seem like a long time for a spacecraft hurtling towards the moon, it was noted that the Apollo Guidance Computer also operated on a slow cycle, around two seconds.

A Nod to Apollo’s Legacy

The experiment drew parallels to the Apollo missions, specifically the Apollo Guidance Computer (AGC). While the AGC was slow by today’s standards, it was part of a complex system with dedicated processors for different tasks.

The ZX Spectrum, by contrast, had to handle everything itself, including the direct control of the serial port. This meant the Spectrum’s BASIC program was doing all the heavy lifting, a far cry from the specialized hardware available during the Apollo era.

Despite the performance limitations, the ZX Spectrum’s program was designed to maintain a balance. It aimed to keep deceleration times equal to impact times, using a conservative 50% thrust to allow for engine failures or bad data. This careful approach helped to prevent the system from becoming desynchronized and crashing.

The Landing Sequence

As the simulated lander approached the lunar surface, the ZX Spectrum program transitioned into its landing mode. The goal was to achieve a vertical descent between 100 and 30 meters above the surface, with minimal sideways velocity. The experiment showed the lander touching down on a relatively flat area, with a slight overshoot in deceleration.

The system then used smaller thrust adjustments to ensure a controlled descent without wasting fuel. The lander eventually touched down, its engine shut down, and the program stopped. The victory was clear: a spacecraft had been landed on the moon using a 1982 Sinclair BASIC program communicating over a serial port.

Reflections on Nostalgia and Pain

The programmer described returning to ZX Spectrum BASIC as initially nostalgic but quickly becoming “incredible amounts of pain.” The complex keyboard, where each key had multiple functions, made coding difficult. For instance, closing a serial port that had been left open after a crash required a complex sequence of key presses involving shift modes and specific number inputs.

He noted that while the ZX Spectrum’s 3.9 MHz processor might seem slow, with the right peripherals and assembly language programming, it might be possible to achieve more. However, the experiment intentionally used BASIC to highlight the hardware’s limitations. The goal was not to push the Spectrum to its absolute limit, but to demonstrate what was possible with this iconic piece of early computing history.

Modern Power vs. Vintage Charm

The experiment also is a clear reminder of how far computing has come. A modern smartphone, for instance, is thousands of times more powerful than the AGC that landed humans on the moon. Even the charger for a smartphone can contain a CPU more powerful than the AGC, capable of negotiating power delivery with USB-C devices.

This success with the ZX Spectrum raises the question of what even more ridiculous hardware could be used for future space simulations. The journey from a 1982 microcomputer controlling a lunar lander to the powerful devices we carry today is proof of human innovation.

The next step could involve exploring even simpler or more obscure hardware for similar challenges. The possibilities for creative computing projects remain vast.


Source: Can My First Computer Fly A Spaceship? 1982 ZX Spectrum Flight Computer (YouTube)

Written by

Joshua D. Ovidiu

I enjoy writing.

17,165 articles published
Leave a Comment