simple digital clock based on PIC 16F628

This is a small project i did several years ago. The board basically consist of 4 7-segment displays some resistors and 4 transistors and last but not least a PIC 16F628. This microcintroller from Microchip was my favourite one because they are robust and easy to use. They can be clocked using an internal clock such that no further external components are needed. Well the price of that is the relative imprecise clock.

pic clock

The probably most interesting part of the project was the multiplexing of the 7 segments. One might think we need 4 x 7 (omitting the dot) = 28 ports of the microcontroller to control all digits. The cleverer way is to use multiplexing. The principle is: Switch on the first 7-segment LED and make it display the correct number (/character). Then switch the first one off and switch on the second one and surely make it display the correct number. And so on. Now if this is done fast enough, the human eye is not able to see these changes and acts therefore as demultiplexer. This type of control is the reason of the 4 transistors. They are in charge to switch on the particular 7-segment display.

The programm code is very easy. Having a variable for hour, minute and second, every second the second variable is increased and if it is larger than 59, set it to 0 and increase the minutes…. Then go to sleep for somewhat of one minute and the repeat. Everybody knows how a clock works.

As i used the internal clock source, the clock was not very precise, sinc the “speed” of the clock is a little bit dependet on the temperature (and may be other things). Also the contrast of the 7-seg display is not very good. I did not calculated exact values for the resistors. I just estimated them roughly.

For details, check out this website: sprut.de (Only german. In my opinion one of the best references on Microchip PICs!)

Leave a comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.