pic16f877 based controllable digital 25

Not rated 10,262

Circuit Image

The PIC16 simulator (Proteus) allows for the verification of digital clock code, which can be modified as needed. Three push buttons are utilized to adjust the time. The code is written in C language using MPLAB with the HI-TECH C compiler. The corresponding code can be downloaded from the Downloads section at the bottom of the page. The displayed figure shows the clock set to 07:58:54. Timer0 serves as the base for digital clock generation, producing 1 ms interrupts. With each 1 ms interval, a global variable named msCounter increments. When msCounter reaches 1000, another global variable named secCounter increments, continuing this pattern. When secCounter reaches 60, minCounter increments, and when minCounter reaches 60, hrCounter increments. This cycle continues until hrCounter reaches 24, at which point all variables reset. The LCD updates with the new values of hrCounter, minCounter, and secCounter every second. Time can be set using three push buttons connected to the RE0, RE1, and RE2 pins. Pressing the 'Set Time' button once enters configuration mode, causing the Hours value to blink, which can be modified using the Up and Down buttons. Pressing the Up button increments the value while the Down button decrements it. After setting the Hours value, pressing the 'Set Time' button again allows for the adjustment of the Minutes value in the same manner. This process is repeated for the Seconds value. After completing the adjustments, pressing the 'Set Time' button one last time allows the clock to operate normally.

The digital clock circuit utilizes a PIC16 microcontroller, which is programmed to manage timekeeping through the use of Timer0 for generating precise timing intervals. The timer is configured to trigger an interrupt every millisecond, enabling the microcontroller to maintain an accurate count of time. The msCounter variable serves to count these milliseconds, and upon reaching 1000, it signals the increment of the secCounter variable, effectively transitioning the count from milliseconds to seconds.

The clock's time-setting interface consists of three push buttons connected to designated pins on the microcontroller (RE0, RE1, RE2). The 'Set Time' button toggles the clock into a configuration mode, where the user can sequentially adjust the hours, minutes, and seconds. The blinking of the corresponding time value indicates which part of the time is currently being set. The Up and Down buttons facilitate the incrementing and decrementing of the selected time value, ensuring user-friendly interaction.

Furthermore, the LCD display is utilized to provide real-time feedback of the clock settings. It updates every second to reflect the current time, ensuring the user has a clear view of the clock's status. The logic governing the transitions between hours, minutes, and seconds is implemented using conditional statements that reset the counters appropriately once their maximum values are reached, maintaining a 24-hour format.

Overall, this digital clock circuit exemplifies an efficient use of microcontroller capabilities, timer interrupts, and user interface design to create a functional and adjustable timekeeping device.Using PIC16 simulator (Proteus) you can verify this digital clock code and change it according to your needs. Using three push buttons (As shown in figure below) you can adjust time as you desire. This code is written in C language using MPLAB with HI-TECH C compiler. You can download this code from the `Downloads`section at the bottom of this pag e. The above figure was taken after setting time to 07:58:54, timer0 is used as the base for digital clock generation. Timer0 is used here to generate 1msec interrupts. After every 1msec a global variable namedmsCounterincrements. WhenmsCounterreaches a value of 1000 then another global variable namedsecCounterincrements and this process repeats itself.

Similarly, whensecCounterreaches 60, then minCounterincrements. And whenminCounterreaches 60 thenhrCounterincrements. This process continues untilhrCounterreaches 24 then all of these variables reset their values. LCD is updated with the new values ofhrCounter, minCounterandsecCounterafter every second. You can set time using three push buttons attached onRE0, RE1andRE2pins (As shown in the above figure). By pressing `Set Time` button one time, code enters in configuration state. Hoursvalue starts to blink and you can modify it usingUpandDownbuttons. PressingUpbutton increments the value and pressingDownbutton decrements the value. When you are done settingHoursvalue, press`Set Time` button again, thenMinutesvalue will start to blink and you can adjust this value usingUpandDownbuttons.

Similarly, after setting Minutes value, you canpress`Set Time` button again, thenSecondsvalue will start to blink and you can adjust this value usingUpandDownbuttons. When you are done adjusting the time, then press`Set Time` button for the last time and this clock will start to work normally.

🔗 External reference




Warning: include(partials/cookie-banner.php): Failed to open stream: Permission denied in /var/www/html/nextgr/view-circuit.php on line 713

Warning: include(): Failed opening 'partials/cookie-banner.php' for inclusion (include_path='.:/usr/share/php') in /var/www/html/nextgr/view-circuit.php on line 713