Overview

I had been messing around with all sorts of bits and bobs that I had gotten in samples from Microchip, Maxim and TI. What I wanted to do was build something that not only performed a task, but also used some of my messing about experience to a practical end.

The main components are;
Microchip PIC 18f2525, a Maxim MAX6956 to drive 60 LEDs and a Maxim DS1307 RTC.

Front face of prototypeBack face of prototype

Here you can see the general overview of the prototype. The PIC is the top chip, the MA6956 is in the center (for easy wiring), the RTC is to the left. In the back view you can see the full wonder of the rats nest wiring! You can see the input buttons and the LDR on the top of the board. There’s the bootload port on the (top left), the reset button (top right), power input bottom (bottom right), Variable resistor for LED current (middle right)

The PIC 18f2525 (datasheet) is my general purpose work horse. It has loads of features such as i2c, SPI, uart, PWM, analog, timers and much more. I tend to start out with this chip as my default choice with the idea of picking something more specific as the project develops (something that never really happens).

It’s over kill really but this is supposed to be about having fun and getting something working, not about optimizing everything to the n’th degree just to save a few pence. It’s nice to have flexibility to throw in a few extra outputs to see what’s going on, or to dedicate the TX/RX pins to bootloading and debug without having to worry about using them for other purposes.

I use the excellent tinyBld bootloader which means I can keep revising and uploading without having to remove the chip. It really is tiny (100words) and doesn’t need any specific setup in MPLAB to create code that just runs. The windows bootloader program also has a cool feature that it can use the RTS/DTS line of the serial port to trigger a reset of the PIC which saves a lot of poking around the circuit.

The MAX6956 (datasheet) is a “2-Wire-Interfaced, 2.5V to 5.5V, 20-Port or 8-Port LED Display Driver and I/O Expander” (as per the datasheet)
This is a great chip, it’s easy to interface to using i2c (there’s an SPI version too the MAX6957). I chose i2c as I need to use i2c to talk to the RTC anyway.The PDIP package version of the MAX6956 has 20 ports, each port can be either a digital input or output, or a constant current LED driver.
The current can be controlled in three ways;

  1. Externally using a simple resistor which governs over all max current per port.
  2. Software config per port (4 bits per port).
  3. Software config globally using a single 4 bit register

You can combine method 1 with either 2 or 3 to easily manage the current and brightness of the attached LEDs.

For the prototype intended to use the single global current register to control over all brightness of the display. The idea being to use a CdS LDR on one of the PIC’s analogue inputs to sense the ambient light level and dim the LED’s accordingly at nighttime.

The DS1307 is a simple Real Time Clock. It’s quite an old design and there are newer better choices, but I had one of these on a protoboard from SparkFun Electronics that I had used before. You talk to it over i2c, you set the time/date and it remembers for around 9 years or so on a single coin cell. Pretty simple. It also has a bit of spare memory that you can use to store your own data and a square wave output that you can set to one of a number of frequencies (1hz being the most useful in my case).

The only slightly complex thing is that it stores the time in Binary Coded Decimal which is a minor pain as you need to encode/decode when ever you talk to it.

It doesn’t have some of the features that newer variants have such as alarms and it will only run from 5 volts but for this application it’s great.

The LEDs for the prototype are all single colour cheapo 5mm jobbies bought from eBay

The code was originally written using Boost C but I subsequently ported it to Microchip C18 as I was having a bit of a nightmare getting to grips with Boost C’s libraries and documentation.

Function wise, it’s nothing special. It’s a clock after all.
It has displays the time as a solid dot for the hours, a 1Hz blinking dot for the minutes and an optional “fast” moving dot for the seconds.

That’s all for now. The next section will be about the software.

2 thoughts on “Overview

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s