❌

Reading view

There are new articles available, click to refresh the page.

Calculator UI Is More Complex Than You Might Think

Calculators are so ubiquitous and so familiar that they are easy to take for granted in many different ways. [lcamtuf] points out one that has probably never occurred to many of us: the user interface for a calculator is an unexpectedly complex thing.

The internal logic to support sequential inputs and multiple operators in a way that feels intuitive is a complex thing.

Resolving something like 1 + 2 = is pretty straightforward but complexity compounds rapidly after that, with numerous special cases. Let’s imagine one decides to program a simple calculator UI as a weekend project. The development process might look a little like this:

  1. User types in 1 + 2 = and the calculator displays 3. What happens if the user immediately presses -?
  2. No problem, just consider the result of the previous operation as an already-there input. So we’ll have 3 - for this next operation, and wait for more.
  3. Unless we should have treated that - as a negative sign for whatever number is coming next, making it a negative number? No, ignore that. Just treat whatever results from pressing equals as a pre-typed input.
  4. Unless the user hits a number. Because if they hit 2 (for example) then we’ll have a 32 and not a 2 which they probably, definitely don’t expect. So that’s a special case and we should insert a clear if that happens.
  5. Oh, better clear if the user enters a decimal, too.
  6. I’m going to need a coffee…

And that’s just the tip of the iceberg. Imagine trying to figure all this out for the very first time, without the benefits of habit and history to fall back on.

The fact is that supporting the apparently trivial behavior of a simple calculator requires an underlying complex state machine that deals with all kinds of special cases in order to make the UI feel intuitive. And that’s just for a basic four-function calculator; we haven’t even touched on how special keys like % should behave.

We know [lcamtuf] speaks from experience, not just because of their deep knowledge of calculator history but because they rolled their own calculator that uses voltmeters as digit displays and there’s nothing like actually implementing something to make one appreciate it.

Bad Apple on a Karaoke Machine

CD+Graphics was a format that never really caught on. It let music discs pack some graphics, maybe liner notes, and mostly song lyrics into the otherwise empty space on a CD. It was never intended for displaying full-motion video, but that didn’t stop [Adam Gashlin] from getting a Bad Apple, with lyrics, running on any device that will play CD+G.

The main challenge is that CD+GΒ gives you 300 screen commands per second, which is plenty for updating text on the 48Γ—16 blocks as the lyrics scroll by. But if you want to send custom blocks and draw images, that’s 2.5 seconds per screen: a lousy framerate.

[Adam]’s first trick is to drop the resolution way down, which gets him into the 8 FPS range. Only update the blocks that change pushes this up to a respectable 17-20 FPS. But you can see the updates, and that’s distracting. It really needed buffering.

If you don’t know Bad Apple, it’s in black and white. And like many old graphics engines of the day, CD+G uses a dynamic palette of colors. [Adam] uses this to pack four frames into one, switching between them using palette swapping. (Absolutely check out his β€œrainbow” version of the video to see how the palette-swapping trick works.)

In the end, his demo has audio, triple-buffered video, and lyrics at 16.3 FPS. It’s slower than the fastest video-only version, but it looks so good, and [Adam]’s explanation of all of the graphics tricks he uses to get there is the real star of the show.

If you want to see Bad Apple running on yet more minimal hardware, how about a 16Γ—2 LCD? Or a much more ridiculous implementation? How’s regexes in Vim for absurd? Got any Bad Apple hacks of your own? Let us know in the comments or the tips line. You can never have too many.

The Seemingly Impossible Oscillator

Back in the days when an integrated circuit meant a simple but expensive device such as a 741 or a 555, most electronics enthusiasts made do with discrete transistor circuits. The common emitter amplifier and its variants are the most familiar, but the humble 3-legged device can do so much more. A particularly obtuse circuit is the subject of examination by [lcamtuf], the reverse avalanche oscillator. A 2N2222, a capacitor, an LED, and a resistor, the transistor is the wrong way round, and there’s nothing on its base. Yet the LED flashes, what on earth is up!

The answer lies in avalanche breakdown, the behavior of a reverse biased diode junction as the voltage across it increases. Eventually the electric field reaches the point at which an avalanche of electrons crosses the depletion layer, and the junction conducts. When connected across an RC circuit, the voltage in the capacitor slowly rises to the point at which avalanche breakdown occurs, and the capacitor abruptly discharges. As the voltage falls the avalanche conduction stops, and the cycle repeats itself. It’s a relaxation oscillator.

We’re treated to an explanation of why a transistor behaves this way and why a simple diode doesn’t, due to a β€œhump” in its I/V curve, and why the emitter-base junction has a lower breakdown voltage than the collector-base. It’s one of those circuits which looks as though it shouldn’t work, but never fails to oscillate.

Want to know more about transistors? Do we have the series for you!

Voltmeter-Based Floating Point Calculator Does It In Style

[lcamtuf] is not just a calculator superfan, but also a skilled builder. That much is evident in the fabulousΒ  design of Calcumator 2000, an electromechanical calculator that uses voltmeter readouts as digits (plus one at the bottom to represent decimal place). There are plenty of high-quality build images, so give it a look!

Meters like the one on the right (numbered 0 to 9) act as digit displays. The meter on the left indicates decimal position.

Calcumator 2000 is a bit of a love letter to a time when display technology hadn’t quite yet produced anything suitable for calculator use. This resulted in calculator designs that are generally unrecognizable compared to the 7-segment display based devices we see today. The Calcumator 2000, in all its electromechanical glory, would have fit right in that era.

The Calcumator 2000 has all the usual buttons one would expect from a simple calculator and drives a total of seven readouts, one of which acts as the decimal point. The idea of using voltmeters as digit displays came from [lcamtuf]’s voltmeter clock, an earlier work with a similar attention to detail in its design and assembly.

We want to take a moment to admire how clean the blue panel is. [lcamtuf] made it by painting one side of an acrylic panel, cutting the letters and design out on a CNC mill, then filling with white paint. The depth of the cuts gives the white elements a nifty multi-layer effect that really complements the design.

Want to see it work? Oh yes, you do. Check out the video, embedded just below.

Three Different Digital Counters To Remind Us How Good We Have It

Integrated electronic modules like counters and displays are convenient and space-saving, which may also make them easy to take for granted. [Nagy KrisztiΓ‘n] demonstrates this by making three very different digital counter designs, each breadboarded with a 7-segment LED display. Push a button, and the displayed number increments by one for each press. It was a personal project that ended up educational in more ways than one.

The progressively-integrated designs shrink in part count and board space, but the complexity doesn’t disappear. It just moves into software.

The first version uses discrete components only, and even though it handles the counting with CD4026B decade counter ICs instead of building counters from scratch with NAND gates, it’s still by far the largest of the three. The second version simplifies driving the display with an AT28C64B EEPROM acting as a sort of hardware lookup table translating binary counts into 7-segment digit display patterns. The third uses an ATtiny24A microcontroller, and unsurprisingly has the smallest footprint.

All of this highlights two things. One is that implementing even a simple counter and 7-segment LED readout is a nontrivial affair when one gets right down to it, even when taking advantage of purpose-built ICs. The second is that the complexity that is on full display in the first version doesn’t simply disappear as the footprint and component count goes down. Rather, it moves into software and other infrastructure, like the need for compilers and chip programmers.

The whole thing is both educational and a reminder of how good the average hardware hacker has it today. There are so many effective electronic assemblies, available to just about anyone at low cost, that it can be very easy to take it all for granted and forget just how much breadboard space and wires were needed for even simple-seeming things.

[Nagy] is certainly no stranger to dealing with a lot of wires, as we’ve seen when he fooled a 286 processor into thinking it was plugged into a functioning vintage motherboard.

The Organ That Forgot To Use Transistors

When we think of 1960s synthesizers it’s usual to imagine instruments with vast arrays of controls and patch cables for configuring their many filters, oscillators, and other parameters. They created the templates for much of what we know today as electronic music.

In all the rush to look at full-blown synths though, it’s easy to forget their more mundane cousin, the electric organ. These instruments graced many a ’60s suburban home or church hall, and [Emma Repairs] has an interesting one. It’s a Philips Philicordia, and it’s sent us here at Hackaday down one of those rabbit holes when we should really be writing.

The instrument is a relatively straightforward single voice electric organ on the outside, but under the hood it’s a different matter. In an age when the transistor was revolutionizing electronic music, the folks in Eindhoven designed this one using tubes. There are a set of conventional enough tubes performing the role of amplifiers and oscillators, but the real party piece of this unit is the array of neon tube dividers. A neon bulb can be used as a switching element, and in those days when affordable digital logic chips were several years away, it made sense to use them in digital circuits.

The inside of the Philicordia is a feast of vintage Philips parts that will be instantly familiar to anyone who’s worked on Western European electronics of this era. The exterior design of the instrument screams understated early-1960s cool, and after she’s introduced it you can hear her playing it in the video below. Further down that rabbit hole we found that one of these instruments provided the distinctive organ sound on Chris Montez’s 1962 hit Let’s Dance, so they weren’t all uncool.

❌