00 to 99 minute timer using PIC16F628A microcontroller

Not rated 18,792

Circuit Image

A source code for a simple PIC-based digital timer is provided. The hardware for the project is not available; however, it will be demonstrated using a DIY PIC16F628A breadboard module and I/O board. The complete circuit diagram and firmware developed using the mikroC Pro for PIC compiler are included in the article. The microcontroller utilized in this project is the PIC16F628A, operating at a 4.0 MHz clock frequency with an external crystal. An HD44780-based 16x2 character LCD serves as the main display unit, allowing users to view and set the timer duration using tact switch inputs. Three tact switches are connected to the RB0 (Start/Stop), RB1 (Unit), and RB2 (Ten) pins. The timer interval can be selected from 0 to 99 minutes using the Unit and Ten minute switches. The Start/Stop switch toggles the timer ON and OFF. When the timer is activated, a logic high signal appears on the RA3 pin, which can be used to switch on a relay. In this demonstration, the timer output (pin RA3) is connected to an LED, which turns ON when the timer starts and turns OFF when the timer duration elapses. Upon powering ON the device, the microcontroller initializes the LCD display and shows a message indicating that the timer is initially OFF, along with the LED or relay connected to the RA3 pin. Users can set the time duration between 00 and 99 minutes (in 1-minute increments) using the Unit and Ten tact switches. Each press of a switch increments the corresponding time digit. Once the desired time is set, pressing the Start/Stop switch turns ON the timer, causing the RA3 pin to go high (illuminating the LED) and initiating the countdown. While the timer is active, the remaining time is displayed on the LCD screen. When the time elapses, the timer stops, and the LED turns OFF. The timer can be interrupted and stopped at any time by pressing the Start/Stop switch again. The firmware for the PIC is developed using the mikroC Pro for PIC compiler, avoiding the use of hardware timers for simplicity; time delays are generated using the Delay_ms() function of mikroC, which provides reasonably accurate timing delays.

The digital timer circuit is designed around the PIC16F628A microcontroller, which is a popular choice for embedded applications due to its versatility and ease of use. The microcontroller's I/O pins are configured to interface with the LCD and tact switches, allowing for seamless user interaction. The HD44780 LCD is a widely utilized display module that provides a straightforward means of displaying alphanumeric characters, making it ideal for timer applications.

The tact switches connected to the RB0, RB1, and RB2 pins are utilized for controlling the timer. The RB0 pin acts as the Start/Stop control, while the RB1 and RB2 pins are designated for setting the unit and ten-minute values, respectively. The microcontroller's firmware processes the inputs from these switches, updating the timer settings accordingly.

The logic high signal from the RA3 pin is pivotal for controlling external devices such as relays or LEDs. In this implementation, an LED is used to provide a visual indication of the timer's status. When the timer is activated, the RA3 pin outputs a high signal, illuminating the LED to signify that the countdown is in progress. Upon completion of the timer duration, the LED is turned OFF, providing a clear indication to the user that the set time has elapsed.

The initialization routine for the LCD display is crucial for providing feedback to the user. Upon powering the device, the microcontroller initializes the display and provides a clear message indicating that the timer is OFF. This feedback is essential for user confidence in the operation of the timer.

The time setting mechanism is designed for simplicity, allowing users to increment the timer values easily. The use of the mikroC Pro for PIC compiler streamlines the development process, enabling the implementation of the Delay_ms() function to create timing delays without the complexity of hardware timer configurations. This approach ensures that the timer operates accurately while maintaining a straightforward design.

In summary, this PIC-based digital timer project showcases the integration of a microcontroller, LCD display, and user input through tact switches, resulting in a functional and user-friendly timer application. The design emphasizes simplicity and clarity, making it an excellent example for educational purposes and practical applications in embedded systems.A source code for a very simple PIC based digital timer. The actual hardware of the project isn`t with me anymore. I will rather demonstrate it using my DIY PIC16F628A breadboard module and I/O board. The complete circuit diagram along with the firmware developed using mikroC Pro for PIC compiler is provided in the article. 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 16G—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. I am using my self-made breadboard module for PIC16F628A and experimenter`s I/O board 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. 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. 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. 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. 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.

🔗 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