{"id":4069,"date":"2011-11-29T21:51:00","date_gmt":"2011-11-30T02:51:00","guid":{"rendered":"http:\/\/embedded-lab.com\/blog\/?p=4069"},"modified":"2012-07-30T09:29:14","modified_gmt":"2012-07-30T13:29:14","slug":"00-to-99-minute-timer-using-pic16f628a-microcontroller","status":"publish","type":"post","link":"https:\/\/embedded-lab.com\/blog\/00-to-99-minute-timer-using-pic16f628a-microcontroller\/","title":{"rendered":"00 to 99 minute timer using PIC16F628A microcontroller"},"content":{"rendered":"<p>Last week I was browsing my old backup hard drive and I found a source code for a very simple PIC based digital timer that I made a couple of years ago. The actual hardware of the project isn&#8217;t with me anymore. I might have lost it when I moved from my old apartment into my new home. However, I thought this might be a good practice project for beginners and so I am sharing it here. I am not going to build it from scratch again; I will rather demonstrate it using my DIY\u00a0<a href=\"http:\/\/embedded-lab.com\/blog\/?p=1034\" target=\"_blank\">PIC16F628A breadboard module<\/a> and <a href=\"http:\/\/embedded-lab.com\/blog\/?p=3596\" target=\"_blank\">I\/O board<\/a>. The complete circuit diagram along with the firmware developed using mikroC Pro for PIC compiler is provided in the article.<\/p>\n<div id=\"attachment_4074\" style=\"width: 570px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/11\/99MinTimerTitle.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4074\" class=\"size-full wp-image-4074\" title=\"99MinTimerTitle\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/11\/99MinTimerTitle.jpg\" alt=\"\" width=\"560\" height=\"364\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/11\/99MinTimerTitle.jpg 560w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/11\/99MinTimerTitle-550x357.jpg 550w\" sizes=\"auto, (max-width: 560px) 100vw, 560px\" \/><\/a><p id=\"caption-attachment-4074\" class=\"wp-caption-text\">0-99 minute timer<\/p><\/div>\n<p><!--more--><\/p>\n<p><strong>Circuit diagram<\/strong><\/p>\n<p>As I mentioned earlier, the microcontroller used in this project is PIC16F628A running at 4.0 MHz clock using an external crystal. An HD44780 based 16&#215;2 character LCD is the main display unit of the project where you can watch and set the timer duration using tact switch inputs. There are three tact switches connected to RB0 (Start\/Stop), RB1 (Unit), and RB2 (Ten) pins. You can select the timer interval from 0-99 min using Unit and Ten minute switches. The Start\/Stop switch is for toggling the timer ON and OFF. When the timer gets ON, a logic high signal appears on the RA3 pin, which can be used to switch on a Relay. The circuit diagram of this project is described below.<\/p>\n<div id=\"attachment_4082\" style=\"width: 560px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/11\/99MinTimerCkt.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4082\" class=\"size-medium wp-image-4082\" title=\"99MinTimerCkt\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/11\/99MinTimerCkt-550x438.png\" alt=\"\" width=\"550\" height=\"438\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/11\/99MinTimerCkt-550x438.png 550w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/11\/99MinTimerCkt.png 726w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/a><p id=\"caption-attachment-4082\" class=\"wp-caption-text\">0-99 minute timer circuit<\/p><\/div>\n<p>I am using my self-made\u00a0<a href=\"http:\/\/embedded-lab.com\/blog\/?p=1034\" target=\"_blank\">breadboard module for PIC16F628A<\/a> and <a href=\"http:\/\/embedded-lab.com\/blog\/?p=3596\" target=\"_blank\">experimenter&#8217;s I\/O board<\/a> here to demonstrate this project. Since there is no relay switch in the I\/O board, I am connecting the timer output (pin RA3) to an LED. When the timer starts, the LED is turned ON. As the timer duration is elapsed, the LED is turned OFF.<\/p>\n<div id=\"attachment_4072\" style=\"width: 570px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/11\/99MinTimerSetup.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4072\" class=\"size-full wp-image-4072\" title=\"99MinTimerSetup\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/11\/99MinTimerSetup.jpg\" alt=\"\" width=\"560\" height=\"348\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/11\/99MinTimerSetup.jpg 560w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/11\/99MinTimerSetup-550x341.jpg 550w\" sizes=\"auto, (max-width: 560px) 100vw, 560px\" \/><\/a><p id=\"caption-attachment-4072\" class=\"wp-caption-text\">Circuit setup<\/p><\/div>\n<p><strong>Operation of the Timer\u00a0<\/strong><\/p>\n<p>When the device is powered ON, the microcontroller initializes the LCD display and shows the following message. The timer is initially OFF and so does the LED or relay, whichever is connected to RA3 pin.<\/p>\n<div id=\"attachment_4091\" style=\"width: 570px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/11\/99MinTimerStart.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4091\" class=\"size-full wp-image-4091\" title=\"99MinTimerStart\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/11\/99MinTimerStart.jpg\" alt=\"\" width=\"560\" height=\"387\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/11\/99MinTimerStart.jpg 560w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/11\/99MinTimerStart-550x380.jpg 550w\" sizes=\"auto, (max-width: 560px) 100vw, 560px\" \/><\/a><p id=\"caption-attachment-4091\" class=\"wp-caption-text\">Message displayed at power on<\/p><\/div>\n<p>You can set time duration between 00-99 min (in step of 1 min) using the Unit and Ten tact switches. Each switch press will increment the corresponding time digit.<\/p>\n<div id=\"attachment_4073\" style=\"width: 556px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/11\/99MinTimerTimeSet.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4073\" class=\"size-full wp-image-4073\" title=\"99MinTimerTimeSet\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/11\/99MinTimerTimeSet.jpg\" alt=\"\" width=\"546\" height=\"393\" \/><\/a><p id=\"caption-attachment-4073\" class=\"wp-caption-text\">Setting timer minute<\/p><\/div>\n<p>When the desired time is set, press the Start\/Stop switch to turn ON the timer. The RA3 pin goes high (LED glows) and the count down begins. When the timer is ON, the remaining time is also shown on the LCD screen. When the time elapsed, the timer stops and the LED turns OFF. You can interrupt and stop the timer at anytime by pressing the Start\/Stop switch once more.<\/p>\n<div id=\"attachment_4071\" style=\"width: 570px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/11\/99MinTimerOutput.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4071\" class=\"size-full wp-image-4071\" title=\"99MinTimerOutput\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/11\/99MinTimerOutput.jpg\" alt=\"\" width=\"560\" height=\"380\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/11\/99MinTimerOutput.jpg 560w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/11\/99MinTimerOutput-550x373.jpg 550w\" sizes=\"auto, (max-width: 560px) 100vw, 560px\" \/><\/a><p id=\"caption-attachment-4071\" class=\"wp-caption-text\">Displaying the left over time on LCD<\/p><\/div>\n<p><strong>Software<\/strong><\/p>\n<p>The firmware for PIC is developed using mikroC Pro for PIC compiler. The use of Timers are avoided for simplicity. The time delays are created using the Delay_ms() function of mikroC, which seems to give reasonably accurate timing delays.<\/p>\n<p><strong><a href=\"http:\/\/embedded-lab.com\/uploads\/HexFiles\/PIC16F628A\/99MinTimer.zip\">D<\/a><a href=\"http:\/\/embedded-lab.com\/uploads\/HexFiles\/PIC16F628A\/99MinTimer.zip\">ownload mikroC source code and HEX file<\/a><\/strong><\/p>\n<p>For a more advanced digital timer switch, read my another project: <strong><a href=\"http:\/\/embedded-lab.com\/blog\/?p=1378\">Programmable digital timer<\/a>.<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last week I was browsing my old backup hard drive and I found a source code for a very simple PIC based digital timer that I made a couple of years ago. The actual hardware of the project isn&#8217;t with me anymore. I might have lost it when I moved from my old apartment into my new home. However, I thought this might be a good practice project for beginners and so I am sharing it here. I am not going to build it from scratch again; I will rather demonstrate it using my DIY\u00a0PIC16F628A breadboard module and I\/O board.<\/p>\n","protected":false},"author":1,"featured_media":4071,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[245,4],"tags":[376,375,96],"class_list":["post-4069","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-embedded-lab-projects","category-pic-projects","tag-digital-timer","tag-pic-timer","tag-pic16f628a"],"_links":{"self":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts\/4069","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/comments?post=4069"}],"version-history":[{"count":16,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts\/4069\/revisions"}],"predecessor-version":[{"id":5709,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts\/4069\/revisions\/5709"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/media\/4071"}],"wp:attachment":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/media?parent=4069"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/categories?post=4069"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/tags?post=4069"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}