I didn’t have this article on my blog in 2009, it came over from my old CMS in 2015.

Test circuit on breadboard

Test circuit on breadboard

This project turns an AVR ATmega8 microcontroller into a LED controller for a matrix of 8×8 LEDs. The controller is acting as I2C-slave, so you can control the patterns to display via this bus (also known as TWI, Two Wire Interface).

Purpose

For my next project, I need to display number values on seven-segment-displays. I bought a bunch of 4-digit-displays a while ago, now I’m going to put them to a use. They are built with four digits in one case, and 12 pins on the underside. Eight of them are the cathodes of the segments (seven segments plus dot), four are the anodes. One for each digit.

You can imagine these modules as a matrix of four times eight LEDs, as can be seen in the included circuit. I use two of these, so I have a matrix of eight times eight LEDs.

The rows and columns of this matrix are connected to the microcontroller, so it can power them row by row. This has two advantages: at first a maximum of eight LEDs is powered at a time, so power consumption is lowered. And at second you need only 16 pins of the controller to address a total of 64 LEDs.

Driving the LEDs in this way makes them flicker a bit, but the controller is fast enough to keep the flickering way above the level you would be able to recognize.

I could have connected my display modules directly to the main controller of my next project, but I don’t have enough free pins on that. As a further benefit, multiplexing the LEDs on a second controller makes the main program easier to write, since I don’t have to mind the timing. So the solution is to use a cheap ATmega8 as LED driver and use the I2C-bus to tell it what to display.

I2C communication

The ATmega8 has a built-in hardware I2C-interface, so it doesn’t take very much code to use it. Nevertheless, I used a little library that Uwe Grosse-Wortmann (uwegw) published on roboternetz.de. I only reformatted it a bit to make the code resemble my style. It is well commented, but the comments are in german. Since only one global array, one init-function and an interrupt service routine are used, it shouldn’t be too hard for english-speaking people to figure out how it is used.

Usage

On the other end of the communication, I used the excellent Procyon AVRlib written by Pascal Stang. You can find it here.

The Circuit

The Circuit

Note: the buffer doesn’t contain any numbers that should be displayed on 7segment-displays. At least not in this example. It only holds bit-patterns.

Displaying numbers

If you solder 7segment displays to the unit and intend to display numbers or characters on it, you need to define them on the master-side of the bus. I didn’t include the definitions in this library because I want the master to have the full flexibility of displaying whatever it wants to, even if it are no numbers.

However, if you are going to use 7segment displays, definition of the numbers still depends on how you soldered them to the controller. I don’t know if the pin-outs are commonly standardized.

To give an example of how you would implement this, here is a fragment of code that defines hexadecimal numbers for usage on my displays:

Drawbacks

Till now, the device worked in all situations I tested it in. So far everything is fine.

Thanks!

I’d like to thank the authors of the libraries I used: Uwe Grosse-Wortmann (uwegw) for the I2C-slave and Pascal Stang for the Procyon AVRlib.

About the license

My work is licensed under the GNU General Public License (GPL). A copy of the GPL is included in License.txt.

Download

This text wasn’t part of the blog in 2009, I copied it from my old CMS in 2015.

My etching tank

My etching tank

Somehow I resisted to etch my own printed circuit boards for years. As I now know, I had no reason: it’s not as hard as I thought it would be. Having the right equipment helps with many things, so it does in this case. After having evaluated the whole process, one of the hardest things is to take off the rubber gloves after handling the chemicals…

Preparing the layout

One of my first own layouts

One of my first own layouts

Before creating the board, one has to create a proper layout from the circuit.

Many people use Eagle CAD for this job. It’s a great tool, but the free (as in beer) version has the handicap that it can only do layouts for half euro cards (that’s 8x10cm). You can do a lot of things on that amount of space, but at least for my Dulcimer project I needed more.

Meanwhile, I got used to KiCad. The usability is even worse than Eagle’s, but if you take your time and if you are kind to the program, it gives nice circuits and board layouts to you in return. And the killer advantage: it’s free software.

Exposure

Exposing the photo sensitive material is a bit tricky. I tried several methods, and I think I reached what I consider to be the optimum.

First the layout has to be printed. I made my first tries with simple paper, printing with my Laserjet 5. After not seeing any results on the boards, I tried coating the paper with oil to make it more transparent. Using a nitraphote lamp it would probably work with an exposure time of 50 minutes or so, but that seemed to be too long in my opinion. I got really good and quick results with overhead slides. With my first tries, I put two prints on top of each other, later I found that to be unnecessary, one layer is enough.

There’s even more choice with the source of light. What didn’t work at all was a 500W halogen lamp. Other people had more luck with that, but I guess that mine has a safety glass that blocks UV light.

A better solution would be the 250W nitraphote bulb that I acquired just for this reason. It’s a standard bulb with an E27 thread, but it delivers more UV than a normal lamp would. Unfortunately, 250W tend to be very hot after a while, and I almost ruined my kitchen lamp trying to expose through a layout printed on paper. After all, using the overhead sheet made really good results after an exposure time of 10 minutes in a distance of 15cm.

The best solution seems to be a facial tanner that I bought for 1,50 Euros — about a quarter of what I paid for the nitraphote lamp. It’s a Philips HB170, it has four tubes with 15W each. I turn it on for a few minutes, so the tubes are pre-heated. Then I put it face-down on two pieces of wood that are 3cm thick. Beneath it the stack consisting of the photo sensitive board, the printed layout and a glass plate. I turn the tanner on for two minutes and get great results — without risking to set the room on fire.

Etching

My first PCB

My first PCB

Surely, you can etch your boards in a simple lab dish, it shouldn’t affect the results much. But I didn’t like that method already on my first tries. Especially since it is everything but easy to maintain the temperature in the etching solution to be arount 50 degrees Celsius.

So I built my own etching tank. It was the cheapest solution since I already had some of the parts from my fish tank hobby. The etching tank consists of:

  • some sheets of glass
  • silicone
  • aquarium heater
  • aquarium glass thermometer
  • aquarium air pump
  • aqua-curtain air diffusor
  • air hose
  • parts of a cable channel (?) that hold the air diffusor and the board in place
  • a plastic container to put underneath the whole thing, since this is the first time I ever glued glass…

The tank holds about one liter of etching solution (natrium persulfate). The size fits quite exactly for one full euro card (16x10cm), the process takes about 10 to 15 minutes.

I am more than happy with the results. I didn’t make any detailed tests yet, but till now I found all the fine structures on my boards that I wanted to be there.