This project is probably my first “real” project involving microcontrollers (I had not worked with microcontrollers prior to college). By “real”, all that I actually mean is that I took the time to solder it. Previously, my only microcontroller experience was breadboarding some blinking lights and or playing around with individual peripherals (UART, timer, etc.) without any real end goal. In contrast, this was a project with a well-defined objective, potential practical application (so long as you can read in binary), and a PCB (the pre-printed RadioShack kind, not a custom design).
That said, this is also a very shameful project for me. In fact, this project is a very good example of how to do everything wrong:
- There is no user input to set the time (plug it in at midnight and let it run)
- There is no crystal for accurate timekeeping
- The power dissipation from the LEDs may exceed the maximum ratings of the microcontroller
Well, that’s embarassing. Although no amount of excuses can justify the shortcomings of this project, allow me at least provide some explanation of why it turned out this way. First and foremost, I was aiming for minimalism with this project. I wanted to use a single low pin count IC, which in this case was a PIC16F690 (I chose that part simply because I had an abundance of them). Unfortunately, the PIC16F690 had exactly enough outputs (17) to independently drive all of the LEDs for the display.
At this point, you may point out that I could have used charlieplexing to drive more LEDs using fewer pins and no additional external hardware. Well, I didn’t know about charlieplexing at the time, so I just went with the naive approach and gave every LED its own drive pin. This, of course, also means that each pin might be sourcing perhaps 10~20mA, making the overall I/O power sourced from the PIC hundreds of milliamps, or around 1W at 5V. This would exceed the absolute maximum ratings specified for the PIC.
So at any rate, there were no spare pins available for an external crystal or any reasonable input device (okay, there was actually one input-only pin leftover, but nobody likes to use a single pushbutton to try to set the time, and my minimalism goal prevented me from doing any fancy serialization or I/O expansion). The lack of a crystal made this worthless as a timekeeping device, as I was at the mercy of the PIC’s internal RC oscillator for the clock source. This type of clock source can drift significantly with voltage and temperature. In fact, I noticed that the clock would be off by several seconds after just several hours of running.
Clearly, this first project was poorly planned. Nonetheless, some good did come from it. I got to gain more exposure to the PIC16F690, which was still fairly new to me at the time (as was working with microcontrollers in general). I also programmed the project in assembly language, which is always a good way to gain a better appreciation for the hardware. As my soldering experience was also quite limited at the time, this project also gave me the opportunity to practice soldering more. Of course, I also got to work with register manipulation, bitwise operations, reading datasheets, and working with the timer module and interrupts. Overall, then, this was a pretty significant learning experience.