Basics of Design Research & Design Hub

Build an EEPROM-Based Driver

Written by Doug Hilton

Working on a design that requires data logging capabilities? Doug suggests that you should consider an EEPROM. With a Parallax Propeller Professional Development Board, some software, and little know-how, your design will be storing and retrieving data in no time.

  • How do design a data logging device using EEPROM

  • How to use the Parallax Professional Development Board (PDB)

  • How to use free software for your EEPROM driver

  • How to wire up your PDB

  • How to understand the bus signals used

  • How to set up the EEPROM I2C driver

  • How to load the test program

  • Parallax Professional Development Board (PDB, P/N 32111) 

  • Microchip Technology EEPROMs

  • Pre-formed jumper wires

  • Male-male jumper wires

  • Eight 0.1-µF capacitors

  • Sixteen 2.2-kΩ 1/10 W resistors

  • Four optional 16-pin IC sockets

When you develop a product that needs to store and retrieve data that will last after powering off, you should consider an EEPROM. An EEPROM is an inexpensive integrated circuit that can hold data for over 200 years without electrical power. EEPROMs range in size from 128 bits to 1,024 Kb in size. Some of can be “ganged” together to increase available storage size up to 512 KB. (Yes, half a gigabyte!). They can use a two-wire serial interface, called I2C. They use low voltage (as low as 1.7 V) and low power (1 mA active current, 1 µA standby current). Some of the devices use a page write buffer so that multiple bytes can be written at a time.

That’s all good stuff, so what’s the downside? Speed and rewrite cycles. EEPROMs are not particularly fast compared to random access memory (RAM). Typical write cycle time per byte or page is 5 ms, plus, of course, the time that it takes to handle the I2C overhead.[1] Also, you can’t write to an EEPROM an infinite number of times. EEPROMs have an “endurance” on the order of 1,000,000 erase/write cycles, which sounds like a lot until you start thinking about how many times you’re going to update them over a long period of time. In a data-logging application that might be active for years, you could easily exceed the endurance of an EEPROM. Refer to Table 1.

Table 1
EEPROM endurance

If you try to write to the EEPROM once a second, it will only last 10 or 11 days. So don’t use an EEPROM for that kind of data-logging! Consider Table 2 instead. If you log data every 5 minutes, the EEPROM will last almost 10 years. That’s not too bad, but not “forever.” So, if you want to put a data logger in a truly hostile or remote location and pick it up many years later, you need to consider EEPROM endurance carefully when you write your software.

What’s the solution? You can easily breadboard an EEPROM demo or…

Table 2
EEPROM endurance in intervals and days
HARDWARE SOLUTION

The Parallax Professional Development Board (PDB, P/N 32111) is a sophisticated demonstration showpiece of the Parallax eight-core Propeller chip. It has a dozen subsystems built in and a huge breadboarding area that just begs for a worthy project to challenge it. Well, here’s one—an EEPROM driver that can use any current EEPROM from the Microchip Technology product line, or any compatible EEPROM from any of the other manufacturers. Then, you can add other components and make your EEPROM driver into a data-logging module for more complex projects.

The PDB has a built-in EEPROM, but it is mostly used by the system to save the current stored program, so it’s not the best candidate for experimenting with. I bought a bigger EEPROM and plugged it in, and it worked just fine, with plenty of room to spare, where I experimented. But that wasn’t good enough for me, oh no. I went to the Microchip Technology website and downloaded specs for all their current devices. Then the “maker” in me decided that I really wanted to be able to experiment with EEPROMs and I went to the Allied Electronics website and ordered some of each type. Table 3 shows what I purchased for this project.

— ADVERTISMENT—

Advertise Here

Table 3
EEPROM project bill of materials

I looked on the Parallax website, in an area called the Propeller Object Exchange (obex.parallax.com), for a good driver and found a demo by Mike Green, an extremely competent programmer whom I know from days long past. But I wanted a complete, robust solution that would let me write arbitrary amounts of data to arbitrary EEPROMs. So, I coded up an EEPROM driver and tested each and every type—and I’m glad I did, because I learned something new from each different part number.

SOFTWARE

Here’s some good news: the software is free! The EEPROM driver and test program can be downloaded from the web. All you do is tell the program what kind of EEPROM you’re using, and it will identify the hardware, calculate the maximum address space, and let you read and write to your new database with optimal speed (using Acknowledge polling). That’s nice if your EEPROM has multi-byte read/write capability.

You may want to look at the driver software to see how byte and page read and write work. For example, to write data to an EEPROM, you send a Start condition, followed by a Control Byte, and then address and data bits, terminated with a Stop condition. To do all that, you use the I2C clock and data lines, which we’ll wire up soon.

WIRING UP THE PDB

The Parallax multicore processor is “overkill” for an EEPROM demo program, but I am sure that you’ll find a useful project or two that need its extra processing power. Lots of jumper wires mean lots of trouble if you don’t take the time to do each one carefully, and then fully double-check your work. Fortunately, the EEPROMs are arranged in a logical order, and you’ll quickly see a pattern develop as you wire them up. Figure 1 shows what the pins of a typical EEPROM look like.

Figure 1
Typical EEPROM pin layout (Source: Microchip Technology)

Showing the complete schematic for eight EEPROMs is just going to confuse you, so let’s not do that. As you can see in Figure 2, there are five buses that we need to connect, one at a time.

Figure 2
EEPROM database conceptual schematic

VCC Bus and VSS Bus—Each EEPROM requires voltage VCC and ground VSS. Looking at the specs above, they are all rated for 2.5 V, but they are all 3.3-V-tolerant, so using the 3.3-V supply on the PDB is OK. Some of the devices can tolerate up to 6.5 V, but some can only take 1.7 V. Please check the electrical characteristics before you wire up the VCC pin. Each chip should get a 0.1-µF bypass capacitor between VCC and VSS.

SCL bus and SDA Bus—Now you need to wire up the I2C signals, which are called serial clock (SCL) and serial data (SDA). I2C is a bus protocol that describes how the SCL and SDA lines are toggled on and off in order to read or write data to and from a device that is I2C-compatible. We’ll use just two pins on the PDB—pin 10 will be the clock (SCL) and pin 11 will be for data (SDA). It’s hard to believe that only two pins of the microcontroller can be used for addressing half a gigabyte of data, but that’s the beauty of the I2C protocol. Notice that there is a 2.2-kΩ, 0.125-W resistor on both the SCL and SDA buses. The technical reason has to do with open-collector logic. You can ignore the theory for now, and just wire it up.

Address Bus—The small EEPROMs, meaning the ones that can’t be “ganged,” are very simple to wire up and get running. You just need to connect SCL and SDA to the microprocessor. The bigger EEPROMs have additional Address lines which are connected to each other, so that the microprocessor can select an individual EEPROM out of the gang. That gives you the capability of having a linear address space that is between one and eight times the capability of a single EEPROM.

There are three types of EEPROMS: small (meaning no address pins); medium (meaning addressable/gang them together); and large (meaning the LC1025, which is addressable, but you can only use four of them, and they connect in a different way than “medium” EEPROMs). For each type of EEPROM, there is a spreadsheet that describes how the pins get connected. The file is posted on the Circuit Cellar article code and files webpage, along with wiring instructions.

— ADVERTISMENT—

Advertise Here

When you’re done wiring Vcc, Vss, SCL, SDA and Address buses, double-check it all so you don’t let the magic smoke out of the EEPROMs when you power it on. Also, a final check is in order to make sure that each Pin 1 is oriented properly (see Photo 1).

Photo 1
Completed Parallax EEPROM Board
EEPROM DRIVER

Now that your EEPROM board is wired, you need a software driver to talk to it. The driver is called XTREM_EEPROM_I2C_Driver. It is written in Parallax SPIN code and it runs on the Parallax PDB. You call subroutines (from your SPIN code) and it reads and writes BYTEs, WORDs, LONGs, and STRINGs to the EEPROM database. A thorough demonstration program is provided that lets you see all the XTREM_EEPROM_I2C_Driver subroutines in action. Table 4 is a list of the EEPROM driver subroutines.

Table 4
EEPROM driver subroutines

You can see a robust set of functions that allow you to initialize, write, and read from your EEPROM in a variety of ways. Each function is described in the driver code and exercised in the demonstration program.

LOADING THE TEST PROGRAM

Now you’ve got between one and eight EEPROMs all wired up, ready to log data. First, test the system to make sure that it’s all working. Use the Parallax Propeller Tool, version 1.3.2, and load the test program called !EEPROM_I2C_Demo using F10. When the program is uploaded to the PDC Propeller chip, start the debug console using F12.

If your wiring is correct, you should see the various tests scroll by the debug window and then the program will terminate normally. The program can be customized to exercise even more EEPROM functions, but some of those functions take quite a while, so they are disabled in the released test program, but you can easily uncomment the code and re-run it to try more EEPROM functionality (see Photo 2).

Photo 2
Screenshot of software output
IoT APPLICATIONS

You can use EEPROMs for data logging, within specified operating conditions, but pay special attention to read/write endurance parameters when you design your application. You may have wondered why anybody would use a 16-byte EEPROM. It is just perfect for storing shutdown values of a digital volume control and frequency for a radio, or the parameters of an iPod, or other small mobile device, or the temperature setting for a home thermostat, or remembering your robot’s servo settings. In other words, it is an excellent option for many Internet of Things applications, where read/write speed is not the primary requirement. 

REFERENCE
[1] Microchip Technology, “I2C Serial EEPROM Family Data Sheet,” DS21930C, 2007.

SOURCES
24LC512 EEPROM
Microchip Technology | www.microchip.com
Propeller Professional Development BoardParallax | www.parallax.com

HARDWARE BOM
Parallax part number 32111, Professional Development Board, is available from Parallax.com for about $100. (I bought one on eBay for $78.99.)

EEPROMs are available from Allied Electronics, Newark, Jameco, and many other websites. You’ll need between four and eight depending on their memory capability.

• Pre-formed jumper wires
• Male-male jumper wires
• Eight 0.1-µF capacitors
• Sixteen 2.2-kΩ 1/10 W resistors
• Four optional 16-pin IC sockets

PUBLISHED IN CIRCUIT CELLAR MAGAZINE • FEBRUARY 2016 #307 – 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 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.

— ADVERTISMENT—

Advertise Here

+ posts

Doug Hilton (WD0UG@yahoo.com) is a computer software designer with an Associates degree in Electronic Technology from J. F. Drake State Technical College. He was issued US Patent 9,158,441 on ontological filtering. Doug has been a licensed amateur radio operator for over 50 years (ham call sign WD0UG).

Sponsor this Article

Supporting Companies

Upcoming Events


Copyright © KCK Media Corp.
All Rights Reserved

Copyright © 2021 KCK Media Corp.

Build an EEPROM-Based Driver

by Doug Hilton time to read: 8 min