Projects Research & Design Hub

Build an Abacus Data Entry Terminal

Written by Dev Gualtieri

This circuit was built as a novel means of computer data entry, but its design has features that may be useful in other projects. You’ll learn about a unique method of position sensing, a method for high precision frequency counting on an inexpensive microcontroller, and multiplexing to reduce hardware complexity.

  • How to build an abacus data entry terminal
  • How does a soroban abacus work?
  • How to understand inductive position sensing
  • How to construct the sensing coil
  • How to design the circuit
  • How to calibrate the system
  • How to implement the software
  • Ferrite toroids
  • 38 AWG enameled copper wire
  • Ribbon cable headers
  • Inductors and capacitors
  • Current-limiting resistor
  • Microchip PIC16F877 microcontroller
  • microEngineering Labs’ PIC Basic Professional
  • 7445 integrated circuit
  • 2N7000 MOSFET

Computer technology has enabled some interesting hobbies. There are people who memorize many digits of pi, a transcendental number that’s now known to many decimal places because of computers. The present record for digits of pi recited from memory is at least 50,000, and it might be as high as 100,000, depending on who’s counting. There are people who use their desktop computers for creation of image parodies using Photoshop and similar image manipulation programs, such as GIMP.

Steampunk is an interesting technology-inspired culture in which devices created by today’s technology are redesigned as if they had been built in the 19th century. Steampunk aficionados covet objects such as computer keyboards that look like manual typewriters, and ornate brass works housing computer monitors. They’re always looking for antique devices to repurpose.

The abacus is a counting device that’s been with us for at least four millennia. Versions of this early manual adding machine have existed in most world cultures, but one of the more popular is the Japanese abacus, called a soroban, as shown in Figure 1. In this device, numbers are represented by movable beads in a modified base-5 number system.

Figure 1
The soroban abacus operates in a modified base-5 number system in which the four lower beads in each column count from zero to four, while the upper bead adds five. In this manner, each column can represent decimal numbers from zero to nine.

The number of bead columns is arbitrary, but each column has four beads in a lower rank and one bead in an upper rank. Counting is done by starting with all beads low on their column, and then raising beads in the lower rank one at a time. When all four beads in the lower rank are up, you get to five by raising the single bead in the upper rank, and demoting the four lower beads to the bottom. When all beads in a column are up, signifying a nine, and you need to add one, all the beads in the column are lowered to the bottom, and a bead in the adjacent column on the left is raised.

It’s easy to add numbers on a soroban by first entering one number, then moving beads to enter the second number atop the first, starting with the rightmost column, and always carrying through towards the left. Such addition might seem complicated to someone who’s not skilled in the art, but everyone will find that it’s easy to enter a number on a soroban, even if they’re not skilled in base-5. Figure 2 illustrates entry of the number 92574.

Figure 2
This is the number 92574 entered on a soroban abacus.

My eldest grandchild has a puzzle that looks a lot like one that I had when I was a child. Wooden pieces are shaped to fit into complementary holes. However, in this electronic age, the puzzle is augmented such that placing a piece in its hole will produce an appropriate sound.


Advertise Here

When I examined this puzzle, I saw that the position sensing was done using photodiodes that respond to the absence of light when they were covered. The designer made the obvious assumption that the puzzle wouldn’t be used in the dark, so this position sensing method worked well.

A soroban with eight columns has forty beads. If we were to use this same position sensing technique, that would involve a lot of photodiodes! Also, we can expect a lot of hand motion above a soroban, so the idea of the diodes being uniformly illuminated is flawed. We need a different method if we want to sense the position of soroban beads.

Every electronics experimenter is familiar with the simple and inexpensive construction of an inductor. You just wind a coil of wire. When too many coil turns are required for the desired inductance, or when you need to make the inductance variable, you wind the coil on a magnetic core. The core material is usually made from ferrite, an oxide of iron and other elements.

Although tuned inductors use a cylinder of ferrite, a more common form of ferrite is a toroid. Toroidal ferrite is used for filters and transformers. They can be used, also, to modify the inductance of a flat inductor, as shown in Photo 1.

Photo 1  
Here you see two ways to change the inductance of a wire coil by introducing ferrite. The top coil illustrates the common method of placing the ferrite within a coil of wire. The lower coil shows the method used in the abacus position sensing in which a ferrite toroid is placed around a flat coil.

Movement of the ferrite core changes the inductance; and, when the inductor is part of a tuned circuit, the resonant frequency will change. The resonant frequency can be read by a frequency counter if the tuned circuit is part of an oscillator, so the core position can be read as a frequency. This is the position sensing approach I used to sense the position of the beads in the abacus.

The sensing coil dimensions are shown in Figure 3. The ferrite toroids I used had an inside diameter of 5 mm and an outside diameter of 10 mm. They were a little snug on a type of drinking straw that I identified as an ideal, and inexpensive, carrier tube for the coils. However, I found that I could stretch the plastic straws slightly, to shrink their outside diameter, by pulling them on an appropriately sized metal rod after they were heated with a hair dryer.

Figure 3
These are the dimensions of the coils (mm) used for the lower and upper ranks of the abacus. Shifting the ferrite beads to the coil area gives a large inductance change.

The flat coils were wound on a simple jig, as shown in Photo 2. One advantage of being married is having access to unusual construction materials; in this case, the clear nail polish I used to coat the coils so they wouldn’t unwind before insertion into the carrier tubes. The coils were glued into the carrier tubes with the same nail polish.

Photo 2
This is the winding jig and coil. Pieces of sleeve insulation were glued into the open areas to maintain the coil width. The coils were covered with clear nail polish to maintain their integrity before insertion into the carrier tubes.

The lower, 25-mm coils were wound as 30 turns of 38 AWG enameled copper wire, while the upper, 12.5-mm coils were wound as 40 turns of the same wire. The longer coils had a nominal resistance of about 2.7 Ω, while the shorter coils had a nominal resistance of about 2 Ω. The coils were inserted into the carrier tubes to a depth that left about 2.5 mm of empty space at the end to allow for mounting.

Photo 3 shows the carrier tubes with their embedded coils inserted into the base assembly. Also shown is the push button switch that sends the entered number values to a computer. This switch also serves as a way to initially calibrate the abacus.


Advertise Here

Photo 3
Carrier tubes with embedded coils are attached to the base assembly. Bare circuit boards are a convenient construction material, since they allow for solder attachment of pieces. Ribbon cable headers were used for connecting the coils to the circuit board. The coils are at the top of each tube where the wires exit.

I often use bare circuit boards as a construction material, since they are rigid, they are easy to cut and drill, and they allow for solder attachment of pieces. Circuit boards worked well for this application, and a mechanical drawing of the base assembly of Photo 3 is available on the Circuit Cellar article code and files webpage. Ribbon cable headers were used for connecting the coils to the circuit board. The circuit board was mounted on the underside of this base plate.

Combining the inductor with a capacitor in the resonant circuit of an oscillator allows the inductance change to be inferred by the oscillator frequency. The abacus data entry terminal uses a slight variant of the digital oscillator shown in Figure 4.

Figure 4
The Colpitts oscillator, a version of which is shown on the left, is my favorite oscillator circuit. A direct translation of this circuit to a digital oscillator is shown on the right. Biasing CMOS logic gates, as shown, will transform each gate to an analog amplifier with a gain of about thirty. Cascading two units results in a high gain analog amplifier.

Timer0 (TMR0) on Microchip Technology PIC microcontrollers will accept an external frequency source and thereby serve as a frequency counter. The resolution of TMR0 is just 8 bits, which is too low of a resolution for most frequency counting. In 1997, Microchip Technology published an application note on a method to achieve 16-bit resolution for frequency counting using TMR0. This method is illustrated schematically in Figure 5.

Figure 5
The TMR0 high-resolution frequency counting principle. An I/O pin (in this case, RA5) gates the frequency source on and off, and it also increments the prescaler to overflow the TMR0 register.  
(Click to enlarge)

The frequency source is routed through a current-limiting resistor (typically 4.7 kΩ) to the external input of the prescaler for TMR0. The prescaler input is also connected to an I/O pin that’s initially configured as an input. In that state, the frequency signal is passed to the counter unimpeded.

After a preset time, the I/O pin is set as an output at state 0. This effectively short circuits the frequency signal, so the prescaler stops incrementing. At that point, the TMR0 register has captured an 8-bit representation of the frequency. Now comes the clever part. The I/O pin is toggled while checking for an increment of the TMR0 register. At that point, we can infer the 8 bits that were in the prescaler from the complement of the number of toggles. We can then construct a 16-bit frequency value.

Figure 6 shows the circuitry for the coil multiplexer and the microcontroller. Figure 7 shows the coil connections, while Figure 8 shows the oscillator and the serial port driver. Ideally, a multiplexer is just a switch, and the open-collector transistors of the 7445 integrated circuit should just short the resonance coils to ground. Calculating from the specification sheet, however, shows that the on resistance of the transistors is about 10 Ω. This is a small value when you’re turning on a relay coil, but any resistance added to an inductor in a tuned circuit lowers the resonant “Q.”

Figure 6
This schematic shows the PIC microcontroller and coil multiplexers. The frequency of OSC1 is 20 MHz.
(Click to enlarge)
Figure 7
These are the coil connections.
Figure 8
Here you see the oscillator and serial port driver.

The effect of this lower Q is that it takes the oscillator a few seconds to start. Once it’s started, it remains in oscillation while we’re switching from coil to coil. I experimented using a MOSFET, the 2N7000, as a switch, and that works much better, but 16 FETs would be needed. I decided to just have the software pause at power-up until the oscillator starts, thereby eliminating such circuit complexity.

The circuit has a display port implemented as an HD44780 standard parallel interface that’s compatible with a wide range of display types (see Photo 4). I used a 2 × 20 character vacuum fluorescent display, which is a power hog and definitely overkill for this application. I tested the circuit with a typical, inexpensive 2 × 16 LCD, and this type of display is probably a good choice. The serial interface is a DB-9 connection to a PC, and it will also interface with a Raspberry Pi (through an appropriate logic level-shifter), probably with an Arduino, or converted to a USB serial port with one of the many available converters.

Photo 4 
a—The circuit board is mounted on the back of the coil assembly shown in Photo 3. The lower connections are to the coils, the side connection is the in-circuit serial programming port, and the upper connections are for the display and DB-9 serial port. b—This is the completed abacus data entry terminal. I constructed a custom plastic case to house the circuit. c—The display shows both the decimal number entered and its hexadecimal equivalent.

Capacitors are generally precise to only about 10% of their nominal value. This low precision, combined with variance in coil construction and coil placement in the carrier tubes, means that the software must be calibrated to the hardware. This is easily done by first positioning the ferrite beads to their lower position, storing the frequency values, then repeating the process with the beads in their upper position. The software is then able to interpolate frequencies to determine the position of the ferrite beads.

Figure 9 shows the average frequency change as a function of the number of ferrite beads on a coil in the lower rank. The nominal frequency of the lower rank coils is 525 kHz when there are no ferrite beads, and 460 kHz when all four beads are present. The nominal frequency of the upper rank coils is 565 kHz when there is no ferrite bead, and 535 kHz when the single bead is present. The putative bead number as a function of the frequency change for the lower rank, as implemented in the software, is shown in Table 1. You can verify oscillation by holding an AM radio close to the coils.

Figure 9
Take a look at the functional relationship between the number of beads in the upper position for the lower rank digits and the difference in frequency with respect to an unloaded coil. This is an average of the response of all eight lower coils in my circuit. Adding beads reduces the resonant frequency in a nearly linear fashion.
(Click to enlarge)
Table 1
Here you see the conversion of frequency to number of lower-rank beads in their upper position. The values
are the percentage of the interval between all beads being up or down.

The source code for the abacus data entry terminal, written in PIC Basic Professional, is available on the Circuit Cellar article code and files download webpage. Also available are hex files for using both 20 × 2 and 16 × 2 displays for those without access to this compiler. The software doesn’t require a display, so you can eliminate that from your design if you want a “bare” terminal.

The software waits for oscillator start and checks to see whether the push button was held during power-up. In that case, it prompts the user for its initial calibration routine in which all beads are first placed down, and then up, in their columns. The calibration values are stored in nonvolatile memory, so calibration is a one-time affair. The serial output is arbitrarily set at 2,400 bps, which is fast enough for a manual data entry terminal (see Photo 5).

Photo 5
Serial data is displayed on the Linux utility, CuteCorn. The tab character between the decimal and hexadecimal representations is displayed here as its hexadecimal equivalent, 0x09. The data rate is 2,400 bps

The circuitry uses a PIC16F877, but the PIC16F877A is presumably a pin-compatible and software-compatible replacement. The only difference is in the way that the flash memory is programmed, something that should be handled automatically by selecting the proper chip in your programming software. The PIC16F877 is a recommended replacement for these microcontrollers, having a few additional functions such as a greater number of analog input channels. The PIC16F887 should work in this application, but some software changes would be needed.

The coils do generate some radio frequency interference, as holding an AM radio tuned to the proper frequency will show. In my unit, however, these signals don’t travel that far, and they are not detected on an AM radio a few feet distant. 

Author’s Note: The source code for this circuit, and hex files for burning the object code directly without a need for a compiler, are available on the Circuit Cellar article code and flies webpage. Also included are the CAD files for the printed circuit board and a mechanical drawing of the coil assembly.


Advertise Here

S. D’Souza, “Frequency Counter Using PIC16C5X,” Microchip Technology Application Note AN592, 1997,
Microchip Technology, “PIC16F87X: 28/40-Pin 8-Bit CMOS FLASH Microcontrollers,” DS30292D, 2013,

PIC16F877 Microcontroller
Microchip Technology |
PIC Basic Professional
microEngineering Labs |


Keep up-to-date with our FREE Weekly Newsletter!

Don't miss out on upcoming issues of Circuit Cellar.

Note: We’ve made the May 2020 issue of Circuit Cellar available as a free sample issue. In it, you’ll find a rich variety of the kinds of articles and information that exemplify a typical issue of the current magazine.

Would you like to write for Circuit Cellar? We are always accepting articles/posts from the technical community. Get in touch with us and let's discuss your ideas.

Sponsor this Article
Website | + posts

Dev Gualtieri received his PhD. in Solid State Science and Technology from Syracuse University in 1974. He had a 30-year career in research and technology at a major aerospace company and is now retired. Dr. Gualtieri writes a science and technology blog at He is the author of three science fiction novels, and books about science and mathematics. See for details.

Supporting Companies

Upcoming Events

Copyright © 2021 KCK Media Corp.

Build an Abacus Data Entry Terminal

by Dev Gualtieri time to read: 11 min