Introduction
The ZX Spectrum, introduced in 1982, shaped an era of affordable home computing. Today, more than four decades later, this classic Z80-based machine has been reimagined as a frequency counter capable of measuring signals up to 20 kHz.
This transformation is part of Hackaday’s annual One Hertz Challenge, which asks makers to build devices that perform an operation exactly once per second. Hobbyist Tito successfully converted the Spectrum into a measurement tool that counts signal pulses during a one-second interval. The result demonstrates how thoughtful low-level programming can revive hardware long considered obsolete (hackaday.com).
This article examines the details of the project, the technical implementation, historical context, and its significance for the maker community.
The One Hertz Challenge
The Hackaday One Hertz Challenge sets a straightforward theme: perform a measurable action every second. This simplicity conceals the creative and technical range of the entries, which include LED blinkers, logic analyzers, and timing-based instruments.
In an era when modern microcontrollers with abundant peripherals are readily available, most participants opt for boards such as the ESP32 or STM32. Tito, however, embraced retrocomputing by selecting a ZX Spectrum, driven by a Zilog Z80 CPU running at 3.5 MHz and limited to 48 KB of RAM. This choice introduced both constraints and opportunities for optimization at the instruction level.
Converting a ZX Spectrum into Test Equipment
Frequency counters measure the oscillation rate of a signal in cycles per second. Standard designs use timers and hardware interrupts. Tito’s implementation achieves the same objective entirely in software by counting the number of rising edges received through the EAR port during a one-second window.
Why the EAR Port?
The EAR port, designed for reading audio from cassette tapes, provides digital transitions suitable for edge detection. Its advantages include:
- Availability on all Spectrum models without modification
- Simple integration with external signal sources
- Direct access via Z80 I/O port 254, bit 6
The hardware remains unaltered, making the hack fully reversible and non-destructive.
Hardware Setup
The physical requirements for the project are minimal:
- A ZX Spectrum 48K or later model
- A periodic signal source within TTL voltage limits
- A cable to feed the signal into the EAR jack
- A BASIC loader to initiate machine code execution
No soldering or custom boards are necessary, which maintains the machine’s originality while giving it new purpose.
Z80 Assembly: Core Logic
The software routine is compact, efficient, and assembled using ZASM. Its design rests on three main loops:
- Initialization
- HL register pair holds the pulse count
- BC register pair tracks elapsed cycles for the one-second interval
- Edge Detection
- Poll I/O port 254 using IN A,(254)
- Apply a mask to isolate bit 6 using BIT 6,A
- Increment HL on each rising transition
- Timing Control
- Decrement BC on each iteration
- When BC reaches zero, one second has elapsed
- Display Update
- Convert HL from binary to decimal
- Print result to the Spectrum display
This method demonstrates how careful cycle counting can substitute for hardware timers in systems where they do not exist.
Accuracy and Calibration
Timing accuracy depends on the Spectrum’s 3.5 MHz clock and precise calculation of instruction cycles. By tuning the loop to consume a fixed number of cycles, the program achieves a one-second interval within a small error margin. This approach recalls early embedded systems design, where developers achieved real-time control by counting cycles rather than relying on dedicated timers.
Practical Performance
The frequency counter achieves reliable readings from 1 Hz up to approximately 20 kHz. Beyond this range, sampling limitations increase the chance of missed edges. The results update once per second, which meets the criteria for the Hackaday challenge while keeping the logic simple.
Although the design cannot compete with dedicated counters in terms of resolution or range, it offers an elegant proof of concept for resource-constrained systems.
Historical Context
In the 1980s, repurposing home computers for technical tasks was common among electronics hobbyists. Magazines often published guides for turning 8-bit machines into oscilloscopes or data loggers using minimal hardware additions. Tito’s work continues this tradition, but with modern insight and tools that make the process more precise and accessible.
By publishing the project on Hackaday.io, Tito also contributes to a global knowledge base that keeps the retrocomputing spirit alive. Unlike commercial ecosystems that hide implementation details, projects like these share everything from theory to code.
Open Source Distribution
The project includes:
- Full Z80 assembly source code
- A BASIC loader for tape-based execution
- A .tzx image for emulators or original hardware
- Documentation detailing timing calibration and test results
This transparency invites community contributions such as feature improvements, alternative user interfaces, and expanded signal range through optimization.
Future Enhancements
Several enhancements could make the ZX Spectrum frequency counter more versatile:
- Adjustable gate times for higher resolution at low frequencies
- Interrupt-driven counting for improved accuracy
- Data logging over a serial interface
- Graphical visualization on the Spectrum screen
These additions would transform a simple hack into a serious diagnostic tool for electronics enthusiasts.
Broader Lessons
This project demonstrates key engineering principles that remain relevant:
- Constraints drive innovation
Working within the limits of 1980s hardware forces creative thinking and algorithmic efficiency. - Software can extend hardware life
Code compensates for missing features, adding functionality without altering the original system. - Hands-on learning matters
Programming at the assembly level strengthens understanding of timing, state management, and I/O control.
Cultural Impact
Retrocomputing remains popular not only for nostalgia but also for education. Projects like Tito’s frequency counter transform static artifacts into working tools, bridging the gap between historical appreciation and contemporary application. The ZX Spectrum, once synonymous with gaming, now proves capable of participating in a modern maker challenge that celebrates ingenuity over raw processing power.
Conclusion
Repurposing a ZX Spectrum as a Z80-based frequency counter aligns perfectly with the One Hertz Challenge theme. It combines precision timing, assembly-level optimization, and creative adaptation of legacy hardware. While the same functionality could be achieved with a modern microcontroller in a few lines of code, the real value lies in the process: learning, experimenting, and pushing the boundaries of what classic systems can achieve.
Tito’s project underscores a timeless truth in computing: old machines do not lose relevance when curiosity and technical skill remain in play. As long as there are challenges like these, the ZX Spectrum will continue to surprise us.
Works Cited
Day, Lewin. “2025 One Hertz Challenge: ZX Spectrum Is Now a Z80 Frequency Counter.” Hackaday, 18 July 2025, https://hackaday.com/2025/07/18/2025-one-hertz-challenge-zx-spectrum-is-now-a-z80-frequency-counter/.
Tito. “Z80 Frequency Counter on a ZX Spectrum.” Hackaday.io, 15 July 2025, https://hackaday.io/project/203522-z80-frequency-counter-on-a-zx-spectrum.
“One Hertz Challenge 2025.” Hackaday, July 2025, https://hackaday.com/tag/2025-hackaday-one-hertz-challenge/.