Projects Research & Design Hub

Periodic Table Desktop Trainer

Written by Dev Gualtieri

Built Using PIC16 MCU

The year 2019 marked the 150th anniversary of the periodic table. As a tribute, Dev built a desktop accessory that helps students learn the chemical symbols and the order of the chemical elements in the periodic table. The circuit is based on a Microchip PIC16 MCU, and it continually runs when powered by a commonly available 5V charger, or intermittently with a long-lived battery supply.

The United Nations proclaimed 2019 to be the International Year of the Periodic Table of Chemical Elements (IYPT2019). In 1869, Russian chemist, Dmitri Mendeleev (1834-1907), first organized all the chemical elements known at that time into a table based on atomic weight. In this effort, he built on the earlier work of many other chemists, notably Antoine Lavoisier (1743-1794), Humphry Davy (1778-1829), John Dalton (1766-1844) and Jacob Berzelius (1779-1848). The table revealed regularity in the properties of the elements, so it’s now known as the Periodic Table.

— ADVERTISMENT—

Advertise Here

Some of the elements of small atomic number—such as iron, copper and zinc—have been known since antiquity. Some other elements are bound together in minerals, and they were only isolated after chemistry was sufficiently developed. The gaseous elements, invisible as they are, were likewise difficult to identify. Other naturally occurring elements were first known only after their synthesis in nuclear reactions. These are promethium, polonium, astatine, francium, actinium, protactinium, neptunium and plutonium. There are other elements—those of atomic number 95 and greater—that have such a short lifetime that they are not found in nature and are only obtained through synthesis.

Each chemical element is represented by a one- or two-letter symbol in the Periodic table. When you scan these symbols, most of them make sense, like “O” for oxygen, “Al” for aluminum and “Ne” for neon. Mixed among these are some “oddball” chemical elements whose symbols don’t match their English names. That’s because their symbols derive from their names in other languages (Figure 1).

FIGURE 1 – These are the “oddball elements” of the periodic table, at least for English speakers. Their symbols derive from their names in Latin and German.

— ADVERTISMENT—

Advertise Here

The symbol Na for sodium derives from the Latin word for salt which is natrium. Latin provides other symbols, such as potassium (K, kalium, from the word for potash), iron (Fe, ferrum), silver (Ag, argentum), tin (Sn, stannum), antimony (Sb, from the name of its mineral, stibium), gold (Au, aurum), mercury (Hg, hydrargyrum, for silver water) and lead (Pb, plumbum). The symbol for tungsten, W, comes from the German name of its mineral: wolframite.

Presently, 118 chemical elements are known. The 118th element, oganesson, was first synthesized in 2002 at a nuclear research facility near Moscow, and it’s named after Russian nuclear physicist, Yuri Oganessian. Oganesson is in Group 18 of the periodic table, and it completes the 7th period. A consequence of this is that the next element, 119, with the temporary name “ununennium,” Latin for a hundred and nineteen, will be difficult to synthesize. As a consequence, we’ll have 118 chemical elements for quite a while.

DEVICE OVERVIEW
My desktop circuit (Figure 2) operates in several modes. It will display the symbols for all 118 chemical elements, either sequentially or in random order. In the sequential mode, it displays the symbols in order of atomic number, from hydrogen (H) to oganesson (Og). In the random mode, it first displays the atomic number, and then the symbol. This latter mode is useful for learning the association of the atomic number and symbol. It could also serve as the basis for a periodic table memory game.

FIGURE 2 – The Periodic Table Desktop Trainer, showing the symbol for bismuth, the element with atomic number 83. The push button at the top allows display of one element at a time, when battery powered.

The device can be powered from a 5V charger. The current demand is surprisingly low—10 to 12mA—because the matrix display LEDs are very efficient. As a consequence, nearly any 5V charger can be used as a power supply. There’s provision for intermittent operation in either sequential or random mode by pushing a button, and this is a useful mode when using battery power.

— ADVERTISMENT—

Advertise Here

In my device, I incorporated a battery holder for three AA batteries. These have enough voltage to power the PIC and display. Since alkaline AA batteries have a capacity of about 2,000mA-hours, this means that theoretically, the battery supply should operate the device continually for 200 hours, or about 100,000 push-button cycles.

CIRCUITRY
The characters are displayed on two 8×8 LED matrix displays that have a total of 128 LEDs. The LED matrix displays used were Luckylight KWM-R30881CPGB, which are available from a variety of sources. These have the LED cathodes connected to the rows.

In each display, the LEDs are wired in a matrix of eight columns and eight rows, with the LED cathodes connected to the row lines. If you happen to have displays in which the anodes are connected to the row lines, you can use the hardware without change and invert some values in the microcontroller (MCU) source code. The LEDs are multiplexed for display by supplying the proper 16 data bits for each row to the column lines, and cycling through the rows. Since there are 16 columns and 8 rows, we need 24 I/O pins to drive the display. Additionally, we need two data lines as an interface for an I2C serial EEPROM that contains the character set (that I’ll described shortly) and a mode switch.

I used a 40-pin MCU, the Microchip Technology PIC16F877A [1], to accommodate all this I/O. The PIC also has pins available for in-circuit serial programming, which made for easier development. The circuitry around the PIC MCU is shown in Figure 3, and the connections for the LED matrix displays are given in Figure 4.

FIGURE 3 – microcontroller circuitry for the Periodic Table Desktop Trainer. To enable a low current sleep mode for battery longevity, the serial EEPROM is powered by one of the PIC I/O pins. The current drain in sleep mode is just 200nA.

FIGURE 4 – Connections for the LED matrix displays. The displays used are Luckylight KWM-R30881CPGB, which are available from a variety of sources. Other LED matrix displays can be used, but the pin-outs may differ from those shown here. These displays have the LED cathodes connected to the row lines.

Since precision timekeeping isn’t required, the clock for the PIC is provided by its internal RC oscillator, with the frequency set by an external 4.7kΩ resistor and 22pF capacitor. This gives a clock frequency of about 4MHz, which is the upper limit for the internal oscillator. The actual operating frequency can be checked at pin 14, which outputs a signal at one-quarter the clock frequency. The 100Ω current-limiting resistors at the pins that drive the LED columns provide a bright display, and the actual brightness is set by a pulse-width modulation (PWM) in the source code.

The character set is contained in a Microchip 24C256 serial EEPROM, whose data are accessed using I2C SDA and SCL signal lines. The required storage for the character set is slightly less than 2KB. The 256KB capacity of this EEPROM is certainly overkill in this application, but it’s hard to source less dense serial EEPROMs. Since we want to minimize battery drain in the MCU’s sleep mode, this serial EEPROM is powered by one of the PIC I/O pins. The pull-up resistors for the mode pins are powered by the same I/O pin.

There are quite a few connections from the PIC pins to the LED matrix displays, and many of the signal line conductors need to cross each other. Figure 5 shows the component side view of the main circuit board. While this is easily done in a multi-layer PCB, I use boards with a single copper plane that I etch for my own circuits. To simplify construction, I mounted the LED matrix displays on a daughter board that plugs into the MCU board. The daughter board still requires a few jumper wires to route the display signals. Figure 6 shows the front and bottom views of the final assembly, showing the daughter board placement before insertion into the plastic case.

FIGURE 5 – Component-side view of the main circuit board for the Periodic Table Trainer. The header for in-circuit serial programming is at the top left with the mode connections nearby. Also seen are the three, eight-position single inline sockets that connect to the daughter board that hosts the LED matrix displays.

FIGURE 6 – Front (above) and bottom (below) views of the final assembly, showing the daughter board placement before insertion into the plastic case. A few of the jumper wires on the daughter board that translate the interface pins to the proper matrix display pins can be seen. Some of these jumpers are hidden beneath the displays. The symbol for silver, Ag, is shown on the top-view photo. The bottom-view photo shows how the daughter board plugs into the microcontroller board, and how the LED matrix displays plug into the daughter board. Single-row inline sockets are used for the connections.

The Periodic Table Trainer operates in several modes that are selected by the logic signals present on the connections to PIC pin-37 (RB4) and pin-38 (RB5). These are set at a logical “1” by the two 100kΩ resistors, and they are set to a logical “0” by connection to ground by switches. When B4 is at zero, the device operates in a single-shot mode, in which one element is shown after each reset. When B4 is a one, the device continually shows elements. If B5 is at zero, a random element is displayed each time, and when B5 is a one, the elements are displayed in the order of their atomic number. In that case, the displayed element is stored in the PIC non-volatile memory so that the order is preserved between button presses in single-shot mode.

CHARACTER SET
I originally wanted to use 16-segment alphanumeric displays, but these weren’t available in the desired large size. The 8×8 LED matrix displays were a good second choice.

The next problem was that I needed character set data for the chemical element symbols and the atomic numbers from 1-118. I designed my own, based on a 5×7 character set, but I included some aesthetic enhancements. One was to have the five lowercase “dangler” characters—g, j, p, q and y—drop below the baseline of the leading uppercase characters. While no chemical elements have symbols that require either uppercase or lowercase j or q, I included these for completeness.

The symbols for the chemical elements are one or two characters, and these are easily displayed on two, side-by-side 8×8 matrix displays. However, the atomic numbers can be as large as 118. While you might initially think that we need three matrix displays to accommodate the atomic numbers, the leftmost digit is the slender character one. I was therefore able to squeeze all the necessary numbers into two matrix displays in my character set. The row data are stored as sequential bytes in the serial EEPROM. Figure 7 shows how.

FIGURE 7 – Character set coding to hexadecimal numbers in the serial EEPROM. The character set is a modified 5×7 character set in which the lower-case “dangler” characters rise from the lowest row.

EEPROM PROGRAMMING
Integrated circuit (IC) technology has advanced considerably since the late 1970s, when I built my first home computers. At that time, erasable read-only memory chips had just a few kilobytes of data space, and they were erased only by exposure to intense ultraviolet light. The IC packages had windows that allowed the ultraviolet light to penetrate the silicon chips and erase them by recombining the electrons and holes in the memory capacitors (Figure 8). Today, read-only memory chips have memory space that is orders of magnitude greater, they’re erased by a quantum tunneling effect and they’re called “electrically erasable programmable read-only memories” (EEPROM).

FIGURE 8 – Evolution of read-only memory. The earlier packages had a window that allowed memory erasure by an ultraviolet light. Left to right, two examples of 2k×8 parallel interface chips from 1979 and the 256k×8 I2C serial EEPROM used in the circuit.

Several years ago, the 24C08 was a popular EEPROM for MCU circuits because it was serially alterable by an I2C interface. This device contained 8KB of memory, which was usually sufficient for most applications. Today, this device has been superseded by the 24C256, a plug-compatible device with 256KB of memory. Not surprisingly, the 24C256 chips are available at a lower price than that of the 24C08, so I could hardly complain when I used this chip to store my 2KB character set.

The character set initially needs to be loaded into the serial EEPROM. There are many choices for purchase of a device programmer, but, if you just need to program a device for the Periodic Table Trainer, that’s an unnecessary expense. One of my many Raspberry Pi computer boards solved that problem, because these boards have an integrated I2C interface. The circuit shown in Figure 9 allows connection of the serial EEPROM to the Raspberry Pi I/O header. It’s so simple that I built mine using point-to-point wiring on a prototyping circuit board, but I’ve included a circuit board layout in the online repository.

FIGURE 9 – Using a Raspberry Pi to program an EEPROM memory chip. Fortunately, the 24CX chips will operate from a 3.3V supply, so we can steal voltage from the Raspberry Pi I/O header pins. The Raspberry Pi has I2C interface pins that make programming possible by software (see main text).

The I2C is not activated by default on the Raspberry Pi, but it’s a simple procedure to do that using the raspi-config program in the Raspbian operating system. Run the configuration program by typing the following in a command line:

sudo raspi-config

Then, at Interfacing Options, enable I2C, select <Finish> and then reboot. After reboot, you can verify that the I2C system is active by this command:

ls /dev/*i2c*

The Raspberry Pi will respond by indicating that the user I2C system, i2c-1, is active.

/dev/i2c-1

One command-line utility you should install for debugging is i2c-tools. This is installed with the following command:

sudo apt-get install -y i2c-tools

In particular, i2c-tools will probe the entire I2C address space to report what devices are connected. When the serial EEPROM is connected, you will see the display shown in Figure 10, which indicates that there is a device at hex address 0x50, after entering the following command:

FIGURE 10 – When the serial EEPROM is connected, you will see this display, which indicates that there is a device at hex address 0x50, after entering the command: i2cdetect -y 1

i2cdetect -y 1

The 0x50 address is a consequence of the upper 4 bits of this EEPROM being logically set at 0101 inside the integrated circuit. When combined with the three lower address bits set at a logical “0” by grounding the address pins, we get an address of 0101000, which is 0x50.

Although the user I2C interface of the Raspberry Pi is accessible from several available programming languages, I’ve found that the easiest of these is Python. However, some things are more easily done using one of my favorite languages, PHP, so I’ve written a program in PHP that writes the character set data into a text file, which is read by a Python program that programs the serial EEPROM through the I2C interface. Source code for these programs is included on Circuit Cellar’s article code & files webpage, and the text file of the character set is included so that it isn’t necessary to run the PHP program if the character set is unmodified. From the same directory that includes the file named elements_hexfile.txt, run the following to program the serial EEPROM:

python i2c_programmer.py

CIRCUIT VARIANTS
As with all my PIC projects, I wrote the firmware using the PICBasic Professional compiler from ME Labs [2]. Because I use Linux exclusively, I run an older version of this compiler and its associated programmer on a very old Windows operating system installed as a virtual machine. The folder on Circuit Cellar’s article code and files webpage for this article include a compiled hex file, to program a PIC without needing a compiler. It would be easy enough to rewrite the source code in C so other compilers can be used, including the free MPLAB C compiler [3] from Microchip Technology, manufacturer of the PIC MCUs.

At the time of writing this article, it’s possible to buy 8×8 LED matrix display subsystems with an I2C bus interface. I avoid publishing circuits that utilize a particular component that might be hard to source in the future, so I didn’t use these in my design. If you are able to buy these, you can still use the character set in the serial EEPROM, and there would be a considerable simplification of the circuit. A smaller PIC can be used, since much of the complexity is off-loaded to these I2C display subsystems, and I’m sure that Arduino fans would have no trouble building and programming a device using these displays. 

RESOURCES

References:
[1] The datasheet for the PIC16F877A is available at the Microchip Technology website at https://ww1.microchip.com/downloads/en/devicedoc/39582b.pdf
[2]. Information on the PICBASIC PRO Compiler is available at https://melabs.com
[3] Information on the free, unrestricted-use, MPLAB XC C Compiler is available at https://www.microchip.com/mplab/compilers

Wikipedia has a very complete article about the periodic table at https://en.wikipedia.org/wiki/Periodic_table

Luckylight | www.luckylight.cn
ME Labs | www.melabs.com
Microchip Technology | www.microchip.com
Raspberry Pi Foundation | www.raspberrypi.org

PUBLISHED IN CIRCUIT CELLAR MAGAZINE • MARCH 2020 #356 – Get a PDF of the issue

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

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


Note: We’ve made the Dec 2022 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 www.tikalon.com/blog/blog.php. He is the author of three science fiction novels, and books about science and mathematics. See www.tikalonpress.com for details.

Supporting Companies

Upcoming Events


Copyright © KCK Media Corp.
All Rights Reserved

Copyright © 2023 KCK Media Corp.

Periodic Table Desktop Trainer

by Dev Gualtieri time to read: 12 min