This is a continuation of this post Using the PIC16F690’s (and others’) Internal Timers to Keep Time
We are not using a crystal or an RTC for this digital clock!!! This is just a demonstration of the internal timers and is not intended to keep actual time.
So, since we aren’t using an RTC, and we are using just a simple internal RC oscillator embedded in our PIC16F690, what kind of accuracy are we looking at? Well, if you are a perfectionist, than stop reading!!! This will not compete with your Seiko (You’ll see why I said that soon). It can’t compete with the DS1305. What it can do is make a somewhat accurate clock at half the cost and half the soldering(maybe) and half the programming and half… I think you might see my point of why this is a cool project. We all have cell phones and computers that have Atomic timekeeping or something, but who has an Altoids clock? Or whatever you decide to do with it? If you can initial off on the “not perfect” line, please continue. (I’ll explain how inaccurate this thing is in just a few paragraphs)
There have been lots of late nights at Tech-tut.com, lately. There are many projects out: an LED light system, temperature probes, and another time keeping device. I was digging through my barn earlier looking for microcontrollers. I found a DS1305, and I laughed. Then, just outside the barn door where I weed-eated last week I saw something black with a silver lining. It was a PIC16F88-I/F if I recall. The legs were pretty weed-eated (gnarled) up, and I was a little sad. None-the-less, I came in and ordered ten more PIC16F690 ICs from Digikey.com. I’ve been working with the same and only one this last week or so. I’m about to allow an Altoids can to digest this one.
The program is fairly simple. It starts at 0000 in 24-hour time. I’ve had it up to 0017 before I started it over. I had to fix some issues. First, my number 1 was on the wrong side of the 7-segment LED. I fixed that. Then I also noticed a “panning” as the microcontroller switched digits. The reason being is that if you could record this in high speed, you’d notice that only one digit is lit at any given time. I don’t know where I learned this trick, but it is along the lines of multiplexing. This particular program only works with common cathode LEDs. I have 7 wires running to the 7 segments. Then I use the 4 grounds. As long as the ground to the other 3 digits is high, it will not illuminate. As soon as a pin goes low, the LEDs illuminate. How cool is that? Summing this up, instead of using 28 pins (4×7 segments) and having each cathode connected to ground, I have 7 pins and 4 grounds making a total of 11 pins of the microcontroller being used.
To make the multiplexing work, the 7 segments are on the same port. I chose port c for the 7 anodes, and I chose port b for the 4 cathodes. If you download the schematic and the program file, you can see how I chose these outputs for these 2 ports. You can do it any way you’d like as long as you keep the anodes on port c and cathodes on port b. you just have to make chart to figure out what hex, or binary, or base ten numbers to output to each port. It’s actually more fun than it is work.
Here’s what’s up. I’ve finished the program. I have also installed this thing into an Altoids can. Here’s the issue that I didn’t even think about. I wanted to use a 3 volt coin cell to power this. The PIC16F690 can run at least to 2 volts, but the blue LEDs cannot! Their forward voltage is somewhere in the 3.4 volt range before they break the barrier. Well, Well, Well… I had a bright idea to use a supercap. It dies pretty fast. The PIC keeps running, but the time won’t display. Anyways, aesthetically, my Altoids tin clock is not going to be pretty. If I were to use a different color display, I could use the coin cell, but I want them blue. If you are wanting to do this project then you can choose whatever color you can live with.